Disable restore button on menu bar

xezekielx

straight edge
Local time
Today, 11:53
Joined
Jul 19, 2005
Messages
7
Is it possible to disable the Restore button that's displayed on the menu bar when a form is maximised?
 
I have run in the same Cave.
I have a main form that is maximised on form load.Cosequently it docks its self in a restored state, so when the user restores it it shrinks to a smaller size. I want to completey avoid this. I have researched but also failed to find the solution.
Any Ideas to get us out of this cave.
Thanks in advance.
 
Here is the Solution.

Set the form's Borderstyle=None
Controlbox=Yes
Max or Min buttons= Enabled

Code:
 Option Explicit
Private Const WS_THICKFRAME As Long = &H40000
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 SetWindowPos Lib _
   "user32" (ByVal hwnd As Long, ByVal _
   hWndInsertAfter As Long, ByVal x As Long, _
   ByVal y As Long, ByVal cx As Long, ByVal _
   cy As Long, ByVal wFlags As Long) As Long
Function DisableResBtn(frm As Form)
   Const WS_THICKFRAME = &H40000
   Const WS_MAXIMIZE = &H1000000
   Const WS_MAXIMIZEBOX = &H10000
   Const GWL_STYLE = (-16)
   Const SWP_FRAMECHANGED = &H20
   Const SWP_NOMOVE = &H2
   Const SWP_NOSIZE = &H1
   Const SWP_NOZORDER = &H4
   'Const HWND_TOP = 0
   
   Dim nStyle As Long
   Dim hwnd As Long
   nStyle = GetWindowLong(frm.hwnd, GWL_STYLE)
   nStyle = nStyle And Not (WS_THICKFRAME)
   nStyle = nStyle And Not (WS_MAXIMIZE)
   nStyle = nStyle And Not (WS_MAXIMIZEBOX)
   Call SetWindowLong(frm.hwnd, GWL_STYLE, nStyle)
   SetWindowPos frm.hwnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED Or SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOZORDER

End Function

On the form's onload event.
Code:
Docmd.maximize
DisableResBtn Me
 
Last edited:

Users who are viewing this thread

Back
Top Bottom