meoit

MultiForm is NOT properly working

1 post in this topic

#1 ·  Posted (edited)

Hi guys.

Sorry for my bad English.

I am trying to create two Forms, one called "Guide Form", one called "Main Form". I want to the "Guide Form" show up if no have my Key in the Registry. And when I see the "Main Form", I continue to call up the "Guide Form", I want to this "Guide Form" is only have a button is "OK, Close me (Guide Form)", then it will return to show up the "Main Form".

But, I was having problems. It does not work as expected and I can not close this GUIs after pressing button of them repeatedly.

I see the problem that just met for the first time when I run my EXE. Apparently, the value of $Only_FrmMAIN_Showed did not change after I click 'Show Guide Form and hide me'. The Exit button is still there and the button 'Go to Main Form and hide me' has not been replaced by button ''OK, Close me (Guide Form)''.

This is my code:

#include <Constants.au3>
#include <GUIConstants.au3>
Opt('MustDeclareVars', 1)
Global $MsgOfForms, $SaveKey = 'HKCU\AAA Test MultiForm', $SaveName = 'FrmMAIN Showed'
;
Global $FrmGUIDE = GUICreate('Guide Form', 298, 181, -1, -1)
Global $EDIT_ONE = GUICtrlCreateEdit('', 16, 8, 265, 121)
GUICtrlSetData($EDIT_ONE, StringFormat('This is Guide Form. Bla Bla\r\n\r\nBla Bla\r\nBla Bla\r\nBla Bla\r\nBla Bla\r\nBla Bla\r\nBla Bla\r\nBla Bla\r\nBla Bla\r\nBla Bla\r\n\r\nThis is Guide Form. Bla Bla'))
If RegRead($SaveKey, $SaveName) == 'Yes Yes' Then ;If have value 'Yes Yes' in Registry, only need create one Button.
    Global $BT_GOTO_FrmMAIN = GUICtrlCreateButton('OK, Close me (Guide Form)', 50, 144, 171, 25)
Else
    Global $BT_EXIT = GUICtrlCreateButton('Exit', 16, 144, 75, 25)
    Global $BT_GOTO_FrmMAIN = GUICtrlCreateButton('Go to Main Form and hide me', 112, 144, 171, 25)
EndIf
;
Global $FrmMAIN = GUICreate('Main form', 260, 168, -1, -1)
Global $BT_EXIT_ALL = GUICtrlCreateButton('Exit all', 77, 116, 105, 25)
Global $BT_SHOW_FrmGUIDE = GUICtrlCreateButton('Show Guide Form and hide me', 45, 45, 177, 25)
;
If RegRead($SaveKey, $SaveName) == 'Yes Yes' Then ;Only the FrmMAIN is showed (If have value 'Yes Yes' in Registry), no show FrmGUIDE.
    GUISetState(@SW_SHOW, $FrmMAIN)
    GUISetState(@SW_HIDE, $FrmGUIDE)
Else
    GUISetState(@SW_SHOW, $FrmGUIDE)
    GUISetState(@SW_HIDE, $FrmMAIN)
EndIf
;
While 1
    $MsgOfForms = GUIGetMsg(1)
    Switch $MsgOfForms[1]
        Case $FrmGUIDE
            Local $Only_FrmMAIN_Showed = RegRead($SaveKey, $SaveName)
            Switch $Only_FrmMAIN_Showed
                Case 'Yes Yes'
                    If $MsgOfForms[0] = $BT_GOTO_FrmMAIN Then
                        RegWrite($SaveKey, $SaveName, 'REG_SZ', 'Yes Yes')
                        GUISetState(@SW_HIDE, $FrmGUIDE)
                        GUISetState(@SW_SHOW, $FrmMAIN)
                    EndIf
                Case Else
                    If $MsgOfForms[0] = $GUI_EVENT_CLOSE Or $MsgOfForms[0] = $BT_EXIT Then
                        Exit
                    ElseIf $MsgOfForms[0] = $BT_GOTO_FrmMAIN Then
                        RegWrite($SaveKey, $SaveName, 'REG_SZ', 'Yes Yes')
                        GUISetState(@SW_HIDE, $FrmGUIDE)
                        GUISetState(@SW_SHOW, $FrmMAIN)
                    EndIf
            EndSwitch
        Case $FrmMAIN
            If $MsgOfForms[0] = $GUI_EVENT_CLOSE Or $MsgOfForms[0] = $BT_EXIT_ALL Then
                Exit
            ElseIf $MsgOfForms[0] = $BT_SHOW_FrmGUIDE Then
                GUISetState(@SW_HIDE, $FrmMAIN)
                GUISetState(@SW_SHOW, $FrmGUIDE)
            EndIf
    EndSwitch
WEnd

How to fix them ?.

Thanks all.

Edited by meoit

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