rdwray Posted March 6, 2012 Posted March 6, 2012 (edited) Why is this flickering? EDIT: Now it isn't flickering?????? expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiButton.au3> #include <StaticConstants.au3> #include <GuiEdit.au3> #include <Misc.au3> #include <GUIConstantsEx.au3> #Include <Date.au3> Opt("GUIOnEventMode", 1) Opt('MustDeclareVars', 1) Global $pos, $x, $y, $hDLL If FileExists(@ScriptDir & "PowerOpt.ini") Then $x = IniRead (@ScriptDir & "PowerOpt.ini", "Position", "x", 0) $y = IniRead (@ScriptDir & "PowerOpt.ini", "Position", "y", 0) Else SavePos() EndIf Main() Func Main() Local $hWnd, $hButC, $hButSD, $hButRS, $hButLO, $hButLP, $hButS, $hButH, $Msg, $Style Local $hBut, $hTxtOper, $hDate, $hTime, $fState Local $month[13] = ["0","Jan.","Feb.","Mar.","Apr.","May.","Jun.","Jul.","Aug.","Sep.","Oct.","Nov.","Dec."] Local $MOUSEEVENTF_LEFTUP = 0x0004 $hWnd = GUICreate("Power Opt", 172, 101, -1, -1, $WS_POPUP) GUISetOnEvent($GUI_EVENT_CLOSE, "SavePos") WinMove("Power Opt", "", $x, $y) GUICtrlCreatePic(@ScriptDir & "BG.bmp", 0, 0, 172, 101) GUICtrlSetState(-1, $GUI_DISABLE) GUISetFont(9, -1, -1, "Segoe UI Semibold") $hTxtOper = GUICtrlCreateLabel("Select an option...", 5, 5, 144, 20, $SS_CENTER, $GUI_WS_EX_PARENTDRAG) GUICtrlSetBkColor($hTxtOper, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor($hTxtOper, 0xFFFFFF) $x = 5 $hButC = GUICtrlCreateButton("",152, 5, 14, 14, $BS_BITMAP) GUICtrlSetImage($hButC,@ScriptDir & "Close.bmp") $hButSD = GUICtrlCreateButton("", $x, 25, 24, 24, $BS_BITMAP) GUICtrlSetImage($hButSD, @ScriptDir & "ShutdownUp.bmp") $hButRS = GUICtrlCreateButton("", $x + 27, 25, 24, 24, $BS_BITMAP) GUICtrlSetImage($hButRS, @ScriptDir & "RestartUp.bmp") $hButLO = GUICtrlCreateButton("", $x + 54, 25, 24, 24, $BS_BITMAP) GUICtrlSetImage($hButLO, @ScriptDir & "LogoffUp.bmp") $hButLP = GUICtrlCreateButton("", $x + 81, 25, 24, 24, $BS_BITMAP) GUICtrlSetImage($hButLP, @ScriptDir & "LockPCUp.bmp") $hButS = GUICtrlCreateButton("", $x + 108, 25, 24, 24, $BS_BITMAP) GUICtrlSetImage($hButS, @ScriptDir & "SuspendUp.bmp") $hButH = GUICtrlCreateButton("", $x + 135, 25, 24, 24, $BS_BITMAP) GUICtrlSetImage($hButH, @ScriptDir & "HibernateUp.bmp") GUICtrlSetDefColor(0xFFFFFF) $hDate = GUICtrlCreateLabel("", 5, 54, 164, 20, $SS_CENTER) GUICtrlSetBkColor($hDate, $GUI_BKCOLOR_TRANSPARENT) $hTime = GUICtrlCreateLabel("", 5, 74, 164, 20, $SS_CENTER) GUICtrlSetBkColor($hTime, $GUI_BKCOLOR_TRANSPARENT) GUISetState(@SW_SHOW) $fState = True $hDLL = DllOpen("user32.dll") Local $bCond, $msg While 1 GUICtrlSetData($hDate, $month[@MON] & " " & @MDAY & ", " & @YEAR) GUICtrlSetData($hTime, @HOUR & ":" & @MIN & ":" & @SEC) $hBut = GUIGetCursorInfo($hWnd) Switch $hBut[4] Case $hButC GUICtrlSetData($hTxtOper, "Close window?") Case $hButSD GUICtrlSetData($hTxtOper, "Shut down?") Case $hButRS GUICtrlSetData($hTxtOper, "Restart?") Case $hButLO GUICtrlSetData($hTxtOper, "Log off?") Case $hButLP GUICtrlSetData($hTxtOper, "Lock PC?") Case $hButS GUICtrlSetData($hTxtOper, "Suspend?") Case $hButH GUICtrlSetData($hTxtOper, "Hibernate?") Case Else GUICtrlSetData($hTxtOper, "Select an option...") EndSwitch Switch $hBut[4] Case $hButC If _IsPressed("01", $hDLL) Then SavePos() Exit EndIf Case $hButSD If _IsPressed("01", $hDLL) Then Shutdown(9) $bCond = $hButSD GUICtrlSetImage($hButSD, @ScriptDir & "ShutdownDn.bmp") EndIf Case $hButRS If _IsPressed("01", $hDLL) Then Shutdown(2) $bCond = $hButRS GUICtrlSetImage($hButRS, @ScriptDir & "Restart.bmp") EndIf Case $hButLO If _IsPressed("01", $hDLL) Then GUICtrlSetImage($hButLO, @ScriptDir & "LogOffDn.bmp") $bCond = $hButLO Shutdown(0) EndIf Case $hButS If _IsPressed("01", $hDLL) Then Shutdown(32) GUICtrlSetImage($hButS, @ScriptDir & "SuspendDn.bmp") EndIf Case $hButH If _IsPressed("01", $hDLL) Then Shutdown(64) GUICtrlSetImage($hButH, @ScriptDir & "HibernateDn.bmp") EndIf Case Else $bCond = 0 GUICtrlSetImage($hButSD, @ScriptDir & "ShutdownUp.bmp") GUICtrlSetImage($hButRS, @ScriptDir & "RestartUp.bmp") GUICtrlSetImage($hButLO, @ScriptDir & "LogOffUp.bmp") GUICtrlSetImage($hButLP, @ScriptDir & "LockPCUp.bmp") GUICtrlSetImage($hButS, @ScriptDir & "SuspendUp.bmp") GUICtrlSetImage($hButH, @ScriptDir & "HibernateUp.bmp") EndSwitch Sleep(10) WEnd EndFunc ;==>Main Func SavePos() DllClose($hDLL) $pos = WinGetPos("Power Opt") IniWrite (@ScriptDir & "PowerOpt.ini", "Position", "x", $pos[0]) IniWrite (@ScriptDir & "PowerOpt.ini", "Position", "y", $pos[1]) EndFunc Edited March 6, 2012 by rdwray “No other God have I but Thee; born in a manger, died on a tree.” Martin Luther
Moderators Melba23 Posted March 6, 2012 Moderators Posted March 6, 2012 rdwray, It will flicker becasuse you reset the label text on each pass - try something like this for each button: Case $hButC If GUICtrlRead($hTxtOper) <> "Close window?" Then GUICtrlSetData($hTxtOper, "Close window?") EndIf M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Reveal hidden contents ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
rdwray Posted March 6, 2012 Author Posted March 6, 2012 On 3/6/2012 at 12:03 PM, 'Melba23 said: rdwray, It will flicker becasuse you reset the label text on each pass - try something like this for each button: Case $hButC If GUICtrlRead($hTxtOper) <> "Close window?" Then GUICtrlSetData($hTxtOper, "Close window?") EndIf M23 Ok, this got the top label, but the issue remains in the date and time labels... “No other God have I but Thee; born in a manger, died on a tree.” Martin Luther
Moderators Melba23 Posted March 6, 2012 Moderators Posted March 6, 2012 rdwray, The principle is exactly the same - check that what you are going to write is different from what is already written. I am sure you can do that yourself. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Reveal hidden contents ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
rdwray Posted March 6, 2012 Author Posted March 6, 2012 On 3/6/2012 at 12:19 PM, 'Melba23 said: rdwray,The principle is exactly the same - check that what you are going to write is different from what is already written. I am sure you can do that yourself. M23I know you are not going to believe this, but I made a mistake and it is working now - thanks M23 “No other God have I but Thee; born in a manger, died on a tree.” Martin Luther
rdwray Posted March 11, 2012 Author Posted March 11, 2012 On a follow up on flickering, I seem to be having a lot of problems with the following code which should be straight forward, but doesn't work because it will not hold a setting. #include <GUIConstantsEx.au3> #include <misc.au3> Local $hDLL = DllOpen("user32.dll") $hWnD = GUICreate("Button As Image") GUISetState(@SW_SHOW) ; GUISetState($hWnd, $GUI_DISABLE) Required for GUI background pic. $hPid = GUICtrlCreatePic(@ScriptDir & "ImagesMoveFirstUp.bmp", 40, 40, 20, 20) Main() Func Main() While 1 $hImg = GUIGetCursorInfo($hWnd) if $hImg[4] And _IsPressed("01", $hDLL) Then GUICtrlCreatePic(@ScriptDir & "ImagesMoveFirstDn.bmp", 40, 40, 20, 20) Else GUICtrlCreatePic(@ScriptDir & "ImagesMoveFirstUp.bmp", 40, 40, 20, 20) EndIf Switch GUIGetMsg(0) Case $GUI_EVENT_CLOSE Exit DllClose($hDLL) EndSwitch WEnd EndFunc “No other God have I but Thee; born in a manger, died on a tree.” Martin Luther
Moderators Melba23 Posted March 11, 2012 Moderators Posted March 11, 2012 rdwray, Same principle as before - only change the image when you need to. Here I have used a flag to show the state of the control - and also merely changed the image in the Pic control rather than create a new one each time: expandcollapse popup#include <GUIConstantsEx.au3> #include <misc.au3> Local $hDLL = DllOpen("user32.dll") $hWnD = GUICreate("Button As Image") GUISetState(@SW_SHOW) $hPid = GUICtrlCreatePic("M:ProgramAu3 ScriptsImagesInfo32.bmp", 40, 40, 20, 20) Main() Func Main() Local $fPressed = False While 1 $hImg = GUIGetCursorInfo($hWnD) If $hImg[4] = $hPid And _IsPressed("01", $hDLL) Then If Not $fPressed Then GUICtrlSetImage($hPid, "M:ProgramAu3 ScriptsImagesStop32.bmp") $fPressed = True EndIf Else If $fPressed Then GUICtrlSetImage($hPid, "M:ProgramAu3 ScriptsImagesInfo32.bmp") $fPressed = False EndIf EndIf Switch GUIGetMsg(0) Case $GUI_EVENT_CLOSE Exit DllClose($hDLL) EndSwitch WEnd EndFunc ;==>Main You will have to reset the image files, by the way. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Reveal hidden contents ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
rdwray Posted March 11, 2012 Author Posted March 11, 2012 On 3/11/2012 at 5:37 PM, 'Melba23 said: rdwray,Same principle as before - only change the image when you need to. Here I have used a flag to show the state of the control - and also merely changed the image in the Pic control rather than create a new one each time: This is still eluding me, the _IsPressed should be a flag saying that the change should take placed based upon the condition of the the mouse button and it doesn't work -why? “No other God have I but Thee; born in a manger, died on a tree.” Martin Luther
Moderators Melba23 Posted March 11, 2012 Moderators Posted March 11, 2012 rdwray,What is eluding you? The principle to avoid flickering is always the same - only change when you need to - which means you need something to tell you the current state of the control. GUICtrlread works for controls using text but in this case we need a flag as it is a Pic control. Relying on mousepresses and position alone is a sure recipe for flickering. Every time you have posted about flickering I have added a simple check to the code and each time the flickering has gone - just do it yourself in future and you will not have the problem. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Reveal hidden contents ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
rdwray Posted March 11, 2012 Author Posted March 11, 2012 Then On 3/11/2012 at 6:12 PM, 'Melba23 said: rdwray, What is eluding you? The principle to avoid flickering is always the same - only change when you need to - which means you need something to tell you the current state of the control. GUICtrlread works for controls using text but in this case we need a flag as it is a Pic control. Relying on mousepresses and position alone is a sure recipe for flickering. Every time you have posted about flickering I have added a simple check to the code and each time the flickering has gone - just do it yourself in future and you will not have the problem. M23 I made and error in my code in that I used the window handle instead of the image handle as you did and it now works when tested without the flags - I am not saying the flags should be eliminated, simply testing. #include <GUIConstantsEx.au3> #include <misc.au3> Local $hDLL = DllOpen("user32.dll") $hWnD = GUICreate("Button As Image") GUISetState(@SW_SHOW) $hPid = GUICtrlCreatePic(@ScriptDir & "\Images\MoveFirstUp.bmp", 40, 40, 20, 20) Main() Func Main() While 1 $hImg = GUIGetCursorInfo($hWnD) If $hImg[4] = $hPid And _IsPressed("01", $hDLL) Then GUICtrlSetImage($hPid, @ScriptDir & "\Images\MoveFirstDn.bmp") Else GUICtrlSetImage($hPid, @ScriptDir & "\Images\MoveFirstUp.bmp") EndIf Switch GUIGetMsg(0) Case $GUI_EVENT_CLOSE Exit DllClose($hDLL) EndSwitch WEnd EndFunc ;==>Main “No other God have I but Thee; born in a manger, died on a tree.” Martin Luther
rdwray Posted March 11, 2012 Author Posted March 11, 2012 M23, I finally got this one working and here is the logic which is exactly like a button works. Can the code be any cleaner? Has a up image and a down image. Pressing mouse over image changes it to down. Dragging mouse off image changes image to up. Dragging mouse back on image before releasing changes image to down. Any other condition the image is up. expandcollapse popup#include <GUIConstantsEx.au3> #include <misc.au3> Local $hDLL = DllOpen("user32.dll") $hWnD = GUICreate("Button As Image") GUISetState(@SW_SHOW) $hPid = GUICtrlCreatePic(@ScriptDir & "\Images\MoveFirstUp.bmp", 40, 40, 20, 20) Main() Func Main() Local $nPushed = True, $wPushed = True While 1 $hImg = GUIGetCursorInfo($hWnD) Select ; Over & pushed (wPushed = true) Case $hImg[4] = $hPid And _IsPressed("01", $hDLL) And $nPushed ;Then GUICtrlSetImage($hPid, @ScriptDir & "\Images\MoveFirstDn.bmp") $wPushed = True ; Over & was pushed Case $hImg[4] = $hPid And _IsPressed("01", $hDLL) And $wPushed ;Then GUICtrlSetImage($hPid, @ScriptDir & "\Images\MoveFirstDn.bmp") $nPushed = False ; Over & not pushed Case $hImg[4] = $hPid And Not _IsPressed("01", $hDLL) ;Then GUICtrlSetImage($hPid, @ScriptDir & "\Images\MoveFirstUp.bmp") $nPushed = True $wPushed = False ; Not over & not pushed (wPushed = False) Case $hImg[4] <> $hPid And Not _IsPressed("01", $hDLL) ;Then GUICtrlSetImage($hPid, @ScriptDir & "\Images\MoveFirstUp.bmp") $nPushed = True $wPushed = False ; Not over & pushed Case $hImg[4] <> $hPid And _IsPressed("01", $hDLL) ;Then GUICtrlSetImage($hPid, @ScriptDir & "\Images\MoveFirstUp.bmp") $nPushed = False EndSelect Switch GUIGetMsg(0) Case $GUI_EVENT_CLOSE Exit DllClose($hDLL) EndSwitch WEnd EndFunc ;==>Main “No other God have I but Thee; born in a manger, died on a tree.” Martin Luther
Moderators Melba23 Posted March 12, 2012 Moderators Posted March 12, 2012 rdwray, As you seem really keen on these image changes on various mouse actions, you might be interested in studying this: expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiButton.au3> #include <GuiImageList.au3> _Main() Func _Main() Local $sAutoIt_Path = StringReplace(@AutoItExe, "AutoIt3.exe", "") ConsoleWrite($sAutoIt_Path & @CRLF) Local $sGreen = $sAutoIt_Path & "ExamplesGUIAdvancedImagesGreen.bmp" Local $sBlue = $sAutoIt_Path & "ExamplesGUIAdvancedImagesBlue.bmp" Local $sRed = $sAutoIt_Path & "ExamplesGUIAdvancedImagesRed.bmp" Local $sIcon1 = $sAutoIt_Path & "Iconsau3.ico" Local $sIcon2 = $sAutoIt_Path & "Iconsau3script_v10.ico" Local $btn1, $btn2, $btn3, $btn4, $msg Local $hImagebtn1, $hImagebtn2, $hImagebtn3, $hImagebtn4 Local $label1 ;Caveat: Minimum Operating Systems: Windows XP Local $hGUI = GUICreate("Button Imagelists", 500, 300) $label1 = GUICtrlCreateLabel("", 150, 30, 340, 250) GUICtrlSetFont(-1, 12) $msg = "The 'Changer' button shows what can be done. " & @CRLF $msg &= "It displays Blue normally," & @CRLF $msg &= "but changes to Red when the cursor is over it. " & @CRLF $msg &= "Pressing changes it to Green." & @CRLF $msg &= "When disabled it shows Red, " & @CRLF $msg &= "and when focused (use the Tab key)" & @CRLF $msg &= "it switches between 2 icons." GUICtrlSetData($label1, $msg) ;multi state image Bitmap $btn1 = GUICtrlCreateButton("Changer", 30, 30, 90, 32) GUICtrlSetTip(-1, "Multi state bitmap imagelist") $hImagebtn1 = _GUIImageList_Create(24, 24, 5, 5) _GUIImageList_AddBitmap($hImagebtn1, $sBlue) ;1 - Normal _GUIImageList_AddBitmap($hImagebtn1, $sRed) ;2 - Hot _GUIImageList_AddBitmap($hImagebtn1, $sGreen) ;3 - Pressed _GUIImageList_AddBitmap($hImagebtn1, $sRed) ;4 - Disabled _GUIImageList_AddIcon($hImagebtn1, $sIcon1) ;5 - Focus Switch - possibly Vista only for the switch _GUIImageList_AddIcon($hImagebtn1, $sIcon2) ;6 - Focus Switch _GUICtrlButton_SetImageList($btn1, $hImagebtn1) ;single state image Bitmap $btn2 = GUICtrlCreateButton("Disable", 30, 70, 90, 32) GUICtrlSetTip(-1, "Single bitmap imagelist") $hImagebtn2 = _GUIImageList_Create(24, 24, 5, 3) _GUIImageList_AddBitmap($hImagebtn2, $sRed);1 - Normal _GUICtrlButton_SetImageList($btn2, $hImagebtn2) ;single state image Icon $btn3 = GUICtrlCreateButton("Unlock", 30, 110, 90, 40) GUICtrlSetTip(-1, "Single icon imagelist") $hImagebtn3 = _GUIImageList_Create(32, 32, 5, 3) _GUIImageList_AddIcon($hImagebtn3, "shell32.dll", 47, True) _GUICtrlButton_SetImageList($btn3, $hImagebtn3) ;single state image Bitmap with overlay text $btn4 = GUICtrlCreateButton("Help", 30, 160, 90, 32) GUICtrlSetTip(-1, "Single bitmap imagelist with overlayed text") GUICtrlSetFont(-1, 14, 800, -1, "Comic Sans MS") $hImagebtn4 = _GUIImageList_Create(90, 32, 5, 3) _GUIImageList_AddBitmap($hImagebtn4, $sRed) _GUICtrlButton_SetImageList($btn4, $hImagebtn4, 4) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $btn1 GUICtrlSetState($btn4, $GUI_FOCUS) Case $btn2 GUICtrlSetState($btn1, $GUI_DISABLE) Case $btn3 GUICtrlSetState($btn1, $GUI_ENABLE) Case $btn4 MsgBox(0, "", "Hi!") EndSwitch WEnd EndFunc ;==>_Main Any use? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Reveal hidden contents ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
rdwray Posted March 12, 2012 Author Posted March 12, 2012 On 3/12/2012 at 8:32 AM, 'Melba23 said: rdwray, As you seem really keen on these image changes on various mouse actions, you might be interested in studying this: expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiButton.au3> #include <GuiImageList.au3> _Main() Func _Main() Local $sAutoIt_Path = StringReplace(@AutoItExe, "AutoIt3.exe", "") ConsoleWrite($sAutoIt_Path & @CRLF) Local $sGreen = $sAutoIt_Path & "ExamplesGUIAdvancedImagesGreen.bmp" Local $sBlue = $sAutoIt_Path & "ExamplesGUIAdvancedImagesBlue.bmp" Local $sRed = $sAutoIt_Path & "ExamplesGUIAdvancedImagesRed.bmp" Local $sIcon1 = $sAutoIt_Path & "Iconsau3.ico" Local $sIcon2 = $sAutoIt_Path & "Iconsau3script_v10.ico" Local $btn1, $btn2, $btn3, $btn4, $msg Local $hImagebtn1, $hImagebtn2, $hImagebtn3, $hImagebtn4 Local $label1 ;Caveat: Minimum Operating Systems: Windows XP Local $hGUI = GUICreate("Button Imagelists", 500, 300) $label1 = GUICtrlCreateLabel("", 150, 30, 340, 250) GUICtrlSetFont(-1, 12) $msg = "The 'Changer' button shows what can be done. " & @CRLF $msg &= "It displays Blue normally," & @CRLF $msg &= "but changes to Red when the cursor is over it. " & @CRLF $msg &= "Pressing changes it to Green." & @CRLF $msg &= "When disabled it shows Red, " & @CRLF $msg &= "and when focused (use the Tab key)" & @CRLF $msg &= "it switches between 2 icons." GUICtrlSetData($label1, $msg) ;multi state image Bitmap $btn1 = GUICtrlCreateButton("Changer", 30, 30, 90, 32) GUICtrlSetTip(-1, "Multi state bitmap imagelist") $hImagebtn1 = _GUIImageList_Create(24, 24, 5, 5) _GUIImageList_AddBitmap($hImagebtn1, $sBlue) ;1 - Normal _GUIImageList_AddBitmap($hImagebtn1, $sRed) ;2 - Hot _GUIImageList_AddBitmap($hImagebtn1, $sGreen) ;3 - Pressed _GUIImageList_AddBitmap($hImagebtn1, $sRed) ;4 - Disabled _GUIImageList_AddIcon($hImagebtn1, $sIcon1) ;5 - Focus Switch - possibly Vista only for the switch _GUIImageList_AddIcon($hImagebtn1, $sIcon2) ;6 - Focus Switch _GUICtrlButton_SetImageList($btn1, $hImagebtn1) ;single state image Bitmap $btn2 = GUICtrlCreateButton("Disable", 30, 70, 90, 32) GUICtrlSetTip(-1, "Single bitmap imagelist") $hImagebtn2 = _GUIImageList_Create(24, 24, 5, 3) _GUIImageList_AddBitmap($hImagebtn2, $sRed);1 - Normal _GUICtrlButton_SetImageList($btn2, $hImagebtn2) ;single state image Icon $btn3 = GUICtrlCreateButton("Unlock", 30, 110, 90, 40) GUICtrlSetTip(-1, "Single icon imagelist") $hImagebtn3 = _GUIImageList_Create(32, 32, 5, 3) _GUIImageList_AddIcon($hImagebtn3, "shell32.dll", 47, True) _GUICtrlButton_SetImageList($btn3, $hImagebtn3) ;single state image Bitmap with overlay text $btn4 = GUICtrlCreateButton("Help", 30, 160, 90, 32) GUICtrlSetTip(-1, "Single bitmap imagelist with overlayed text") GUICtrlSetFont(-1, 14, 800, -1, "Comic Sans MS") $hImagebtn4 = _GUIImageList_Create(90, 32, 5, 3) _GUIImageList_AddBitmap($hImagebtn4, $sRed) _GUICtrlButton_SetImageList($btn4, $hImagebtn4, 4) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $btn1 GUICtrlSetState($btn4, $GUI_FOCUS) Case $btn2 GUICtrlSetState($btn1, $GUI_DISABLE) Case $btn3 GUICtrlSetState($btn1, $GUI_ENABLE) Case $btn4 MsgBox(0, "", "Hi!") EndSwitch WEnd EndFunc ;==>_Main Any use? M23 M23, thanks, I will definitely do some studing on this one. Once in awhile you smart people let go with some of your knowledge.... “No other God have I but Thee; born in a manger, died on a tree.” Martin Luther
Moderators Melba23 Posted March 12, 2012 Moderators Posted March 12, 2012 rdwray,I try to "let go" of what I know all the time - that is why I come here. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Reveal hidden contents ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
rdwray Posted March 12, 2012 Author Posted March 12, 2012 M23, the reason I was trying to use an image instead of a button is because of the outline the button creates. In the case of the image list the image is moved to the right approx 5 pixels and filling the rest of the button - in other words, I need to move the image 5 pixels to the left using a button. “No other God have I but Thee; born in a manger, died on a tree.” Martin Luther
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