AppTux Posted November 12, 2009 Share Posted November 12, 2009 I have a GUI with a close and a minimize button. In a other topic had i see a way to do it. I want to press the minimize or closebutton, and if you go up with your mouse button then goes it do something. I have that code something modified, but it doesn't work expandcollapse popup#include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <File.au3> #Include <GUICtrlSetOnHover.au3> #Include <Icons.au3> Global $Back,$theme[6],$Hold = False _FileReadToArray("Resources\Theme.ini",$theme) $GUI1 = GUICreate("Example", 450,300,-1,-1,$WS_POPUP) GUISetBkColor(0xd8d8d8) $Back = GUICtrlCreatePic($theme[2],0,0,450,300) GUICtrlSetState(-1,$GUI_DISABLE) $min = GUICtrlCreatePic($theme[3],375,0,25,18) $close = GUICtrlCreatePic($theme[5],400,0,50,18) For $i = $min To $close _Leave($i) Next GUISetState() Do $msg = GUIGetMsg() $cursor = GUIGetCursorInfo($GUI1) Until $msg = -3 Func _Down($CtrlID) If $Hold Then Return Else $Hold = True EndIf Local $File Switch $CtrlID Case $min $File = 'min-press.bmp' Case $close $File = 'close-press.bmp' EndSwitch _SetImage($CtrlID, @ScriptDir & '\Resources\' & $File, $Back) EndFunc ;==>_Down Func _Leave($CtrlID) Local $File Switch $CtrlID Case $min $File = 'min.bmp' Case $close $File = 'close.bmp' EndSwitch _SetImage($CtrlID, @ScriptDir & '\Resources\' & $File, $Back) $Hold = False EndFunc ;==>_Leave Func _Hover($CtrlID) Local $File Switch $CtrlID Case $min $File = 'min-hover.bmp' Case $close $File = 'close-hover.bmp' EndSwitch _SetImage($CtrlID, @ScriptDir & '\Resources\' & $File, $Back) $Hold = False EndFunc ;==>_Hover Func _Up($CtrlID) _Hover($CtrlID) EndFunc ;==>_Up Can you see what te problem is with this code?? plz help me. PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore. Link to comment Share on other sites More sharing options...
GodlessSinner Posted November 12, 2009 Share Posted November 12, 2009 (edited) expandcollapse popup#include <GUICtrlSetOnHover_UDF.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $pressed = 0 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 625, 165, 273, 569) $Button1 = GUICtrlCreateButton("Minimize", 480, 16, 137, 33, $WS_GROUP) _GUICtrl_SetOnHover(-1, "_Hover_Proc", "_Leave_Hover_Proc", "PrimaryDown_Proc", "PrimaryUp_Proc") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _Hover_Proc($iCtrlID) Switch $iCtrlID Case $Button1 GUICtrlSetFont($Button1, 8, 800, 0, "MS Sans Serif") $pressed = 1 EndSwitch EndFunc Func _Leave_Hover_Proc($iCtrlID) Switch $iCtrlID Case $Button1 GUICtrlSetFont($Button1, 8, 400, 0, "MS Sans Serif") $pressed = 2 EndSwitch EndFunc Func PrimaryDown_Proc($iCtrlID) Switch $iCtrlID Case $Button1 If $pressed = 1 Then GUICtrlSetFont($Button1, 12, 400, 0, "MS Sans Serif") $pressed = 2 EndIf EndSwitch EndFunc Func PrimaryUp_Proc($iCtrlID) Switch $iCtrlID Case $Button1 If $pressed = 2 Then GUICtrlSetFont($Button1, 8, 800, 0, "MS Sans Serif") $pressed = 1 WinSetState($Form1, "", @SW_MINIMIZE) EndIf EndSwitch EndFunc Edited November 12, 2009 by Godless _____________________________________________________________________________ Link to comment Share on other sites More sharing options...
AppTux Posted November 14, 2009 Author Share Posted November 14, 2009 expandcollapse popup#include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <File.au3> #Include <GUICtrlSetOnHover.au3> #Include <Icons.au3> Global $pressed = 0,$theme[6] _FileReadToArray("Resources\Theme.ini",$theme) $GUI1 = GUICreate("Xtreme Run", 450,300,-1,-1,$WS_POPUP) GUISetBkColor(0xd8d8d8) GUICtrlCreatePic($theme[2],0,0,450,300) GUICtrlSetState(-1,$GUI_DISABLE) $min = GUICtrlCreatePic($theme[3],375,0,25,18) _GUICtrl_SetOnHover(-1, "_Hover_Proc", "_Leave_Hover_Proc", "PrimaryDown_Proc", "PrimaryUp_Proc") $close = GUICtrlCreatePic($theme[5],400,0,50,18) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _Hover_Proc($iCtrlID) Switch $iCtrlID Case $min GUICtrlDelete($min) $min = GUICtrlCreatePic("Resources\min-hover.bmp",375,0,25,18) GUICtrlSetState(-1,$GUI_SHOW) $pressed = 1 EndSwitch EndFunc Func _Leave_Hover_Proc($iCtrlID) Switch $iCtrlID Case $min GUICtrlDelete($min) $min = GUICtrlCreatePic("Resources\min.bmp",375,0,25,18) GUICtrlSetState(-1,$GUI_SHOW) $pressed = 2 EndSwitch EndFunc Func PrimaryDown_Proc($iCtrlID) Switch $iCtrlID Case $min If $pressed = 1 Then GUICtrlDelete($min) GUICtrlCreatePic("Resources\min-press.bmp",375,0,25,18) GUICtrlSetState(-1,$GUI_SHOW) $pressed = 2 EndIf EndSwitch EndFunc Func PrimaryUp_Proc($iCtrlID) Switch $iCtrlID Case $min If $pressed = 2 Then GUICtrlDelete($min) $pressed = 1 WinSetState($GUI1, "", @SW_MINIMIZE) $min = GUICtrlCreatePic("Resources\min.bmp",375,0,25,18) GUICtrlSetState(-1,$GUI_SHOW) EndIf EndSwitch EndFunc Only the mouseover action works. the image wouldn't change when I leave the button. PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore. Link to comment Share on other sites More sharing options...
AppTux Posted November 17, 2009 Author Share Posted November 17, 2009 I had update the code a bit. maybe can you see the problem. The new problem (not a very big) is a bit smaller. the image change when i go over the image, but the normal also. it's flashing. but if i leave the button, the images flashes not on. (own problem resolved) expandcollapse popup#include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <File.au3> #Include <GUICtrlSetOnHover.au3> #Include <Icons.au3> Global $pressed = 0,$theme[6] _FileReadToArray("Resources\Theme.ini",$theme) $GUI1 = GUICreate("Xtreme Run", 450,300,-1,-1,$WS_POPUP) GUISetBkColor(0xd8d8d8) GUICtrlCreatePic($theme[2],0,0,450,300) GUICtrlSetState(-1,$GUI_DISABLE) $min = GUICtrlCreatePic($theme[3],375,0,25,18) _GUICtrl_SetOnHover(-1, "_Hover_Proc", "_Leave_Hover_Proc", "PrimaryDown_Proc", "PrimaryUp_Proc") $min2 = GUICtrlCreatePic("Resources\min-hover.bmp",375,0,25,18) $min3 = GUICtrlCreatePic("Resources\min-press.bmp",375,0,25,18) $close = GUICtrlCreatePic($theme[5],400,0,50,18) GUICtrlSetState($min,$GUI_SHOW) GUICtrlSetState($min2,$GUI_HIDE) GUICtrlSetState($min3,$GUI_HIDE) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _Hover_Proc($iCtrlID) Switch $iCtrlID Case $min GUICtrlSetState($min,$GUI_HIDE) GUICtrlSetState($min3,$GUI_HIDE) GUICtrlSetState($min2,$GUI_SHOW) $pressed = 1 EndSwitch EndFunc Func _Leave_Hover_Proc($iCtrlID) Switch $iCtrlID Case $min GUICtrlSetState($min,$GUI_SHOW) GUICtrlSetState($min2,$GUI_HIDE) GUICtrlSetState($min3,$GUI_HIDE) $pressed = 2 EndSwitch EndFunc Func PrimaryDown_Proc($iCtrlID) Switch $iCtrlID Case $min If $pressed = 1 Then GUICtrlSetState($min,$GUI_HIDE) GUICtrlSetState($min2,$GUI_HIDE) GUICtrlSetState($min3,$GUI_SHOW) $pressed = 2 EndIf EndSwitch EndFunc Func PrimaryUp_Proc($iCtrlID) Switch $iCtrlID Case $min If $pressed = 2 Then GUICtrlSetState($min,$GUI_SHOW) GUICtrlSetState($min2,$GUI_HIDE) GUICtrlSetState($min3,$GUI_HIDE) $pressed = 1 WinSetState($GUI1, "", @SW_MINIMIZE) EndIf EndSwitch EndFunc All of the things i need are in the file. (or what you need) maybe it can help troubleshooting PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore. Link to comment Share on other sites More sharing options...
AppTux Posted November 17, 2009 Author Share Posted November 17, 2009 sorry, the uploading doesn't work PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore. Link to comment Share on other sites More sharing options...
PartyPooper Posted November 17, 2009 Share Posted November 17, 2009 If all you want to do is trigger events based on whether or not the close or minimise buttons have been pressed, have you thought about using: GUISetOnEvent($GUI_EVENT_CLOSE, "Function") GUISetOnEvent($GUI_EVENT_MINIMIZE, "Function") Link to comment Share on other sites More sharing options...
AppTux Posted November 17, 2009 Author Share Posted November 17, 2009 I understand that not really, but that is not where i was looking for but thanks for your fast reply PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore. 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