Jump to content
Sign in to follow this  
rdwray

Flicker

Recommended Posts

rdwray

Why is this flickering?

EDIT: Now it isn't flickering??????

#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 by rdwray

“No other God have I but Thee; born in a manger, died on a tree.” Martin Luther

Share this post


Link to post
Share on other sites
Melba23

rdwray,

It will flicker becasuse you reset the label text on each pass - try something like this for each button: :oops:

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
rdwray

rdwray,

It will flicker becasuse you reset the label text on each pass - try something like this for each button: :bye:

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

“No other God have I but Thee; born in a manger, died on a tree.” Martin Luther

Share this post


Link to post
Share on other sites
Melba23

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

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
rdwray

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

M23

I know you are not going to believe this, but I made a mistake and it is working now - thanks M23 :oops:

“No other God have I but Thee; born in a manger, died on a tree.” Martin Luther

Share this post


Link to post
Share on other sites
rdwray

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

Share this post


Link to post
Share on other sites
Melba23

rdwray,

Same principle as before - only change the image when you need to. :oops:

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: :bye:

#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. :doh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
rdwray

rdwray,

Same principle as before - only change the image when you need to. :oops:

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: :doh:

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? :bye:

“No other God have I but Thee; born in a manger, died on a tree.” Martin Luther

Share this post


Link to post
Share on other sites
Melba23

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

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

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
rdwray

Then

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

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

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

#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

Share this post


Link to post
Share on other sites
rdwray

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

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.

#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

Share this post


Link to post
Share on other sites
Melba23

rdwray,

As you seem really keen on these image changes on various mouse actions, you might be interested in studying this: :bye:

#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? :oops:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
rdwray

rdwray,

As you seem really keen on these image changes on various mouse actions, you might be interested in studying this: :doh:

#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? :bye:

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

“No other God have I but Thee; born in a manger, died on a tree.” Martin Luther

Share this post


Link to post
Share on other sites
Melba23

rdwray,

I try to "let go" of what I know all the time - that is why I come here. :oops:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
rdwray

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.

post-61681-0-07913400-1331579855_thumb.p


“No other God have I but Thee; born in a manger, died on a tree.” Martin Luther

Share this post


Link to post
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
Sign in to follow this  

×