I would like to be able to stop users maximising a form. Can anyone point me to an article or post some code that would allow me to "Grey" it out?
Regards
James Roche
Printable View
I would like to be able to stop users maximising a form. Can anyone point me to an article or post some code that would allow me to "Grey" it out?
Regards
James Roche
Wouls this work for you?
Code:Option Explicit
Private Const GWL_STYLE = (-16)
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_THICKFRAME = &H40000
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 GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Sub Form_Load()
'=======================
Dim hMenu As Long
Dim lStyle As Long
'disable MAXIMIZE button
lStyle = GetWindowLong(Me.hwnd, GWL_STYLE)
lStyle = lStyle And Not WS_MAXIMIZEBOX
Call SetWindowLong(Me.hwnd, GWL_STYLE, lStyle)
'uncomment the following block if you need to make form not resizeable
' lStyle = GetWindowLong(Me.hwnd, GWL_STYLE)
' lStyle = lStyle And Not WS_THICKFRAME
' Call SetWindowLong(Me.hwnd, GWL_STYLE, lStyle)
End Sub
Why can't you set the maximize property (of the form) to False?
If you meant to say MaxButton then of course that would work too but only if don't need to change it again.Quote:
Originally Posted by Pasvorto
For toggling (True/Fals) Max/Min/Close buttons you'll have to use Windows APIs.
I just took it as a "blanket" can't maximize the form. I may have misunderstood.
I just disable the maximize button of the form in design.
SetWindowlacement also will work.
http://allapi.mentalis.org/apilist/S...lacement.shtml
Lol, i didnt realise the form has a max button property, thats done the trick. Thanks guys :)