Results 1 to 12 of 12

Thread: Hiding the SysMenu

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    80

    Angry

    How do I hide the SysMenu on an MDI child form? I'm pulling my hair out on this one and am having no luck.

    Thanks...

  2. #2
    Lively Member AndySoft's Avatar
    Join Date
    Oct 2000
    Location
    Massillon, OH
    Posts
    68
    Turn off the Control Box...
    -AndySoft
    [email protected]
    [email protected] (Use the other one first!)

    I use: NASM, HTML, Perl, PHP, JavaScript, Batch, TI-Basic (TI-83+), QBasic 1.1, QuickBASIC 4.5, QuickBASIC Extended 7.1, VB-WIN 6 Ent., and the rest of Visual Studio 6 Ent. And who knows what else!

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    80

    Unhappy

    *Sigh* If only it were that easy...

    I need to keep on the minimizing, maximizing, and closing option on the form. I just have no need for the sysmenu with the icon....

    Anyone else? Please? :-)

  4. #4
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628
    Change the border style? If you change it to "sizable toolwindow" you will still have the close box but lose everything else. they will be able to resize the window still with border dragging.
    Last edited by Lord Orwell; Mar 12th, 2001 at 05:57 AM.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  5. #5
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628
    If you want to keep the 3 buttons and lose the context menu altogether, the attached file contains all the info you need to do that.
    Attached Files Attached Files
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  6. #6
    Guest
    You can easily do it via subclassing.

    Add to a Module
    Code:
    Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
    Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Const GWL_WNDPROC = (-4)
    Private Const WM_NCHITTEST = &H84
    Private Const HTSYSMENU = 3
    Private Const WM_NCLBUTTONDOWN = &HA1
    
    Global WndProcOld As Long
    
    Public Function WindProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    
        If wMsg = WM_NCLBUTTONDOWN And wParam = HTSYSMENU Then
            Exit Function
        End If
      
        WindProc = CallWindowProc(WndProcOld&, hwnd&, wMsg&, wParam&, lParam&)
        
    End Function
    
    Sub SubClassWnd(hwnd As Long)
        WndProcOld& = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindProc)
    End Sub
    
    Sub UnSubclassWnd(hwnd As Long)
        SetWindowLong hwnd, GWL_WNDPROC, WndProcOld&
        WndProcOld& = 0
    End Sub
    Add to your Form
    Code:
    Private Sub Form_Load()
        SubClassWnd hwnd
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        UnSubclassWnd hwnd
    End Sub

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    80
    Megatron -- Thanks for the code. It works, but in this case I want to hide the SysMenu icon as well as disable it. I will definetely use that code in the future.

    Lord Orwell -- Thanks for that attachment. My question is, and this is an "API Newbie" one (hey, gotta start somewhere...):

    How am I able to turn off the sysmenu with that?

    Do I just try something like:
    SetWindowLong(hwnd,WS_SYSMENU,0)?
    I see that the sysmenu property is 80000 to use it. So what is its value to not use it? I am unfamiliar with these api's, and reading my Appleman API book fails to clear up my confusion.

    I must be making this more difficult than it is.....

    Thanks...

  8. #8
    Guest
    Yes, that will work, but it's just the same as disabling the the ControlBox property.

    Just incase your interested, here's the code
    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_SYSMENU = &H80000
    
    Private Sub Form_Load()
        Dim wStyle As Long
        wStyle = GetWindowLong(hwnd, GWL_STYLE)
        wStyle = wStyle Xor WS_SYSMENU
        SetWindowLong hwnd, GWL_STYLE, wStyle
    End Sub

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    80
    Hmmm... so basically I can either a) disable the whole control box or disable the sysMenu when it pops up but still show the icon? But I can't "hide" that icon and the menu?

    How do programs like Word, FileMaker, even Windows clock do it? They still have the "X" at the top right and they do not have a sysMenu....

    And thanks for the example Megatron... that helps my understanding of how to use the API....

  10. #10
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628
    Originally posted by Lord Orwell
    Change the border style? If you change it to "sizable toolwindow" you will still have the close box but lose everything else. they will be able to resize the window still with border dragging.

    And the clock does still have the context menu. Right-click on the title bar to activate it.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    80
    The problem with the toolwindow is that it is smaller than the normal window. Know what I mean? The caption at the top is smaller, which makes the windows look somewhat "weird" to some people....

    I'll resort to using that if I have to, but I just figured since I've seen programs not use the sysMenu, I figured there was a way...

  12. #12
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628
    I am afraid MEGATRON is right. It seems that the sysmenu has to be active for the controls to appear. Annoyingly, the reverse is not true.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

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