AutoHotkey Community

It is currently May 27th, 2012, 12:41 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: September 7th, 2005, 10:01 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
Hi,

My wish is to extend the GuiControl, Enable/Disable to accept a variable with 0 or 1, like Gui,Add,Control,Disabled%Var%

Since I have the following lines multiple times in my script:
Code:
  If ChkDrawGoldenCut
    {
      GuiControl, 2:Enable , CobGoldenCutColor
      GuiControl, 2:Enable , CobGoldenCutStyle
    }
  Else
    {
      GuiControl, 2:Disable , CobGoldenCutColor
      GuiControl, 2:Disable , CobGoldenCutStyle
    }


And they could be as simple as this:
Code:
  GuiControl, 2:Enable%ChkDrawGoldenCut% , CobGoldenCutColor
  GuiControl, 2:Enable%ChkDrawGoldenCut% , CobGoldenCutStyle

or this
Code:
  GuiControl, 2:Disable%ChkDrawGoldenCut% , CobGoldenCutColor
  GuiControl, 2:Disable%ChkDrawGoldenCut% , CobGoldenCutStyle


Thus, saving lines of code 5 times (10 against 2).
Thus, avoiding typos and cleaning/simplifying the code structure

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 7th, 2005, 1:30 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
This is a good improvement; thanks for demonstrating its usefulness. I'll also do it for "GuiControl Hide/Show".

This change will be in the next update. Edit: It has been added in v1.0.38.02.


Last edited by Chris on September 8th, 2005, 4:18 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 7th, 2005, 2:55 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
I do not want to strech it too much, but is it possible, to also add
Gui,Add,Control,Enabled%Var%

Out of consitency and because it would save us the need to negate a status var

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 7th, 2005, 3:29 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
I see your point, but I think it's a little too obscure. Besides, you won't have to invert the variable if you use "Disable" in both. For example:

SubmitIsDisabled := true
Gui, Add, Button, Disabled%SubmitIsDisabled%, Submit
...
GuiControl, Disable%SubmitIsDisabled%, Submit


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 7th, 2005, 3:41 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
The thing is that I can't toggle on the "gui,Add" part the result as I can on the "GuiControl" with En/Dis-able.
Or could I use +/-, I never tried? If so, forget the stuff below.

Assume I have a var that is true. But I want to enable the control.
Since "Gui,Add" only has a "Disabled" and no "Enabled" I can't do it I have to negate the var to do it

Code:
var_neg := not var
Gui,Add,Control, Disabled%var_neg%

To have the syntax consistent I would appreciate to only write
Code:
Gui,Add,Control, Enabled%var%

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 7th, 2005, 3:46 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
Sorry, my bad,

I tried and it works with
Gui, Add, Control, -Disabled%var%

I didn't remember the +/- thing that can be left out, since it assumes +.
I got confused that the GuiControl has En/Dis-able but Gui hasn't.

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 7th, 2005, 3:50 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
I forgot about the ability to have a minus prefix too. Thanks for making it all clear now!


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 9 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group