Sign in to follow this  
Followers 0
Manjish

Problem with @sw_disable/enable

8 posts in this topic

#1 ·  Posted (edited)

Guys I have this GUI's.. 1 is the main with two buttons.. each button launches a new gui.. i don't want anyone to access my main window, whenever i am doing something with my child windows.. so i change the guisetstate to @sw_disable when i launch my child windows.. and enable it again when any of them are closed..

This works fine.. But my problem is when i close the child windows.. the main window gets minimized.. it is enabled.. but it gets minimized for no reason.. I don't know the problem here.. please help me sort this out.. thanks..

#include <EditConstants.au3>
#include <GUIConstants.au3>
#include<AES.au3>
$file = "db.ini"
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 436, 221, 193, 125)
$Group1 = GUICtrlCreateGroup("Make A Choice", 0, 0, 433, 217)
$Button1 = GUICtrlCreateButton("Register", 24, 152, 169, 33, 0)
$Button2 = GUICtrlCreateButton("Login", 240, 152, 169, 33, 0)
$Label1 = GUICtrlCreateLabel("What Do You Wish To Do?", 136, 72, 135, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
     Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $Button1
          GUISetState(@sw_disable)
            Register()
       GUISetState(@SW_ENABLE)
        Case $Button2 
          GUISetState(@sw_disable)
            Signin()
       GUISetState(@sw_enable)
    EndSwitch

WEnd
Exit


Func Register()
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Register", 350, 200, 193, 125)
$Group1 = GUICtrlCreateGroup("Register", 0, 0, 345, 195)
$Label1 = GUICtrlCreateLabel("Enter Registration Information", 40, 30, 143, 17)
$input1=GUICtrlCreateInput("", 110, 70, 233, 21)
$Label2 = GUICtrlCreateLabel("Username", 48, 70, 60, 17)
$Label3 = GUICtrlCreateLabel("Password", 48, 120, 60, 17)
$input2=GUICtrlCreateInput("", 110, 120, 233, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$Button3 = GUICtrlCreateButton("OK", 90, 150, 169, 30, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
            ExitLoop
    Case $Button3 
    $check=_CheckUsername($file,GUICtrlRead($input1))
                If Not $check Then
                    IniWrite($file, "UserData", GUICtrlRead($input1), _AesEncrypt("Key",GUICtrlRead($input2)))
                Else
                    MsgBox(0, "", "Username already exists!")
                EndIf
        ExitLoop
   EndSwitch
WEnd
GUIDelete($Form1)
EndFunc

Func Signin()
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Login", 350, 200, 193, 125)
$Group1 = GUICtrlCreateGroup("Login", 0, 0, 345, 195)
$Label1 = GUICtrlCreateLabel("Enter Registration Information", 40, 30, 143, 17)
$input1=GUICtrlCreateInput("", 110, 70, 233, 21)
$Label2 = GUICtrlCreateLabel("Username", 48, 70, 60, 17)
$Label3 = GUICtrlCreateLabel("Password", 48, 120, 60, 17)
$input2=GUICtrlCreateInput("", 110, 120, 233, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$Button4 = GUICtrlCreateButton("OK", 90, 150, 169, 30, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
            ExitLoop
    Case $Button4  
    $check = _CheckUsername($file, GUICtrlRead($input1))
                If $check Then
                    $password = IniRead($file, "UserData", GUICtrlRead($input1), "")
                    If Not @error And BinaryToString(_AesDecrypt("Key",$password)) == GUICtrlRead($input2) Then
                    MsgBox(0, "", "Credentials correct!")
                    Exit
                    ElseIf BinaryToString(_AesDecrypt("Key",$password))<>GUICtrlRead($input2) Then
                        MsgBox (0, "", "Incorect Password Entered!")
                   EndIf
                Else 
                   MsgBox(0,"","Incorrect Username Entered")
                EndIf
        ExitLoop
    EndSwitch
WEnd
GUIDelete($Form1)
EndFunc

Func _CheckUsername($file, $username)
    $var = IniReadSection($file, "UserData")
    If @error Then
        Return 0
    Else
        For $i = 1 To $var[0][0]
            If $var[$i][0]=$username Then Return 1
        Next
        Return 0
    EndIf
EndFunc;==>_CheckUsername

; To encrypt/decrypt memory block or string:
$Encrypted = _AesEncrypt("Key", "Plantext")
$Decrypted = _AesDecrypt("Key", $Encrypted)
$Result = BinaryToString($Decrypted)
Edited by Manjish

[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

Share this post


Link to post
Share on other sites



@Manjish

Link of AES.au3 ?

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Manjish,

Use $GUI_ENABLE/$GUI_DISABLE and it works - but do not ask me why!

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

Manjish,

Use $GUI_ENABLE/$GUI_DISABLE and it works - but do not ask me why!

M23

Ya but, how do use it.. i can'tuse it in guisetstate..


[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

Share this post


Link to post
Share on other sites

Manjish,

Yes you can! Just try and see! How do you think I know it works? But as I said, I do not know why!

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

@Manjish

Link of AES.au3 ?

Cheers, FireFox.

Doesn't matter.. just remove those lines.. i had used it for encryption/decryption.. but my problem is different.. so just forget that part..


[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

Share this post


Link to post
Share on other sites

Doesn't matter.. just remove those lines.. i had used it for encryption/decryption.. but my problem is different.. so just forget that part..

Melba's solution is working...

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

@M23

Ah.. your philosophy.. I certainly appreciate it.. Now knowing how it feels to be on the other side..:)

Anyways, I found a workaround.. I know it's a "WorkAround" and not a solution.. but nevertheless it does the job.. :)

While 1
     Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $Button1
           GUISetState(@sw_disable)
            Register()
        GUISetState(@SW_ENABLE)
        GUISetState(@SW_RESTORE)

        Case $Button2 
           GUISetState(@sw_disable)
            Signin()
        GUISetState(@sw_enable)
        GUISetState(@SW_RESTORE)
    EndSwitch

WEnd

[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

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  
Followers 0