Jump to content
Sign in to follow this  
tommytx

How to make sure all the check box changes are credited everywhere.

Recommended Posts

tommytx

When I click a radio box on the main gui panel, not all areas are notified... Is there an easy way to do its..

For example like I am familiar with the html thingy like onchange() go out and notify all these folks.. but not sure if there is an easy way to make the program do some subroutines when I click a radio box to make a change.... any help would be appreciated.. I show one example in item 2 of some of the parts of the program that need to be notified of the radio button change.... Thanks

When I click any of the below radio buttons, the others auto uncheck... but I an not sure how to generate a onchange so that any click on a radio button fires off several subroutines to make sure the rest of the program is up to speed...for example the title line needs to change along with several other items.

Item 1:
$rob = GUICtrlCreateRadio("Rob", 175, 5, 40, 20)
$man = GUICtrlCreateRadio("Man", 225, 5, 40, 20)
GUICtrlSetState(-1, 1)  ; checked
$pi = GUICtrlCreateRadio("Pi", 275, 5, 40, 20)
; GUICtrlSetState(-1, 1)  ; checked

Item 2:
_IEPropertySet ($oIE1, "title", $mytitle & " " & $cntdn)
  WinSetTitle($hGUI, "",$mytitle & " " & $cntdn)

Share this post


Link to post
Share on other sites
Spiff59

I'm a little confused what you're asking.

Clicking on a radio button causes a message event like other controls that you can monitor with a GUIGetMsg() loop.

I'll sometimes lump a bunch of contiguous buttons together to be processed by a single subfunction, rather than create separate "Case" phrases and separate subfunctions for each button.

GUICreate("", 400,200)
$rob = GUICtrlCreateRadio("Rob", 175, 5, 40, 20)
$man = GUICtrlCreateRadio("Man", 225, 5, 40, 20)
GUICtrlSetState(-1, 1)  ; checked
$pi = GUICtrlCreateRadio("Pi", 275, 5, 40, 20)
; GUICtrlSetState(-1, 1)  ; checked
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = -3 then ExitLoop
    Switch $msg
        Case $rob to $pi
            Process_Changes($msg - $rob + 1)
;      Case $whatever
    EndSwitch
WEnd

Func Process_Changes($button)
    MsgBox("",0,"Doing what I do for button " & $button)
EndFunc

Share this post


Link to post
Share on other sites
tommytx

Let me give an example of what I mean... maybe that will help....I have many items throught the program that need update when a button changes... as you can see before so I am thinking about a command like on change.. meaning if the button selections are changed automatically do 1 or 2 subs that need to be updated...

Like for example when i hit the button man changing from manual to say Pi for Phillippines...

I need to update items such as below...

$decapman = "tommytx" when man is chosen... but

$decapman = "Phillippines" when the Pi radio button is checked...

Those do not change when I tick or untick the radio button so I need something that auto runs around and does the subs of choice when I tick or untick a button... with html they call it onchange for example = submit.... do something.... big...

Func guiread()
GUISetState()
$sPi =  GUICtrlRead($pi)
$sMan = GUICtrlRead($man)
$sDe = GUICtrlRead($de)
EndFunc
Func settitle()
guiread()
if $sMan = 1 then
$mytitle = "Manual Mode " & $botnr
$decapman = "Tommytx"
EndIf
WinSetTitle($hGUI, "", $mytitle)
if $sPi = 1 then
$mytitle = "PI Mode " & $botnr
$dcapman = "Phillippines"
EndIf

WinSetTitle($hGUI, "", $mytitle)
if $sDe = 1 then
$mytitle = "Death Mode " & $botnr
$decapman = "Death By Capture"
EndIf
WinSetTitle($hGUI, "", $mytitle)
EndFunc

Share this post


Link to post
Share on other sites
Mechaflash

need more code sir.

The whole GUI loop as well as the functions in question.


Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites
tommytx

Bottom line it would be helpful to know if there is a way to trigger a sub run anytiime a radio box changes...

For example if I have radio1 , radio2 and radio3... I want to do a sub any time one of the radio boxes changes state...

On html its like onchange('dowork()') etc.... does autoit have anything monitoring a state change of a radio button.

Share this post


Link to post
Share on other sites
BrewManNH

GUIGetMsg in a message loop or GUICtrlOnEvent when using OnEvent mode will read the state of a control, and you can have your program do certain things depending upon whether the radio button is "checked" or "unchecked".


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Mechaflash

since you don't want to provide the code...

as BrewManNH said... your GUI case items should be in a loop (normally While 1). While your GUI is active, you can use

If GUICtrlRead($checkbox) = $GUI_CHECKED (or) $GUI_UNCHECKED Then [...]
in your switch/case.

If you need to set a constant throughout the script even if the GUI is gone, create a bool variable like

If GUICtrlRead($checkbox) = $GUI_CHECKED Then
  $fCheckbox = True
Else
  $fCheckbox = False
EndIf
Edited by mechaflash213

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites
tommytx

I think that is what I need is to set up the radio buttons on the while loop and put all the routines i need to run there so they all get done on any radio button change.. thanks for all the ideas..

Share this post


Link to post
Share on other sites
Newb

maybe it's just a stupid advice and I didn't even read the code, but why not set a global variable which gets changed along with the change of the state of your control and make a separate function, let's call it UpdateControls(), which gets called on your needs which updates all you controls?

I didn't read any reply up here but i guess some of the expert coder already thought of this.

If the variable is like a checkbox you can do it with a boolean true/false

If it has more than 2 states you can do with a numeric variable like 1,2,3,4.... for every state

Just make some good loops to check the gui state and put them in a function and run it when you want the gui to update to make it update whole gui or controls


I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

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  

×