Max/Min Buttons missing & Window won't max


Posted by tee on August 02, 2001 7:47 PM

Hi Everyone

I am in a bit of a bother.

I have done some changes to my code and now my workbook window refuses to Maximized and the Max and Min buttons are not displayed.

I have since gone back and undone my changes but it is still not working.

Any help would be much appricated.

Regards
Tee

Posted by Cory on August 03, 2001 11:06 AM

Your workbook window is missing the buttons? Not a userform (which don't come with Min/Max buttons)?

If it's your workbook window, I'd have to see the code...

if it's the userform then Dax posted some good code for me a while back that adds these buttons through use of API calls. Here's that code:

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 DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long

Private Const GWL_STYLE As Long = (-16)
Private Const WS_SYSMENU As Long = &H80000
Private Const WS_MINIMIZEBOX As Long = &H20000
Private Const WS_MAXIMIZEBOX As Long = &H10000

Private Sub UserForm_Activate()
Dim lFormHandle As Long, lStyle As Long
lFormHandle = FindWindow("ThunderDFrame", Me.Caption)
lStyle = GetWindowLong(lFormHandle, GWL_STYLE)
lStyle = lStyle Or WS_SYSMENU
lStyle = lStyle Or WS_MINIMIZEBOX
lStyle = lStyle Or WS_MAXIMIZEBOX
SetWindowLong lFormHandle, GWL_STYLE, (lStyle)
DrawMenuBar lFormHandle
End Sub

This will give your forms that max, min and close buttons. There are API calls to do loads more. You can check 'em out at www.allapi.net...

Cory



Posted by Ivan F Moala on August 03, 2001 3:10 PM

Try restoring via this code ???

Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, _
ByVal bRevert As Long) As Long

Private Declare Function FindWindowA Lib "user32" (ByVal lpClassName As _
String, ByVal lpWindowName As String) As Long


Public Sub GetMenuControlsBack()
Dim ActWinCaption As String
Dim lHandle As Long

ActWinCaption = "Microsoft Excel - " & ActiveWorkbook.Name & vbNullChar
lHandle = FindWindowA(vbNullString, ActWinCaption)

GetSystemMenu lHandle, True

End Sub

Ivan