Sign in to follow this  
Followers 0
am632

Disabling a group

3 posts in this topic

Hi,

Just a small problem I would like to know is how do you disable a group and its contents?

Here is my code,

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 523, 220, 192, 124)
GUISetState(@SW_SHOW)
$Group1 = GUICtrlCreateGroup("Group1", 32, 24, 193, 129)
$Radio1 = GUICtrlCreateRadio("Radio1", 64, 56, 113, 17)
$Radio2 = GUICtrlCreateRadio("Radio2", 64, 80, 113, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Group2", 288, 24, 193, 129)
$Radio3 = GUICtrlCreateRadio("Radio3", 320, 56, 113, 17)
$Radio4 = GUICtrlCreateRadio("Radio4", 320, 80, 113, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetState($Group2,@SW_DISABLE)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
WEnd

I thought it was just the 'GUICtrlSetState($Group2,@SW_DISABLE)' but its not doing anything. Id like the group to be grayed out as default which I can re-enable later in the script as necessary.

Thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

The Group in the above example is just a control, it doesn't actually group the controls under it the way you are thinking. It does group the radio buttons contained within it, but you can't disable them all at the same time by disabling the group control. You have to disable all of the controls individually, one at a time.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 523, 220, 192, 124)
GUISetState(@SW_SHOW)
$Group1 = GUICtrlCreateGroup("Group1", 32, 24, 193, 129)
$Radio1 = GUICtrlCreateRadio("Radio1", 64, 56, 113, 17)
$Radio2 = GUICtrlCreateRadio("Radio2", 64, 80, 113, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Group2", 288, 24, 193, 129)
$Radio3 = GUICtrlCreateRadio("Radio3", 320, 56, 113, 17)
$Radio4 = GUICtrlCreateRadio("Radio4", 320, 80, 113, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
;~ GUICtrlSetState($Group2,@SW_DISABLE)
For $I = $Radio1 To $Radio2
    GUICtrlSetState($I, $GUI_DISABLE) ; $GUI_DISABLE is needed to disable the control
Next

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
WEnd

EDIT: Want to clarify something. I used the controlIDs in the For/Next loop the way I did because they're created in sequence, if there were other controls in between these radio buttons, I'd have to do it another way.

Edited by BrewManNH

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

ah right I see, thanks v much for your help

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