Results 1 to 4 of 4

Thread: Menus & Control Boxes

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Isle of Man
    Posts
    276
    I want to prevent users of my app from closing the form and from having it in an unmaximised state.

    i've successfully ghosted out the close and min/max button, but there is still the option to restore on the top left menu. selecting restore from this makes my form into a window. because i have disabled the max button, the form can't be maximised again

    is there any way I can turn off themenu at the top left completley, because I don't want to be maximising the form in code whenever the form resize event is fired

  2. #2
    Guest
    Try this:
    Code:
    Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
    Private Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpString As Any) As Long
    Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
    Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
    
    Const MF_STRING = &H0
    Const MF_GRAYED = &H1
    
    Private Sub Form_Load()
    
        Me.WindowState = 2
        Dim hMenu As Long, hID As Long, hSubMenu As Long
        
        'Get the SystemMenu handle
        hMenu = GetSystemMenu(Me.hwnd, 0)
        'Get the ID and Handle for the Restore Item
        hID = GetMenuItemID(hMenu, 0)
        hSubMenu = GetSubMenu(hMenu, 0)
        'Disable it
        ModifyMenu hMenu, hID, MF_GRAYED, hSubMenu, "Restore"
        
    End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Isle of Man
    Posts
    276
    thanks very much for that, it was a great help - worked first time, too

  4. #4
    Guest
    No problem. Since the above example disables the system command for maximizing, you do not need to disable the Max button. Even if the user were to press it, nothing would happen.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width