Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to remove the minimize button by code 1

Status
Not open for further replies.

samotek

Technical User
May 9, 2005
197
BG
How can I remove the three buttons on the upper right corner in the database ? These three buttons are called “minimize” “restoredown”and “close”. With the command
Application.CommandBars("Menu bar").Enabled = False
I remove all the buttons and the screen is clear of them, but these three buttons remain on the right upper corner. Is there any command with which to remove them by code ?

 
You need to change the ControlBox property (or MinMaxButtons and CloseButton separately).

This can be done at design time in the properties window or at runtime. It seems that even if you are changing the properties at runtime the form must be opened in design vuew first...

Ed Metcalfe.

Please do not feed the trolls.....
 
Thank you for the reply. In the design view of the form i have put No to the properties ControlBox
and CloseButton but these buttons persist to stay at the upper right corner of the screen. perhaps they are tied up not with Acces but with Windows ?
 
We've had this discussion elswhere today; he's not talking about on a form, he's talking about on the the Access application itself!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Aha! So that's why it's not working!

Ed Metcalfe.

Please do not feed the trolls.....
 
I took this code from another forum (and then promptly forgot which one - sorry) and modified it slightly. I think it will do what you want:

Code:
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 Const GWL_STYLE = (-16)
Private Const WS_CAPTION = &HC00000 ' WS_BORDER Or WS_DLGFRAME
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_SYSMENU = &H80000

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
Private Enum ESetWindowPosStyles
    SWP_SHOWWINDOW = &H40
    SWP_HIDEWINDOW = &H80
    SWP_FRAMECHANGED = &H20 ' The frame changed: send WM_NCCALCSIZE
    SWP_NOACTIVATE = &H10
    SWP_NOCOPYBITS = &H100
    SWP_NOMOVE = &H2
    SWP_NOOWNERZORDER = &H200 ' Don't do owner Z ordering
    SWP_NOREDRAW = &H8
    SWP_NOREPOSITION = SWP_NOOWNERZORDER
    SWP_NOSIZE = &H1
    SWP_NOZORDER = &H4
    SWP_DRAWFRAME = SWP_FRAMECHANGED
    HWND_NOTOPMOST = -2
End Enum

Private Declare Function GetWindowRect Lib "user32" ( _
      ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Private Function ShowTitleBar(ByVal bState As Boolean)
Dim lStyle As Long
Dim tR As RECT

   ' Get the window's position:
   GetWindowRect Application.hWndAccessApp, tR

   ' Modify whether title bar will be visible:
   lStyle = GetWindowLong(Application.hWndAccessApp, GWL_STYLE)

      Me.Tag = Me.Caption
      Me.Caption = ""
      lStyle = lStyle And Not WS_SYSMENU
      lStyle = lStyle And Not WS_MAXIMIZEBOX
      lStyle = lStyle And Not WS_MINIMIZEBOX
      
      'lStyle = lStyle And Not WS_CAPTION
   SetWindowLong Application.hWndAccessApp, GWL_STYLE, lStyle

   ' Ensure the style takes and make the window the
   ' same size, regardless that the title bar etc
   ' is now a different size:
   SetWindowPos Application.hWndAccessApp, _
       0, tR.Left, tR.Top, _
       tR.Right - tR.Left, tR.Bottom - tR.Top, _
       SWP_NOREPOSITION Or SWP_NOZORDER Or SWP_FRAMECHANGED

   Me.Refresh
End Function

Please do not feed the trolls.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top