Jump to content

GUICreate with no icon menu


daveed
 Share

Recommended Posts

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
Link to comment
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

Link to comment
Share on other sites

  • 2 months later...

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...