Jump to content

GUIGetMsg and 2 GUIs


Bester
 Share

Go to solution Solved by Melba23,

Recommended Posts

Hello, 

i have a bit of a problem here, and i don`t know what i messed up. Basicly i`m trying to work with 2 GUIs, but i don`t even need to open secound gui and i keep getting message from it, $nMsg[0] = $save_settings_btn and i don`t know what is the problem, since i isolated it with 

If $nMsg[0] = $save_settings_btn Then
            If $nMsg[1] = $secondary_gui Then
                ConsoleWrite("Save button was pushed")
                ToolTip("Settings were saved", 400, 400)
            EndIf
        EndIf

here`s the whole loop function

Func LoopGUI()
    Local $nMsg
    Local $MW

    While True
        $nMsg = GUIGetMsg(1)

        If $nMsg[0] = $GUI_EVENT_CLOSE Then ;when windows is closed do a cleanup for GDI+
            If $nMsg[1] = $main_gui Then
                _GDIPlus_GraphicsDispose($hGraphic)
                _GDIPlus_ImageDispose($clickable_logo)
                _GDIPlus_Shutdown()
                Exit
            Else
                GUIDelete($secondary_gui)
                GUICtrlSetState($setting_button, $GUI_ENABLE)
            EndIf
        EndIf

        If $nMsg[0] = $GUI_EVENT_RESTORE Then ;after restoring minimized windows autoit won`t show some graphics
            RefreshGDIPlus()
        EndIf

        If $nMsg[0] = $GUI_EVENT_PRIMARYDOWN Then ;enables clicking on logo
            InRect()
        EndIf

        If $nMsg[0] = $setting_button Then
            SettingsGUI()
            GUICtrlSetState($setting_button, $GUI_DISABLE)
        EndIf

        If $nMsg[0] = $save_settings_btn Then
            If $nMsg[1] = $secondary_gui Then
                ConsoleWrite("Save button was pushed")
                ToolTip("Settings were saved", 400, 400)
            EndIf
        EndIf

        For $i = 1 To $button[0] ;the main thing, opens VLC
            If $nMsg[0] = $button[$i] Then
                $MW = RegRead("HKEY_CURRENT_USER\Software\TV Atris", "MultiWindow")
                If $MW = 0 Then
                    WinClose("VLC media player")
                    Run($VLC_path & " " & $stream_address[$i])
                    ConsoleWrite($stream_address[$i] & @CRLF)
                Else
                    Run($VLC_path & " " & $stream_address[$i])
                    ConsoleWrite($stream_address[$i] & @CRLF)
                EndIf
            EndIf
        Next

    WEnd
EndFunc   ;==>LoopGUI

any help would be appreciated, 

Thank you

Edited by Bester
Link to comment
Share on other sites

Thank you kindly for your help good sir, but somehow i still have a problem with this, i`ve tried to use GUISwitch as you suggested (must admit, i don`t understand it much), but still, after i open my primary gui, i keep getting message from secound gui, which isn`t even opend yet, and it really confuse me, since i don`t see how can this be happening.

Link to comment
Share on other sites

Okey i found a workaround, i`m not too happy about this but it works, i`ve created a $variable = 0 and when secound GUI is created $variable is set to 1.

I found out that if i`m trying to GUIGetMsg button which has not been created yet, it will always return positive. So i`m going to use this $variable to determin when secound GUI has been build.

BUT, if anybody got better idea, please let me know! 

Thanks :)

Edited by Bester
Link to comment
Share on other sites

  • Moderators

Bester,

Have you read the Managing Multiple GUIs tutorial in the Wiki? If not I heartily recommend it. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

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

 

Link to comment
Share on other sites

Yes, i actually did, and that`s exactly what i`ve done, only i wasn`t using Swich but If, and this thing happened. That`s why i was so suprised, that i`m getting answer from the button that wasn`t even created.

Edited by Bester
Link to comment
Share on other sites

  • Moderators
  • Solution

Bester,

It is difficult to know for sure from the small snippets of code you have given us, but I would hazard a guess that you have declared the variable which will hold the to-be-created button ControlID but not given it a value - in this case Autoit interprets it 0. And guess what is the return value from GUIGetMsg when nothing is happening? :whistle:

When you declare the variable give it a placeholder value (I always use 9999 as I have never yet used ten thousand controls in a GUI) and then it will not fire until you actually create the button and assign the real ControlID to the variable. Remember also to reset the placeholder value if you delete the button. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

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

 

Link to comment
Share on other sites

  • Moderators

Bester,

Nice to see that the crystal ball still works! :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

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

 

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