Sign in to follow this  
Followers 0
adamski

Prevent menu on GUI title bar?

5 posts in this topic

Hello,

How can I prevent the right click menu from displaying when the GUI title bar, icon, minimise and maximise/restore buttons are right clicked? Nothing happens when you right click the close button, and that is what I am after for the rest of the title bar.

Thanks.

Share this post


Link to post
Share on other sites



#Include <WindowsConstants.au3>
#Include <GUIConstantsEx.au3>

Global Const $SC_KEYMENU = 0xF100

$hForm = GUICreate('MyGUI')

GUIRegisterMsg($WM_NCLBUTTONDBLCLK, 'WM_NCLBUTTONDBLCLK')
GUIRegisterMsg($WM_NCLBUTTONDOWN, 'WM_NCLBUTTONDOWN')
GUIRegisterMsg($WM_NCRBUTTONDOWN, 'WM_NCRBUTTONDOWN')
GUIRegisterMsg($WM_SYSCOMMAND, 'WM_SYSCOMMAND')

GUISetState()

Do
Until GUIGetMsg() = -3

Func WM_NCLBUTTONDBLCLK($hWnd, $iMsg, $wParam, $lParam)
    Switch $wParam
        Case 0x03
            Return 0
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NCLBUTTONDBLCLK

Func WM_NCLBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    Switch $wParam
        Case 0x03
            Return 0
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NCLBUTTONDOWN

Func WM_NCRBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    Switch $wParam
        Case 0x02, 0x03
            Return 0
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NCRBUTTONDOWN

Func WM_SYSCOMMAND($hWnd, $iMsg, $wParam, $lParam)
    Switch $wParam
        Case $SC_KEYMENU
            Return 0
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SYSCOMMAND

Share this post


Link to post
Share on other sites

Thanks Yashied,

The menu still appears when right clicking the max/minimise buttons, but many thanks.

Share this post


Link to post
Share on other sites

Thanks Yashied,

The menu still appears when right clicking the max/minimise buttons, but many thanks.

#Include <WindowsConstants.au3>
#Include <GUIConstantsEx.au3>

Global Const $SC_KEYMENU = 0xF100

$hForm = GUICreate('MyGUI')

GUIRegisterMsg($WM_NCLBUTTONDBLCLK, 'WM_NCLBUTTONDBLCLK')
GUIRegisterMsg($WM_NCLBUTTONDOWN, 'WM_NCLBUTTONDOWN')
GUIRegisterMsg($WM_NCRBUTTONDOWN, 'WM_NCRBUTTONDOWN')
GUIRegisterMsg($WM_SYSCOMMAND, 'WM_SYSCOMMAND')

GUISetState()

Do
Until GUIGetMsg() = -3

Func WM_NCLBUTTONDBLCLK($hWnd, $iMsg, $wParam, $lParam)
    Switch $wParam
        Case 0x03
            Return 0
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NCLBUTTONDBLCLK

Func WM_NCLBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    Switch $wParam
        Case 0x03
            Return 0
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NCLBUTTONDOWN

Func WM_NCRBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    Switch $wParam
        Case 0x02, 0x03, 0x08, 0x09, 0x14, 0x15
            Return 0
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NCRBUTTONDOWN

Func WM_SYSCOMMAND($hWnd, $iMsg, $wParam, $lParam)
    Switch $wParam
        Case $SC_KEYMENU
            Return 0
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SYSCOMMAND

Share this post


Link to post
Share on other sites

GUIRegisterMsg($WM_NCLBUTTONDBLCLK, 'WM_NCLBUTTONDBLCLK')

GUIRegisterMsg($WM_NCLBUTTONDOWN, 'WM_NCLBUTTONDOWN')

GUIRegisterMsg($WM_NCRBUTTONDOWN, 'WM_NCRBUTTONDOWN')

GUIRegisterMsg($WM_SYSCOMMAND, 'WM_SYSCOMMAND')

Thanks again!

Do I need WM_NCLBUTTONDBLCLK, WM_NCLBUTTONDOWN and WM_SYSCOMMAND? It appears to work OK when I comment these out.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0