This very simple bit of code will give me the minimize and maximize buttons
on
my userform:
Option Explicit
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&)
Private hWnd As Long
Private Sub UserForm_Initialize()
hWnd = FindWindow(vbNullString, Me.Caption)
SetWindowLong hWnd, -16, &H20000 Or &H10000 Or &H84C80080
End Sub
Private Sub UserForm_Activate()
' Minimize in TaskBar (activate following lines)
'ShowWindow hWnd, 0
'SetWindowLong hWnd, -20, &H40101
'ShowWindow hWnd, 1
EnableWindow FindWindow(vbNullString, Application.Caption), 1
End Sub
Now how could I use this and add 2 more things:
Run a Sub when the maximize button gets pressed.
I am happy with the minimize result and would leave this as it is.
Make keyboard shortcuts for both the minimize and maximize actions.
I did post this in the VB API group, but maybe because it is VBA I got no
reply.
I am sure that if there was an answer for this many VBA coders would be
interested
in this.
RBS