Sign in to follow this  
Followers 0
daveed

GUICreate with no icon menu

16 posts in this topic

#1 ·  Posted (edited)

Hallow,

How do you create a popup gui with only a close button in the title bar and no left icon and menu.

i tryed BitOr($WS_CAPTION, $WS_SYSMENU+$WS_EX_TOOLWINDOW) and

BitOr($WS_CAPTION, $WS_EX_TOOLWINDOW)

Edited by daveed

Share this post


Link to post
Share on other sites



I think $WS_EX_TOOLWINDOW is what you are looking for, but i think you are doin it wrong muttley

GuiCreate("Title", 200, 100, -1, -1, Default, $WS_EX_TOOLWINDOW)

Share this post


Link to post
Share on other sites

$WS_* is a normal window style constand

$WS_EX_* is an extended window style constant... You'll notice they are in different places in GUI Create.

GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] )

To combine use BitOR (), and if you only need to set an extended style, and not a normal one, use -1 or default, as Paulie showed in his code.

Cheers,

Brett

muttley

Share this post


Link to post
Share on other sites

Thanks guys!

For the help ive got a bit of a better understanding now.

Cheers!

Share this post


Link to post
Share on other sites

Is it possible to create a window similar to the $WS_EX_TOOLWINDOW (no icon menu, no minimize/maximize, with close button), but with the normal titlebar height? $WS_EX_TOOLWINDOW has the narrower titlebar.

Share this post


Link to post
Share on other sites

wraithdu

Good, but how disable the system menu? :P

Share this post


Link to post
Share on other sites

As far as I know you must have the $WM_SYSMENU style in order to have the X (close) button, so you're stuck with it unless you go the $WS_EX_TOOLWINDOW route.

Share this post


Link to post
Share on other sites

I found a few ways to do it actually, but this seems like the best -

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

$hwnd = GUICreate("", 200, 100, -1, -1, BitOR($WS_CAPTION, $WS_POPUPWINDOW))
GUISetIcon(@AutoItExe, -2)

GUIRegisterMsg($WM_NCLBUTTONDOWN, "MY_HITTEST")
GUIRegisterMsg($WM_NCRBUTTONDOWN, "MY_HITTEST")

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Func MY_HITTEST($hWnd, $Msg, $wParam, $lParam)
    Switch $wParam
        Case $HTSYSMENU
            Return 1
        Case $HTCAPTION
            Switch $Msg
                Case $WM_NCRBUTTONDOWN
                    Return 1
            EndSwitch
    EndSwitch
EndFunc

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

wraithdu

He he... Nice! But the system menu area not draggable :(

Another method:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

$hwnd = GUICreate("Test GUI", 200, 100, -1, -1, BitOR($WS_CAPTION, $WS_POPUPWINDOW))
GUISetIcon(@AutoItExe, -2)

GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Func WM_NCHITTEST($hWnd, $Msg, $wParam, $lParam)
    Local $iProc = DllCall("user32.dll", "int", "DefWindowProc", "hwnd", $hWnd, "int", $Msg, "wparam", $wParam, "lparam", $lParam)
    If $iProc[0] = $HTSYSMENU Then Return $HTCAPTION
EndFunc

:P

Edited by rasim

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Heh, guess you didn't test that bit of code? WM_NCHITTEST was the first message I tried, but it's only sent for client coords, not when clicking in the titlebar, sysmenu, min / max / close buttons, etc. Oh, and the sysmenu area isn't draggable under normal circumstances anyway. Bear in mind all my testing is on Vista (just in case XP is different.)

I used Spy++ to catch all the messages. Most of ones that we can capture and block are the two I used above, and WM_SYSCOMMAND. BUT, there's a discrepancy with WM_SYSCOMMAND. MSDN says that the wParam of a WM_SYSCOMMAND message should be SC_MOUSEMENU when the mouse invokes the sysmenu, and that value is 0xF090. Spy++ shows the message as WM_SYSCOMMAND with a uCmd (don't know what that means) value of SC_MOUSEMENU, but when I look deeper, the wParam is 0xF093. That doesn't make sense. Maybe the message value was changed on vista? I don't know, but try this -

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiMenu.au3>; for $SC_MOUSEMENU constant

$hwnd = GUICreate("", 200, 100, -1, -1, BitOR($WS_CAPTION, $WS_POPUPWINDOW))
GUISetIcon(@AutoItExe, -2)

GUIRegisterMsg($WM_SYSCOMMAND, "MY_HITTEST")
GUIRegisterMsg($WM_NCRBUTTONDOWN, "MY_HITTEST")

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Func MY_HITTEST($hWnd, $Msg, $wParam, $lParam)
    Switch $Msg
        Case $WM_SYSCOMMAND
            Switch $wParam
                Case $SC_MOUSEMENU
                    ConsoleWrite("SC_MOUSEMENU : " & $wParam & @CRLF)
                    Return _WinAPI_DefWindowProc($hWnd, $WM_NCLBUTTONDOWN, $HTCAPTION, $lParam)
                Case 0xF093
                    ConsoleWrite("Unknown : " & $wParam & @CRLF)
                    Return _WinAPI_DefWindowProc($hWnd, $WM_NCLBUTTONDOWN, $HTCAPTION, $lParam)
            EndSwitch
        Case $WM_NCRBUTTONDOWN
            Switch $wParam
                Case $HTCAPTION
                    Return 1
            EndSwitch
    EndSwitch
EndFunc
Edited by wraithdu

Share this post


Link to post
Share on other sites

PS - board doesn't seem to like <autoit></autoit> tags right now....

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

wraithdu

WM_NCHITTEST was the first message I tried, but it's only sent for client coords, not when clicking in the titlebar, sysmenu, min / max / close buttons, etc.

What? :P You read this? I think that the WM_NCHITTEST is sent to a Non Client area.

wraithdu

all my testing is on Vista

I don't have the Vista. :(

P.S.

My example don't work under Vista?

Edited by rasim

Share this post


Link to post
Share on other sites

Hmm, I guess I misinterpreted my previous results a bit. Ok, so WM_NCHITTEST is in fact sent from the caption bar. But at least under Vista I never get the HTSYSMENU message. I only get HTCAPTION and HTCLIENT. So yes, your example fails on Vista. Too bad Microsoft can't keep basic things consistent between OS's.

Share this post


Link to post
Share on other sites

wraithdu

OK :P

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