Jump to content
Sign in to follow this  
Madza91

Gui Titlebar Right click - Context menu disable?!

Recommended Posts

Madza91

Hello... Is possible to disable Context menu on GUI's TitleBar?

I need to disable Context Menu on GUI's Titlebar, but I need X button on GUI too...

Is there some style for GUI, or some way to disable Right click on Titlebar?

Here is little demo script:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("With Context Menu", 250, 400, 100, -1, -1, $WS_EX_TOOLWINDOW)
GUISetState(@SW_SHOW)

$hGUI2 = GUICreate("Without Context Menu (but without X (exit button) too", 320, 400, 360, -1, $WS_CAPTION, $WS_EX_TOOLWINDOW)
GUISetState(@SW_SHOW)

While 1
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
WEnd

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Share this post


Link to post
Share on other sites
Madza91

I found solution:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("With Context Menu", 250, 400, 100, -1, -1, $WS_EX_TOOLWINDOW)
GUISetState(@SW_SHOW)
GUIRegisterMsg(0x00A4, "aaa")

While 1
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
WEnd

Func aaa()
    Return 0
EndFunc

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Share this post


Link to post
Share on other sites
Zedna

#include <GUIConstantsEx.au3>#include <WindowsConstants.au3>
#include <GUIMenu.au3>

$hGUI = GUICreate("With Context Menu", 250, 400, 100, -1, -1, $WS_EX_TOOLWINDOW)
GUISetState(@SW_SHOW)

$hGUI2 = GUICreate("Without Context Menu (but without X (exit button) too", 320, 400, 360, -1, $WS_CAPTION, $WS_EX_TOOLWINDOW)
GUISetState(@SW_SHOW)

$hMenu = _GUICtrlMenu_GetSystemMenu($hGui2)
_GUICtrlMenu_DestroyMenu($hMenu)

While 1
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
WEnd

Edited by Zedna

Share this post


Link to post
Share on other sites
Madza91

Nice solution too, thx ^_^


[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Share this post


Link to post
Share on other sites
Madza91

Hehe ^_^

I solved that too:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global Const $SC_MOVE = 0xF010;
Global Const $SC_MOVE2 = 0x0F012;
Global Const $SC_CLOSE = 0xF060;
Global Const $SC_CLOSE2 = 0xF063;
Global Const $SC_MENU = 0xF093;
Global Const $SC_KEYMENU = 0xF100;
Global Const $SC_MOUSEMENU = 0xF090;

$hGUI = GUICreate("With Context Menu", 250, 400, 100, -1, -1, $WS_EX_TOOLWINDOW)
GUISetState(@SW_SHOW)
GUIRegisterMsg(0x00A4, "aaa")
GUIRegisterMsg($WM_SYSCOMMAND,"WM_SYSCOMMAND")

While 1
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
WEnd

Func aaa()
    Return 0
EndFunc

Func WM_SYSCOMMAND($hWndGUI, $MsgID, $wParam, $lParam)
    Switch $wParam
        Case $SC_MOVE, $SC_MOVE2
            If $hWndGUI = $hGUI Then Return 0
        Case $SC_CLOSE, $SC_CLOSE2
            Exit
        Case $SC_MENU, $SC_MOUSEMENU, $SC_KEYMENU
            Return 0
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Share this post


Link to post
Share on other sites
GEOSoft

Or this function (created from rovers code)

$hGUI = _GUI_NoIcon("With Context Menu", 250, 400)

Func _GUI_NoIcon($sTitle, $iWidth = -1, $iHeight = -1, $iXpos = -1, $iYpos = -1)
   Local $GCL_HICONSM = -34, $GCL_HICON = -14
   Local $hWnd = GUICreate($sTitle, $iWidth, $iHeight, $iXpos, $iYpos, _
         BitOR($WS_CAPTION, $WS_SYSMENU), $WS_EX_DLGMODALFRAME)
   Local $hIcon = GetClassLong($hWnd, $GCL_HICON)
   DllCall("User32.dll", "int", "DestroyIcon", "hwnd", $hIcon)
   SetClassLong($hWnd, $GCL_HICON, 0)
   SetClassLong($hWnd, $GCL_HICONSM, 0)
   Return $hWnd
EndFunc  ;<==> _GUI_NoIcon()

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.