Sign in to follow this  
Followers 0
notta

How do you achieve this?

7 posts in this topic

#1 ·  Posted (edited)

Thanks rasim. I have a case statement that handles a checkbox in my main while loop that is only displayed when certain conditions are met. When the checkbox is not displayed I still have the case for the checkbox in my main while loop. How can I handle this condition?

ok some psuedo code:

ip = 201

if ip > 200
$checkbox = guictrlcreatecheckbox


while 1
  $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
                Case $checkbox
                    do something 
Wend

Now how do I handle this?

ip = 100

if ip > 200
$checkbox = guictrlcreatecheckbox


while 1
  $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
                Case $checkbox  <-- this is causing problems now. How can I conditionally handle this?
                    do something 
Wend
Edited by notta

Share this post


Link to post
Share on other sites



I have a case statement that handles a checkbox in my main while loop that is only displayed when certain conditions are met. When the checkbox is not displayed I still have the case for the checkbox in my main while loop. How can I handle this condition?

Don`t see a problem:

#include <GuiConstantsEx.au3>

$hGUI = GUICreate("Test", 200, 100)

$checkbox = GUICtrlCreateCheckbox("Test", 50, 50, 50, 20)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $checkbox
            If BitAND(GUICtrlRead($checkbox), $GUI_CHECKED) Then
                ConsoleWrite("-> Checked" & @LF)
            Else
                ConsoleWrite("-> Unchecked" & @LF)
            EndIf
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Sorry guys. i wiped out my original post. Been a very long day.

Thanks rasim. I have a case statement that handles a checkbox in my main while loop that should only be displayed when certain conditions are met. When the checkbox is not displayed I still have the case for the checkbox in my main while loop. How can I handle this condition?

ok some psuedo code:

ip = 201

if ip > 200
$checkbox = guictrlcreatecheckbox


while 1
  $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $checkbox
                if $checkbox = checked Then 
                set text on status bar to true
            Else 
                set text on status bar to false
Wend

Now how do I handle this?

ip = 100

if ip > 200
$checkbox = guictrlcreatecheckbox


while 1
  $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $checkbox  <-- problem. How can I conditionally handle this? I don't need this condition under this situation, but how can I remove it? Status bar text is flickering false.
            if $checkbox = checked Then 
               set text on status bar to true
            Else 
               set text on status bar to false
Wend
Edited by notta

Share this post


Link to post
Share on other sites

Sorry guys. i wiped out my original post. Been a very long day.

Thanks rasim. I have a case statement that handles a checkbox in my main while loop that should only be displayed when certain conditions are met. When the checkbox is not displayed I still have the case for the checkbox in my main while loop. How can I handle this condition?

ok some psuedo code:

ip = 201

if ip > 200
$checkbox = guictrlcreatecheckbox


while 1
  $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $checkbox
                if $checkbox = checked Then 
                set text on status bar to true
            Else 
                set text on status bar to false
Wend

Now how do I handle this?

ip = 100

if ip > 200
$checkbox = guictrlcreatecheckbox


while 1
  $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $checkbox  <-- problem. How can I conditionally handle this? I don't need this condition under this situation, but how can I remove it? Status bar text is flickering false.
            if $checkbox = checked Then 
               set text on status bar to true
            Else 
               set text on status bar to false
Wend
I don`t understand your question completely. What this mean

checkbox in my main while loop that should only be displayed

? Checkbox hided, disabled? Maybe you need this?

#include <GuiConstantsEx.au3>

Global $CheckFlag = False

$hGUI = GUICreate("Test", 200, 100)

$checkbox = GUICtrlCreateCheckbox("Test", 50, 50, 50, 20)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $checkbox
            If $CheckFlag = False Then
                $CheckFlag = True
                If BitAND(GUICtrlRead($checkbox), $GUI_CHECKED) Then
                    ConsoleWrite("-> Checked" & @LF)
                Else
                    ConsoleWrite("-> Unchecked" & @LF)
                EndIf
            EndIf
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I read last nights post and I'm like uggggh! I was out of it last night. Anyway I just threw an example together that illustrates what I'm writing about:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiStatusBar.au3>

Dim $dhcp = "True"
Dim $checkboxDHCP = ""
Dim $msg, $GUI
Dim $ipaddress = "192.168.1.98"
Global $aParts[3] = [170, 400, -1]



    $GUI = GUICreate("My GUI",500, 510); will create a dialog box that when displayed is centered
    
    if $dhcp == "False" Then
        $checkboxDHCP = GUICtrlCreateCheckbox("Register the IP address", 50,50)
    Else
        GUICtrlCreateLabel("Do not need the checkbox.",50,50)
    EndIf
    
    $hStatus = _GUICtrlStatusBar_Create ($GUI)
    _GUICtrlStatusBar_SetParts ($hStatus, $aParts)
    _GUICtrlStatusBar_SetText ($hStatus, " " & "IP Address = " & $ipaddress)
    _GUICtrlStatusBar_SetText ($hStatus, " " & "DHCP IP = " & $dhcp, 1)
    
    Select
        Case $dhcp = "True" 
            _GUICtrlStatusBar_SetText ($hStatus, " " & "Send mail = " & $dhcp, 2)
        Case $dhcp = "False" 
            _GUICtrlStatusBar_SetText ($hStatus, " " & "Send mail = " & $dhcp, 2)
    EndSelect
    
    GUISetState(@SW_SHOW); will display an empty dialog box

; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $checkboxDHCP; I don't need this case if $dhcp == "True"
            If BitAND(GUICtrlRead($checkBoxDHCP), $GUI_CHECKED) Then
                _GUICtrlStatusBar_SetText ($hStatus, " " & "Send mail = " & "True", 2)
            Else
                      ;MsgBox(0,"","tEST");IF $dhcp = "True" This gets executed over and over.
                _GUICtrlStatusBar_SetText ($hStatus, " " & "Send mail = " & "False", 2)
            EndIf
    EndSelect
    WEnd

If $dhcp == "True I don't need the checkbox in the GUI I don't need the checkbox. If it's true I want to put a label on the screen, but i still have that case for the checkbox in my while loop which is causing _GUICtrlStatusBar_SetText ($hStatus, " " & "Send mail = " & $dhcp, 2) to loop which is making the false flicker. Set $dhcp to "True" and "False" and see what I mean.

Edited by notta

Share this post


Link to post
Share on other sites

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $checkbox
            If $CheckFlag = False Then
                $CheckFlag = True
                If BitAND(GUICtrlRead($checkbox), $GUI_CHECKED) Then
                    ConsoleWrite("-> Checked" & @LF)
                Else
                    ConsoleWrite("-> Unchecked" & @LF)
                EndIf
            EndIf
    EndSwitch
WEnd

Thanks Rasim. The checkflag seems to do the job. I had the remove the setting $checkflag = "True" after testing for If $CheckFlag = False because if I unchecked the box it would not change the text in the status bar back. You guys make this stuff look so easy while I spend hour upon hours doing the stuff you can do in no time. I'll test it out in my full script and see if I have any issues. I'm up 2000 lines and it's getting confusing.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

By the way, the working version of what I meant.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiStatusBar.au3>

;Dim $dhcp = "True"
Dim $dhcp = "False"
Dim $checkboxDHCP = ""
Dim $msg, $GUI
Dim $ipaddress = "192.168.1.98"
Global $aParts[3] = [170, 400, -1]
Global $checkflag = "False"


    $GUI = GUICreate("My GUI",500, 510); will create a dialog box that when displayed is centered
    
    if $dhcp == "False" Then
        $checkboxDHCP = GUICtrlCreateCheckbox("Register the IP address", 50,50)
    Else
        $checkflag = "True"
        GUICtrlCreateLabel("Do not need the checkbox.",50,50)
    EndIf
    
    $hStatus = _GUICtrlStatusBar_Create ($GUI)
    _GUICtrlStatusBar_SetParts ($hStatus, $aParts)
    _GUICtrlStatusBar_SetText ($hStatus, " " & "IP Address = " & $ipaddress)
    _GUICtrlStatusBar_SetText ($hStatus, " " & "DHCP IP = " & $dhcp, 1)
    
    Select
        Case $dhcp = "True" 
            _GUICtrlStatusBar_SetText ($hStatus, " " & "Send mail = " & $dhcp, 2)
        Case $dhcp = "False" 
            _GUICtrlStatusBar_SetText ($hStatus, " " & "Send mail = " & $dhcp, 2)
    EndSelect
    
    GUISetState(@SW_SHOW)    ; will display an empty dialog box

  ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $checkboxDHCP
            if $checkflag = "False" Then
        ;$checkflag = "True"
            If BitAND(GUICtrlRead($checkBoxDHCP), $GUI_CHECKED) Then
                _GUICtrlStatusBar_SetText ($hStatus, " " & "Send mail = " & "True", 2)
            Else
                   ;MsgBox(0,"","tEST")
                _GUICtrlStatusBar_SetText ($hStatus, " " & "Send mail = " & "False", 2)
            EndIf
            EndIf
    EndSelect
    WEnd
Edited by notta

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