Border style of Excel forms

23 views
Skip to first unread message

Shu

unread,
Apr 28, 2004, 10:34:42 PM4/28/04
to
Hello,
Why the form in Excel can not be set with some maximize or
minimize icon on the top ritht of form. Only two options
are provided in Excel VBE. One is 0-frmborderStylenone,
the other is 1-frmborderstylesingle. But There are more
choices in VB.

Is there any way to set up them?

Thanks very much.

Rgds
Shu

Michel Pierron

unread,
Apr 29, 2004, 3:48:25 AM4/29/04
to
Hi Shu;
Private Declare Function FindWindow& Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName$, ByVal lpWindowName$)
Private Declare Function SetWindowLong& Lib "user32" Alias _
"SetWindowLongA" (ByVal hWnd&, ByVal nIndex&, ByVal dwNewLong&)
Private Declare Function EnableWindow& Lib "user32" (ByVal hWnd&, ByVal fEnable&)
Private Declare Function ShowWindow& Lib "user32" (ByVal hWnd&, ByVal nCmdShow&)

' Minimize in application
Private Sub UserForm_Initialize()
Dim Style As Long
' Min: &H20000 / Max: &H10000 / Resize: &H40000
Style = &H84C80080 Or &H20000 Or &H40000
SetWindowLong FindWindow(vbNullString, Me.Caption), -16, Style
EnableWindow FindWindow(vbNullString, Application.Caption), 1
End Sub

To reduce the userform in the Taskbar, add the procedure:
' Minimize in TaskBar
Private Sub UserForm_Activate()
Dim hWnd As Long
hWnd = FindWindow(vbNullString, Me.Caption)
ShowWindow hWnd, 0
SetWindowLong hWnd, -20, &H40101
ShowWindow hWnd, 1
End Sub

Regards
MP

"Shu" <anon...@discussions.microsoft.com> a écrit dans le message de
news:5cef01c42d92$86aee320$a101...@phx.gbl...

Michel Pierron

unread,
Apr 29, 2004, 4:31:12 AM4/29/04
to
Hi Shu;
In complement of my post, you can use the following procedure to display the
userform in no modal mode:

Sub NoModalMode()
#If VBA6 Then
UserForm1.Show 0
#Else
UserForm1.Show
#End If
End Sub

MP

"Shu" <anon...@discussions.microsoft.com> a écrit dans le message de
news:5cef01c42d92$86aee320$a101...@phx.gbl...

Shu

unread,
Apr 29, 2004, 7:33:56 AM4/29/04
to
Thanks a lot, Michel.

Shu

>.
>

Reply all
Reply to author
Forward
0 new messages