Splash Screen


Posted by John Cheung on January 24, 2002 9:56 AM

Hi, I am trying to implement a splash screen for my Excel app. I try to use Userform successfully. However, that leaves the title bar which I cannot find anyway to remove. Does anyone know how to remove the title bar. Any other implementation of splash screen is also welcomed.
thanks
John



Posted by Mark O'Brien on January 24, 2002 10:55 AM

John,

This code was shamelessly, shamelessly (I say) taken from formfun.zip on:

http://www.bmsltd.co.uk/Excel/Default.htm


I've chopped out as much junk as I could in ten minutes. I know for a fact that there's still some unnecessary code still in there, but I can leave it to you to work that. The man behind BMSLtd is called Stephen Bullen and he wrote three chapters of a book that totally changed VBA for me, because he actually tells you how to use API calls.

' API Calls
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function ShowWindow Lib "user32" _
(ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" _
(ByVal hWnd As Long) As Long
Private Declare Function SetFocus Lib "user32" _
(ByVal hWnd As Long) As Long


'Window styles
Private Const GWL_STYLE As Long = (-16) 'The offset of a window's style
Private Const WS_CAPTION As Long = &HC00000
Dim mbcaption As Boolean
Dim hWndForm As Long

Private Sub UserForm_Initialize()

'Get the userform's window handle
If Val(Application.Version) < 9 Then
hWndForm = FindWindow("ThunderXFrame", Me.Caption) 'XL97
Else
hWndForm = FindWindow("ThunderDFrame", Me.Caption) 'XL2000
End If

mbcaption = False
SetFormStyle


End Sub

'Routine to set the form's window style
Private Sub SetFormStyle()

Dim iStyle As Long, hMenu As Long, hID As Long, iItems As Integer

'Have we got a form to set?
If hWndForm = 0 Then Exit Sub

iStyle = GetWindowLong(hWndForm, GWL_STYLE)

'Build up the basic window style flags for the form
If mbcaption Then iStyle = iStyle Or WS_CAPTION Else iStyle = iStyle And Not WS_CAPTION

'Set the basic window styles
SetWindowLong hWndForm, GWL_STYLE, iStyle

iStyle = GetWindowLong(hWndForm, GWL_EXSTYLE)

SetWindowLong hWndForm, GWL_EXSTYLE, iStyle

'Show the window with the changes
ShowWindow hWndForm, SW_SHOW
DrawMenuBar hWndForm
SetFocus hWndForm

End Sub

HTH