Jump to content

Button Not Responding


MaudKip
 Share

Recommended Posts

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.

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

Opt("GUIOnEventMode",0) will make the x button work again

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

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:

#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

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...