Friday, May 24, 2013

Stand out Full Screen View - The Basic principles

This can be a follow-up to my last article Kiosk Full Screen Stand out for 2007/2010.

Here' will outline how to produce a true Full Screen search for Stand out 2007/2010. Here's a catalog from the subjects we'll cover. I'll include Code clips and my logic behind the kind of Code I personally use. I think you'll think it is helpful.

1. Hiding the machine Taskbar
2. Iterating WorkSheets in Kiosk Mode
3. Exiting Kiosk Mode

1. Hiding the machine Taskbar
OK we've several choices if this involves Hiding the machine Taskbar but we're governed slightly in a single respect for the reason that because we will hook into Stand out s own Full Screen view we can't do that and employ API calls to maneuverOrRe-size the Stand out Application MDI Window to merely cover the Taskbar. Therefore we realize that we have to completely hide the Taskbar each launch we currently have to determine how.

One way is to buy a handle towards the Taskbar Window and power it down. Another technique is to toggle/auto-hide the Taskbar as if you would do by hand having a right-click Qualities after which set the car-hide the taskbar checkbox. Why I choose the latter is the fact that:

a) Home windows 7 OS has some issues completely hiding the beginning Button (you are able to almost get it done, however, you get a small curve from the Button that is unsightly. Well that is what I've discovered, that or even the Button continues to be completely visible - it's a little of the discomfort.
b) If unconditionally you neglect to restore the Taskbar customers won't appreciate which makes them get into User Interface and resetting the Taskbar within the Taskbar & Start Menu Configurations.
c) Lastly I discovered that in 2007/2010 and OS like XP, Vista or Home windows 7 you are able to launch Full Screen having a toggle and also the Taskbar remains hidden as Stand out fills the whole Screen whenever you Call Application.DisplayFullscreen = True.

It is therefore for that above reasons which i chose but still make use of the following code within my Kiosk Software inside a VBA Module by:
HideTaskbar()
UnhideTaskbar()

Option Explicit

Private Declare Function _

SHAppBarMessage Lib "shell32.dll" _

(ByVal dwMessage As Lengthy, _

ByRef pData As APPBARDATA) As Lengthy

Private Const ABS_AUTOHIDE As Lengthy = &H1
Private Const ABM_GETTASKBARPOS As Lengthy = &H5
Private Const ABM_GETSTATE As Lengthy = &H4
Private Const ABM_SETSTATE As Lengthy = &'
Private Const ABM_SETAUTOHIDEBAR As Lengthy = &H8
Private Type RECT

left As Lengthy

Top As Lengthy

right As Lengthy

Bottom As Lengthy
Finish Type
Private Type APPBARDATA

cbSize As Lengthy

hWnd As Lengthy

uCallbackMessage As Lengthy

uEdge As Lengthy

rc As RECT

lParam As Lengthy
Finish Type

Dim abd As APPBARDATA
Dim abd_retval, _

abd_setval As Lengthy

' AutoHideTaskBar:: sets the appdardata, lParam struct to autohide the machine taskbar
Public Sub HideTaskbar()

abd_retval = _

SHAppBarMessage(ABM_GETSTATE, abd)

abd.lParam = _

abd_retval Or ABS_AUTOHIDE

abd_setval = _

SHAppBarMessage(ABM_SETSTATE, abd)
Finish Sub

' RestoreTaskBar:: reinstates the autohide system taskbar to some normal condition
Public Sub UnhideTaskbar()

abd_retval = _

SHAppBarMessage(ABM_GETSTATE, abd)

abd.lParam = _

abd_retval And Never ABS_AUTOHIDE

abd_setval = _
SHAppBarMessage(ABM_SETSTATE, abd)
Finish Sub

2. Iterating WorkSheets in Kiosk Mode

Right so onto Iterating WorkSheets in Kiosk Mode. Well clearly we've hidden the Taskbar after which released Full Screen. Within my Kiosk Menu I add the opportunity to hide Gridlines, Titles, WorkSheet Tabs etc. I won't cover that here because it is very elementary VBA coding to do these tasks. Things I covers and reveal to you though is a few code regarding how to iterate Stand out WorkSheets missing over Hidden or Very Hidden Sheets both forward and backward. You will find plenty of functions available to browse one of the ways however i wanted to produce a approach to do either.

First we have to setup an Enum inside a VBA Code Module named b_functions the following (I've given my two Navigator types a distinctive integer of three for Previous, browse backward and a pair of for Next, browse forward):

' browser enum:: for worksheet navigation
Public Enum Navigator

xlNavigatePrevious = 3

xlNavigateNext = 2
Finish Enum

We'll make use of the types above to pass through right into a Function known as Browser (Direction) through the next code (we won't return something):

Iterate the WorkSheet Forwards
Call b_functions.Browser(xlNavigateNext)

Iterate the WorkSheet Backwards
Call b_functions.Browser(xlNavigatePrevious)

This is actually the Function that will the work.

' Browser:: dynamically choose a sheet or chart (hidden, very hidden overlooked) via browser buttons
Public Function Browser(ByVal Direction As Navigator)

' vars
Dim i, _

J, _

K As Integer
Dim DefaultSheet As String ' selected sheet
DefaultSheet = ActiveWorkbook.ActiveSheet.Title
J = ActiveWorkbook.Sheets.Count

With ActiveWorkbook

For i = 1 To J

If DefaultSheet =.Sheets(i).Title Then

Choose Situation Direction

Situation xlNavigatePrevious ' left

Basically > J - (J - 1) Then

While.Sheets(i - 1).Visible = xlSheetVeryHidden Or _
.Sheets(i - 1).Visible = xlSheetHidden

Basically - 1 = J - (J - 1) I quickly = 2: GoTo choose_prev Else i = i - 1

Wend
choose_prev:
.Sheets(i - 1).Choose

Exit For

Else

For K = J To i Step -1

While.Sheets(K).Visible = xlSheetVeryHidden Or _
.Sheets(K).Visible = xlSheetHidden

K = K - 1

Wend
.Sheets(K).Choose

Exit For

Next K

Exit For

Finish If

Situation xlNavigateNext ' right

Basically < J Then

While.Sheets(i + 1).Visible = xlSheetVeryHidden Or _
.Sheets(i + 1).Visible = xlSheetHidden

Basically + 1 = J I quickly = : GoTo choose_next Else i = i + 1

Wend
choose_next:
.Sheets(i + 1).Choose

Exit For

ElseIf i = J Then

For K = 1 To J

While.Sheets(K).Visible = xlSheetVeryHidden Or _
.Sheets(K).Visible = xlSheetHidden

K = K + 1

Wend
.Sheets(K).Choose

Exit For

Next K

Exit For

Finish If

Finish Choose

Finish If

Next i

Finish With
Finish Function
3. Exiting Kiosk Mode

Since Stand out 2007 (Version 12, launched 2007) exiting from Full Screen mode in Stand out was somewhat simpler because of the truth that Stand out now permitted you to definitely press Esc to exit. Nevertheless this poses one big issue - how you can track/trap the applying.DisplayFullscreen = False event?

Once more I considered Sub-classing the MDI Stand out Window and listening for Window messages. Used to do it pretty much simply (infamously hard to do inside a stable manner with no.DLL) nevertheless it still unsuccessful capture the Exit event whenever a WorkBook was Full Screen sized along with the Stand out primary Window being Maximised - all very frustrating. It is because an Exit from Full Screen here triggers no refresh from Stand out so theoretically there's no event to capture.
What exactly else could we all do? Well the technique I selected was to utilize a Home windows API to produce a very fine Timer Thread to do something like a listener for that Application. DisplayFullscreen = false event. After a little experimentation I made the decision to check on with this event every 1/tenth of the second - quite sufficient to capture the most passionate of user exiting the Kiosk mode.

This is actually the Call code, the Subroutines used, Private Function Prototype Terms (.DLL Library's)and code to make use of the Timer Thread (again all saved inside a VBA Code Module named b_functions):

Call b_functions.StartTimer 100

StartTimer(ByVal Duration As Lengthy)
Sub StopTimer()
TimerIsActive() As Boolean
TimerEvent()

' SetTimer
Private Declare Function _

SetTimer Lib "user32" _

(ByVal hWnd As Lengthy, _

ByVal nIDEvent As Lengthy, _

ByVal uElapse As Lengthy, _

ByVal lpTimerFunc As Lengthy) As Lengthy

' KillTimer
Private Declare Function _

KillTimer Lib "user32" _

(ByVal hWnd As Lengthy, _

ByVal nIDEvent As Lengthy) As Lengthy

' timer thread id
Private m_TimerID As Lengthy

Private Sub StartTimer(ByVal Duration As Lengthy)

If m_TimerID = Then

m_TimerID = SetTimer(, , Duration, AddressOf TimerEvent)

Finish If
Finish Sub

Private Sub StopTimer()

If m_TimerID Then

KillTimer , m_TimerID

m_TimerID =
** DO EXIT CODE HERE **

Finish If
Finish Sub

Private Property Get TimerIsActive() As Boolean

TimerIsActive = (m_TimerID )
Finish Property

Private Sub TimerEvent()

If Application.DisplayFullScreen = False Then

StopTimer

Finish If
Finish Sub

Well that about systems up for the time being. Mark Kubiszyn.

No comments:

Post a Comment