topten Posted July 30, 2015 Share Posted July 30, 2015 I create a picture as a button$historyon = GUICtrlCreatePic("off.jpg", 280, 500, 30, 30) GUICtrlSetState(-1, $GUI_DISABLE) $ButtonNext = GUICtrlCreateLabel("", 280, 500, 30, 30) GUICtrlSetCursor(-1, 0) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetState(-1, $GUI_ENABLE) _GUICtrl_OnHoverRegister(-1, "_Hover_Proc", "_Leave_Hover_Proc", "PrimaryDown_Proc")From the innitiate state the button on the gui is in "off" position. When the button is pressed the picture should be changed to "on" positionLater on I register the function for the button when it is pressedFunc PrimaryDown_Proc($historyon) local $buttonon, $buttonoff Switch $historyon Case $ButtonNext if $historyswitchedon=0 then $buttonon = GUICtrlCreatePic("on.jpg", 280, 500, 30, 30) GUICtrlDelete ($buttonoff) ;MsgBox (0, "", "0") GUISetState() $historyswitchedon=1 Return EndIf if $historyswitchedon=1 then $buttonoff = GUICtrlCreatePic("off.jpg", 280, 500, 30, 30) GUICtrlDelete ($buttonon) ;MsgBox (0, "", "1") GUISetState() $historyswitchedon=0 Return EndIf EndSwitch EndFuncBut I am getting not stable result: Sometimes, the picture of button is changed directly when I press on it, sometimes it is not changed, sometimes it is keeping changing from position "on" to position "off" while the button is being pressed several times. What am I doing wrong? Link to comment Share on other sites More sharing options...
BrewManNH Posted July 30, 2015 Share Posted July 30, 2015 Don't keep recreating the button, just use GUICtrlSetImage to change from one image to the other.Also, if you need more help, please post a runnable script. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
topten Posted July 30, 2015 Author Share Posted July 30, 2015 @BrewManNHI tried GUICTRLSETIMAGE but it seems not to work thereI guess I should have posted the question in this brunch Link to comment Share on other sites More sharing options...
Yashied Posted July 30, 2015 Share Posted July 30, 2015 Try Skin UDF from my sig. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... 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