Welcome Guest.   Make a donation to an author on the site October 30, 2014, 06:20:20 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Your Support Funds this Site: View the Supporter Yearbook.
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: Hide Gui Buttons previously created  (Read 2202 times)
justice
Supporting Member
**
Posts: 1,889



Solve issues simply.

View Profile WWW Give some DonationCredits to this forum member
« on: July 29, 2011, 07:37:35 AM »

In a loop I create a bunch of buttons with the following code:
Code:
Formatted for Autohotkey with the GeSHI Syntax Highlighter [copy or print]
  1. Gui, Add, Button, gButtonDestinationSelect HWNDButtonDestinationSelect%a_index%, %ButtonLabel%

Later on I want to hide/disable all these buttons using GuiControlGet, Hide but I'm not able to 'point' to these buttons, could anyone write a quick example?
Logged

skwire
Global Moderator
*****
Posts: 4,119



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #1 on: July 29, 2011, 08:06:47 AM »

GuiControlGet doesn't handle hiding/showing/disabling/enabling of buttons.  GuiControl does.  Consider this example:

Formatted for Autohotkey with the GeSHI Syntax Highlighter [copy or print]
  1. Loop, 6
  2. {
  3.    Gui, Add, Button, vmyButton%A_Index%, Click me
  4. }
  5.  
  6.  
  7. Sleep, 1500 ; Small delay to show form before changes.
  8.  
  9.  
  10. Loop, 6
  11. {
  12.    If ( Mod( A_Index, 2 ) = 1 ) ; Hide odd-numbered buttons.
  13.    {
  14.        GuiControl, Hide, myButton%A_Index%
  15.    }
  16.    Else ; Disable even-numbered buttons.
  17.    {
  18.        GuiControl, Disable, myButton%A_Index%
  19.    }
  20.    Sleep, 500 ; Small delay to show changes happening.
  21. }
  22.  
  23. Return ; End of auto-execute section.
  24.  
  25.  
  26. {
  27.    ExitApp
  28. }
Logged

justice
Supporting Member
**
Posts: 1,889



Solve issues simply.

View Profile WWW Give some DonationCredits to this forum member
« Reply #2 on: July 29, 2011, 08:09:15 AM »

Thanks, sorry that was lazy typing I meant GuiControl. However, my buttons to not have variables assigned to them for a specific reason I cannot remember why, is there a way to do it without?
Logged

skwire
Global Moderator
*****
Posts: 4,119



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #3 on: July 29, 2011, 08:26:58 AM »

In regards to GuiControl -- you have two choices if you don't have variable names assigned to the buttons.

  • You can use the "classname + instance number" combo.  Button1, Button2, etc.  I would advise against this method since that enumeration will change if you add other buttons before you add those looped buttons.
  • You can use the text of the button itself.  Obviously, the text would need to be unique for each button (which I don't think it is in your case).
Logged

justice
Supporting Member
**
Posts: 1,889



Solve issues simply.

View Profile WWW Give some DonationCredits to this forum member
« Reply #4 on: July 29, 2011, 08:30:18 AM »

Got it to work smiley Great.
Formatted for Autohotkey with the GeSHI Syntax Highlighter [copy or print]
  1. GuiControl,Enable,btn1%a_index%
  2. Gui, Add, Button, vbtn1%a_index%, %ButtonLabel%
  3. {
  4. GuiControl,Text,btn1%a_index%,%ButtonLabel%
  5. GuiControl,Show,btn1%a_index%
  6. }
I'm still not sure why I removed the variables initially, so will do serious testing.. Thanks so much skwire smiley sometimes  AHK just lacks a simple example.
Logged

Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.076s | Server load: 0 ]