 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Invalid User
Joined: 14 Feb 2005 Posts: 442 Location: Texas, Usa
|
Posted: Fri Mar 18, 2005 8:34 pm Post subject: Gui/Control delete |
|
|
Hmmm, GuiControl, Delete, Control
And... ControlDelete
These seem like fine editions for anyone who gets mad at a control and wished to rid their world of it.
Each of these would make it possible to create an engine that creates millions of controls as long as they are deleted after there use is no longer needed, Or simply deleting the pic control rather than replacing it with a nonexisting file or resizing it. why not get rid of it all together, that is if it can be done. _________________ my lame sig  |
|
| Back to top |
|
 |
JSLover
Joined: 20 Dec 2004 Posts: 541 Location: LooseChange911.com... the WTC attacks were done by the US Gov't... the official story is a lie...
|
Posted: Sat Mar 19, 2005 12:19 am Post subject: Re: Gui/Control delete |
|
|
I'm always in favor of new direct commands...but it is possible...
DeleteControl.ahk...
| Code: | Gui, Add, Text, w300, Use Window Spy && hover over each button, see Button1 2 && 3, press Delete Me, then hover again...Delete Me was really deleted.
Gui, Add, Button, section, Test
Gui, Add, Button, ys, Delete Me
Gui, Add, Button, ys, Keep Me
Gui, Show ;, w300 h100 ;, AutoSize
WM_CLOSE=0x10
return
ButtonDeleteMe:
PostMessage, %WM_CLOSE%, , , Delete Me
return
GuiClose:
ExitApp |
_________________
Home • Click image! • Blog |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5390 Location: /b/
|
Posted: Sat Mar 19, 2005 12:22 am Post subject: |
|
|
Showing/Hiding controls could be used instead of deleting [GuiControl, Hide, (...)]. _________________
 |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Sat Mar 19, 2005 2:16 am Post subject: Re: Gui/Control delete |
|
|
| Invalid User wrote: | Hmmm, GuiControl, Delete, Control
And... ControlDelete | Although it sounds good in theory, real-world uses for it seem extremely rare. Because of this -- as well as the fact that it would add considerable complexity to the design (which might reduce performance) -- I've given it a low priority.
If anyone can think of legitimate/practical uses for this that can't be achieved with "GuiControl Hide", please post them here. |
|
| Back to top |
|
 |
JSLover
Joined: 20 Dec 2004 Posts: 541 Location: LooseChange911.com... the WTC attacks were done by the US Gov't... the official story is a lie...
|
Posted: Sat Mar 19, 2005 3:19 am Post subject: Re: Gui/Control delete |
|
|
...did no one see my post above...about it *currently being possible* to delete controls?...
| Chris wrote: | | as well as the fact that it would add considerable complexity to the design |
...what's complex about having a ControlDelete command do the same thing as the PostMessage, WM_CLOSE...or just have the command close the control's window directly, like a WinClose?
| Chris wrote: | | If anyone can think of legitimate/practical uses for this that can't be achieved with "GuiControl Hide", please post them here. |
...hiding a control doesn't release the memory used for it to exist & a loop creating controls will reach the 11K limit. & trying to keep track & re-show & re-purpose existing controls would be tedious. _________________
Home • Click image! • Blog |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Sat Mar 19, 2005 6:14 pm Post subject: Re: Gui/Control delete |
|
|
| JSLover wrote: | | ...what's complex about having a ControlDelete command do the same thing as the PostMessage, WM_CLOSE | That method is useful, but it doesn't actually cause the control to be internally deleted: it's still present in the array of controls, and thus it permanently consumes one position even after it's gone.
| Quote: | | ...hiding a control doesn't release the memory used for it to exist | True, but most controls take up very little memory. Large controls such as Edits seldom need to be destroyed, and they can be emptied via "GuiControl,, MyEdit" to free most of their memory.
| Quote: | | a loop creating controls will reach the 11K limit | Do you have a script in mind that needs to do this? If so, perhaps you could give a general description of what it does.
| Quote: | | trying to keep track & re-show & re-purpose existing controls would be tedious. | I still can't visualize why a script would need to continuously add new controls. I'm not saying it's never needed, just that the need is rare enough to justify making "GuiControl, Delete" a low priority.
As you probably know, you can also use "Gui Destroy" to reset a window to having zero controls.
Thanks for your comments. More are welcome. |
|
| Back to top |
|
 |
sosaited
Joined: 24 Feb 2005 Posts: 233
|
Posted: Sat Mar 19, 2005 9:36 pm Post subject: |
|
|
hi ..
If i need to make a Gui starting with some text (welcome message, setc) and one button( start) and then after the user presses the button .. the current controls get deleted and (ony by one.. or line by line-so it'll look good).. and then then the remainign controls appear...
as i am new in AHK.. so if this is possible with Control hide.. i am sorry for sending this post.,.. but when u Hide a control.. and ANOTHER CONTROL HAS TO APPEAR ON THE SAME PLACE (or something like that) what will happen?.. Control Delete.. can be useful..
thanks |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Sun Mar 20, 2005 3:02 am Post subject: |
|
|
| sosaited wrote: | | when u Hide a control.. and ANOTHER CONTROL HAS TO APPEAR ON THE SAME PLACE (or something like that) what will happen? | It should be fine because hidden controls are very close to nonexistent from the point of view of the user and the parent window. |
|
| Back to top |
|
 |
Invalid User
Joined: 14 Feb 2005 Posts: 442 Location: Texas, Usa
|
Posted: Sun Mar 20, 2005 8:22 am Post subject: |
|
|
so in the end this command will never happen, so in my case I will have to create a system for recycling the controls for tetris, It shouldnt be too hard, _________________ my lame sig  |
|
| Back to top |
|
 |
JSLover
Joined: 20 Dec 2004 Posts: 541 Location: LooseChange911.com... the WTC attacks were done by the US Gov't... the official story is a lie...
|
Posted: Sun Mar 20, 2005 10:19 am Post subject: Re: Gui/Control delete |
|
|
| Chris wrote: | | it's still present in the array of controls |
...what array? I used Window Spy & it appeared to be gone, before delete "Delete Me" was Static2, after delete "Keep Me" was Static2...so I figured it was gone, for real...would WM_DESTROY or another message destroy it more? I used this "deleting" technique in a script to run a program & delete a few buttons so the person couldn't click on them...I tried hiding the buttons but the Alt+Underlined-letter shortcut still worked...using my delete, the shortcut didn't work, which is what I needed, *no* way to "click" that button.
| Chris wrote: | | True, but most controls take up very little memory. |
...yes, but however "little" there is an 11K limit, so all that "little" adds up.
| Chris wrote: | | Do you have a script in mind that needs to do this? If so, perhaps you could give a general description of what it does. |
...not me, I think it's IU & niwi with the Tetris scripts, creating a bunch of controls to be the Tetris blocks. Keeping an array of the "current" controls & renaming (er um, there are no words on Tetris blocks, so um, re-coloring) & re-positioning the controls, instead of just deleting, seems hard to me. Does posting that message free it up enough to get past the 11K limit?...or just make it "seem gone"?
| Chris wrote: | | I'm not saying it's never needed, just that the need is rare enough to justify making "GuiControl, Delete" a low priority. |
...I'm not sure what you're thinking a "GuiControl, Delete" would have to do...perhaps your answer to the above "what array" will help me see where you are in thinking of what the "Delete" would really need to do.
| Chris wrote: | | As you probably know, you can also use "Gui Destroy" to reset a window to having zero controls. |
...that would make the Tetris window flicker. Perhaps 2 Gui windows...when one gets near-full, create another with only the "current contents", show the new, Gui Destroy the old, then when the new one gets near-full...transition back...??? _________________
Home • Click image! • Blog |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Sun Mar 20, 2005 8:54 pm Post subject: Re: Gui/Control delete |
|
|
First of all, I admit that I didn't realize this request was related to the Tetris scripts (though I probably should have guessed )
| JSLover wrote: | what array? I used Window Spy & it appeared to be gone...
Does posting that message free it up enough to get past the 11K limit?...or just make it "seem gone"? | AutoHotkey maintains an array internally for each GUI window. The array initially contains room for 1000 items but grows if more are needed (up to 11,000 max). When you use a technique such as WM_CLOSE on a control, that might indeed destroy it from a resources/memory point of view. However, the control will still exist in the internal array, taking up a slot, because AutoHotkey is not notified of the control's closure/destruction.
| Quote: | | would WM_DESTROY or another message destroy it more? | I don't know. I'm unfamiliar with this technique of closing/destroying controls (though I'm glad it does what you need it to do).
| Quote: | | I tried hiding the buttons but the Alt+Underlined-letter shortcut still worked...using my delete, the shortcut didn't work, which is what I needed, *no* way to "click" that button. | Thanks for this good info, which I will add to the docs. It turns out that "GuiControl Disable" in conjunction with "GuiControl Hide" will prevent a control's shortcut key (underlined letter) from working.
| Quote: | | ...I'm not sure what you're thinking a "GuiControl, Delete" would have to do...perhaps your answer to the above "what array" will help me see... | To delete a control completely, the current high-performance array approach would probably have to be replaced with something more flexible. One reason for this is the current approach relies on the fact that a control's OS ID number is the same as its array index. This allows control operations to run at maximum speed because no lookup/search is required to find a control in the array. |
|
| Back to top |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2436
|
Posted: Sun Mar 20, 2005 9:14 pm Post subject: |
|
|
Here's an example that may demonstrate a few of the current issues with using the PostMessage method of deleting a control:
| Code: | ; Generated using SmartGUI Creator 3.4
Gui, Add, Text, x16 y10 w80 h30 vT1, 1 - off
Gui, Add, Text, x106 y10 w80 h30 vT2, 2 - off
Gui, Add, Text, x196 y10 w80 h30 vT3, 3 - off
Gui, Add, Text, x286 y10 w80 h30 vT4, 4 - off
Gui, Add, Button, x16 y60 w80 h30 gBT1, 1 - on/off
Gui, Add, Button, x106 y60 w80 h30 gBT2, 2 - on/off
Gui, Add, Button, x196 y60 w80 h30 gBT3, 3 - on/off
Gui, Add, Button, x286 y60 w80 h30 gBT4, 4 - on/off
Gui, Add, Edit, x186 y100 w60 h30 vDelC, 1
Gui, Add, Button, x86 y100 w100 h30 gConDel, Delete
Gui, Add, Edit, x186 y130 w60 h30 vAddC, 1
Gui, Add, Button, x86 y130 w100 h30 gConAdd, Create
Gui, Show, x398 y110 h179 w388, Delete Control Test
WM_CLOSE=0x10
T1 = 1 - off
T2 = 2 - off
T3 = 3 - off
T4 = 4 - off
Return
; ***********************
BT1:
Gui, Submit, NoHide
if T1 =
Return
if T1 = 1 - on
{
T1 = 1 - off
}
else
{
T1 = 1 - on
}
GuiControl,, T1, %T1%
Return
; ***********************
BT2:
Gui, Submit, NoHide
if T2 =
Return
if T2 = 2 - on
T2 = 2 - off
else
T2 = 2 - on
GuiControl,, T2, %T2%
Return
; ***********************
BT3:
Gui, Submit, NoHide
if T3 =
Return
if T3 = 3 - on
T3 = 3 - off
else
T3 = 3 - on
GuiControl,, T3, %T3%
Return
; ***********************
BT4:
Gui, Submit, NoHide
if T4 =
Return
if T4 = 4 - on
T4 = 4 - off
else
T4 = 4 - on
GuiControl,, T4, %T4%
Return
; ***********************
ConDel:
Gui, Submit, NoHide
DelControl =
if Delc = 1
{
DelControl = %T1%
T1 =
}
else if Delc = 2
{
DelControl = %T2%
T2 =
}
else if Delc = 3
{
DelControl = %T3%
T3 =
}
else if Delc = 4
{
DelControl = %T4%
T4 =
}
if DelControl =
{
}
else
{
PostMessage, %WM_CLOSE%, , , %DelControl%
}
Return
; ***********************
ConAdd:
Gui, Submit, NoHide
if AddC = 1
{
if T1=
{
Gui, Add, Text, x16 y10 w80 h30 vT1, 1 - off
T1 = 1 - off
MsgBox, Created Ok
}
else
{
MsgBox, Control not created
}
}
else if AddC = 2
{
if T2 =
{
Gui, Add, Text, x106 y10 w80 h30 vT2, 2 - off
T2 = 2 - off
MsgBox, Created Ok
}
else
{
MsgBox, Control not created
}
}
else if AddC = 3
{
if T3 =
{
Gui, Add, Text, x196 y10 w80 h30 vT3, 3 - off
T3 = 3 - off
MsgBox, Created Ok
}
else
{
MsgBox, Control not created
}
}
else if AddC = 4
{
if T4 =
{
Gui, Add, Text, x286 y10 w80 h30 vT4, 4 - off
T4 = 4 - off
MsgBox, Created Ok
}
else
{
MsgBox, Control not created
}
}
Return
GuiClose:
ExitApp
|
|
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Mon Mar 21, 2005 2:42 am Post subject: |
|
|
Yes, I would avoid "closing" a control if it causes any problems, because the program currently lacks any capability to handle this.
Instead, you could use the following to prevent a control's shortcut key from working:
GuiControl, Hide, &OK
GuiControl, Disable, &OK ; Prevent the Alt+O shortcut key from operating. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|