MaudKip Posted October 25, 2007 Share Posted October 25, 2007 (edited) I need some assistance. How come when the 'X' button is pressed, it doesn't respond properly to the case select? I am pretty new to autoit, but I have never had this problem before. Thanks in advance. expandcollapse popup#include <GUIConstants.au3> Opt("GUIOnEventMode",1) Const $HTCAPTION = 2 Const $WM_NCLBUTTONDOWN = 0xA1 $gui = GuiCreate("Title",296,200,-1,-1,BitOR($WS_POPUP,$WS_BORDER,$WS_SIZEBOX)) GUISetBkColor(0xA6CAF0) GUISetOnEvent ($GUI_EVENT_CLOSE, "Quit" ) GUISetOnEvent ($GUI_EVENT_PRIMARYDOWN, "Drag" ) $Label1 = GUICtrlCreateLabel(" GUI", 0, 0, 250, 17) GUICtrlSetColor(-1, 0xA6CAF0) GUICtrlSetBkColor(-1, 0x004E98) $Button1 = GUICtrlCreateButton("X", 280, 0, 17, 17, $BS_FLAT) GUICtrlSetBkColor(-1, 0xA6CAF0) $Button2 = GUICtrlCreateButton(chr(2), 264, 0, 17, 17, $BS_FLAT) GUICtrlSetFont(-1, 7, 0, 0, "times new roman") GUICtrlSetBkColor(-1, 0xA6CAF0) $Button3 = GUICtrlCreateButton("_", 248, 0, 17, 17, $BS_FLAT) GUICtrlSetFont(-1, 7, 0, 0, "times new roman") GUICtrlSetBkColor(-1, 0xA6CAF0) $Icon1 = GUICtrlCreateIcon(@windowsdir & "\cursors\horse.ani", 0, 1, 1, 15, 15, BitOR($SS_NOTIFY,$WS_GROUP)) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg=$Button1 Exit EndSelect Sleep(10) WEnd Func Drag() dllcall("user32.dll","int","SendMessage","hWnd", $gui,"int",$WM_NCLBUTTONDOWN,"int", $HTCAPTION,"int", 0) EndFunc Func Quit() Exit EndFunc Edited October 25, 2007 by MaudKip Link to comment Share on other sites More sharing options...
inferno123 Posted October 25, 2007 Share Posted October 25, 2007 Opt("GUIOnEventMode",0) will make the x button work again Link to comment Share on other sites More sharing options...
Siao Posted October 25, 2007 Share Posted October 25, 2007 GUIGetMsg doesn't work with OnEvent mode. Pick one. "be smart, drink your wine" Link to comment Share on other sites More sharing options...
MaudKip Posted October 25, 2007 Author Share Posted October 25, 2007 (edited) Opt("GUIOnEventMode",0) will make the x button work againThank you so much inferno. That did the trick =] EDIT: Apparently I spoke too soon. Is it possible to have the drag feature and working buttons? EDIT:EDIT: Lol, nevermind. $Button1 = GUICtrlCreateButton("X", 280, 0, 17, 17, $BS_FLAT) GUIctrlSetOnEvent($GUI_EVENT_PRIMARYDOWN, "Quit") Edited October 25, 2007 by MaudKip Link to comment Share on other sites More sharing options...
MaudKip Posted October 25, 2007 Author Share Posted October 25, 2007 Ok, I have a new problem. I got the minimize button to work, however, if you press the minimize button then restore the window by clicking it in the taskbar, then click the label at the top of the screen it minimizes the window. How can this be rectified? Here is the edited code: expandcollapse popup#include <GUIConstants.au3> Opt("GUIOnEventMode",1) Const $HTCAPTION = 2 Const $WM_NCLBUTTONDOWN = 0xA1 $gui = GuiCreate("Title",296,200,-1,-1,BitOR($WS_POPUP,$WS_BORDER,$WS_SIZEBOX)) GUISetBkColor(0xA6CAF0) GUISetOnEvent ($GUI_EVENT_CLOSE, "Quit" ) GUISetOnEvent ($GUI_EVENT_PRIMARYDOWN, "Drag" ) $Label1 = GUICtrlCreateLabel(" GUI", 0, 0, 250, 17) GUIctrlSetOnEvent($GUI_EVENT_PRIMARYDOWN, "titleBar") GUICtrlSetColor(-1, 0xA6CAF0) GUICtrlSetBkColor(-1, 0x004E98) $Button1 = GUICtrlCreateButton("X", 280, 0, 17, 17, $BS_FLAT) GUIctrlSetOnEvent($GUI_EVENT_PRIMARYDOWN, "Quit") GUICtrlSetBkColor(-1, 0xA6CAF0) $Button2 = GUICtrlCreateButton(chr(2), 264, 0, 17, 17, $BS_FLAT) GUICtrlSetFont(-1, 7, 0, 0, "times new roman") GUICtrlSetBkColor(-1, 0xA6CAF0) $Button3 = GUICtrlCreateButton("_", 248, 0, 17, 17, $GUI_FOCUS) GUIctrlSetOnEvent($GUI_EVENT_PRIMARYDOWN, "Min") GUICtrlSetFont(-1, 7, 0, 0, "times new roman") GUICtrlSetBkColor(-1, 0xA6CAF0) $Icon1 = GUICtrlCreateIcon(@windowsdir & "\cursors\horse.ani", 0, 1, 1, 15, 15, BitOR($SS_NOTIFY,$WS_GROUP)) GUIctrlSetOnEvent($GUI_EVENT_PRIMARYDOWN, "null") GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd Func Drag() dllcall("user32.dll","int","SendMessage","hWnd", $gui,"int",$WM_NCLBUTTONDOWN,"int", $HTCAPTION,"int", 0) EndFunc Func Min() GUISetState(@SW_MINIMIZE ) EndFunc Func null() EndFunc Func titleBar() EndFunc Func Quit() Exit EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now