Jump to content

Multiple Guis & Skin UDF


Recommended Posts

Hello everyone! I hope you’re all doing well. Could somebody please assist me with a doubt I have?

I’m working on a larger project, but this small example will help illustrate my question. How can I set up skin buttons using the advanced parameter with GUIGetMsg  in AutoIt?

Here’s the scenario: I’m creating a skin button that opens a new GUI. This secondary GUI also has a skin button. My goal is to have both my primary and secondary GUIs equipped with these skin buttons. I believe that _Skin_Helper is the main function responsible for refreshing the buttons. However, when I attempt to include both GUIs in the while loop (as shown in the script below), it doesn’t work as expected. After clicking the primary skin button once, there seems to be a conflict.

 

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#Include <Skin.au3>

Global $g_hGUI1, $g_idButton1, $g_idButton2, $g_hGUI2, $g_idButton3

example()

Func example()

    gui1()
    _Skin_EnableFocus(1)
    Local $aMsg

    While 1
        _Skin_Helper($g_hGUI1)
        _Skin_Helper($g_hGUI2)

        $aMsg = GUIGetMsg(1) ; Use advanced parameter to get array
        If Not IsHWnd($aMsg[1]) Then ContinueLoop ; preventing subsequent lines from processing when nothing happens

        Switch $aMsg[1] ; check which GUI sent the message
            Case $g_hGUI1
                Switch $aMsg[0] ; Now check for the messages for $g_hGUI1
                    Case $GUI_EVENT_CLOSE ; If we get the CLOSE message from this GUI: $g_hGUI1 ...
                        ExitLoop ;  ... exit the loop and thus exit the program
                    Case $g_idButton1
                        MsgBox($MB_OK, "MsgBox 1", "Test from GUI 1")
                    Case $Button
                        ;GUICtrlSetState($g_idButton2, $GUI_DISABLE)
                        gui2()
                EndSwitch
            Case $g_hGUI2
                Switch $aMsg[0] ; Now check for the messages for $g_hGUI2
                    Case $GUI_EVENT_CLOSE ; If we get the CLOSE message from this GUI : $g_hGUI2 ...
                        GUIDelete($g_hGUI2) ; ... just delete the GUI ...
                        ;GUICtrlSetState($g_idButton2, $GUI_ENABLE) ; ... enable button (previously disabled)
                    Case $g_idButton3
                        MsgBox($MB_OK, "MsgBox", "Test from GUI 2")
                EndSwitch
        EndSwitch
    WEnd

EndFunc   ;==>example

Func gui1()
    $g_hGUI1 = GUICreate("GUI 1", 200, 200, 100, 100)
    $g_idButton1 = GUICtrlCreateButton("Msgbox 1", 10, 10, 80, 30)
    $g_idButton2 = GUICtrlCreateButton("Show GUI 2", 10, 60, 80, 30)
    Global $Button = _Skin_AddButton(20,110,64,64,'red_normal.png', 'red_hover.png', 'red_click.png','','',1)
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO + $GUI_DOCKSTATEBAR + $GUI_DOCKHEIGHT)
    GUISetState()
EndFunc   ;==>gui1

Func gui2()
    $g_hGUI2 = GUICreate("GUI 2", 200, 200, 350, 350)
    GUISetState()
    Global $g_idButton3 = _Skin_AddButton(10,10,80,30,'yellow_normal.png', 'yellow_hover.png', 'yellow_click.png','','',1)
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO + $GUI_DOCKSTATEBAR + $GUI_DOCKHEIGHT)
EndFunc   ;==>gui2

 

red_click.png

red_hover.png

red_normal.png

yellow_click.png

yellow_hover.png

yellow_normal.png

Skin.au3 Skin_Ex.au3 cdecdecdecde.au3

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