[Solved]GUI Control pos/size hide/disable, delete

Get help with using AutoHotkey and its commands and hotkeys
User avatar
RobertL
Posts: 540
Joined: 18 Jan 2014, 01:14
Location: China

[Solved]GUI Control pos/size hide/disable, delete

Post by RobertL » 27 Sep 2014, 05:48

  • Question:
    • When delete a head control which's position and size (and a margin) may be used to calculate the next one's position and size should update the previous one as new head.
    • If delete a control in the middle, user have to deal with the empty area themselves.
      But I hope there is some clue, like control chain contain create order.
    In code below, E2 was deleted, so it should be E1.
    Spoiler
  • Solved question:
    Spoiler
  • Possible solution with query:
    Spoiler
[/list]

Relative : GuiControl, Delete in Wish List, start by @trismarck, @lexikos, guest3456, me take part in.
Last edited by RobertL on 29 Sep 2014, 23:56, edited 9 times in total.
我为人人,人人为己?

Coco
Posts: 771
Joined: 29 Sep 2013, 20:37
GitHub: cocobelgica

Re: GUI. Control pos & size hide/disable, delete. PostVer1.6

Post by Coco » 27 Sep 2014, 08:59

Use xp yp wp hp, E3 will use E2's position

User avatar
RobertL
Posts: 540
Joined: 18 Jan 2014, 01:14
Location: China

Re: GUI. Control pos & size hide/disable, delete. PostVer1.6

Post by RobertL » 27 Sep 2014, 09:52

@Coco Haha, not reach the goal.

Code: Select all

Gui, Add, Edit , vE1 w100, E1
	GuiControl, Hide, E1
	GuiControl, Disable, E1
Gui, Add, Edit , vE2, E2
	GuiControl, Hide, E2
	GuiControl, Disable, E2
Gui, Add, Edit , vE3 w100, E3
Gui, Show
return
So, how to make E3's position to E1?
This is mainly talk about dynamic delete and create.
The solution above seems a way..
我为人人,人人为己?

lexikos
Posts: 7189
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: GUI. Control pos & size hide/disable, delete. PostVer1.6

Post by lexikos » 27 Sep 2014, 23:11

Use GuiControlGet Pos.

User avatar
RobertL
Posts: 540
Joined: 18 Jan 2014, 01:14
Location: China

Re: lexikos

Post by RobertL » 28 Sep 2014, 00:06

@lexikos
Sorry, it seems not help much.
You mean to keep tracing every control, especially when hide/disable them?
If you're in a good humor, please take a look at query in Possible solution(3rd item in list above).
Thanks for your suggestion.
我为人人,人人为己?

lexikos
Posts: 7189
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: [OPEN]GUI Control pos/size hide/disable, delete. PostVer

Post by lexikos » 29 Sep 2014, 19:16

So, how to make E3's position to E1?
Get E1's position. Set E3's position. If this doesn't solve the problem, you're stating the problem incorrectly.

User avatar
RobertL
Posts: 540
Joined: 18 Jan 2014, 01:14
Location: China

Re: lexikos V1.5

Post by RobertL » 29 Sep 2014, 19:23

I wrote:In PostVer1.10 at top:
  • When delete a head control which's position and size (and a margin) may be used to calculate the next one's position and size should update the previous one as new head.
  • If delete a control in the middle, user have to deal with the empty area themselves.
    But I hope there is some clue, like control chain contain create order.
  • [spoiler2=Outdated content][quote="I"]I mean when I add a new control after GuiControl, Delete (GuiControl, Hide or DllCall("DestroyWindow", "UInt",..)) some one (like E2), how can I know the previous existed one (like E1)?
    Although the delete operation may break control relationship chain especially the head/last control from original status in creating.
    I was seeking the new head control which's position and size will be used to calculate the next one. E2 was deleted, so it should be E1.[/quote][/spoiler2]
I wrote:In Possible solution:
Spoiler
Currently, I think could record or traversal each control and get it's pos and size..
Is there a better way?
我为人人,人人为己?

lexikos
Posts: 7189
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: [OPEN]GUI Control pos/size hide/disable, delete. PostVer

Post by lexikos » 29 Sep 2014, 22:06

I think could record [...] each control and get it's pos and size..
That is the easiest and most reliable way. You know what the last control is because you created the controls. It only takes one line of code to append the control's HWND to an array. There's no need to record the position or size, since you can get it with one line of code.

User avatar
evilC
Posts: 4791
Joined: 27 Feb 2014, 12:30

Re: [Solved]GUI Control pos/size hide/disable, delete

Post by evilC » 30 Sep 2014, 06:50

If you create a child GUI for each control that you wish to be able to delete, you can properly remove the control by closing the GUI.

You can also use a ?deferwindowpos? DLL call to move all the GUI controls below the deleted control in one go, thus avoiding excessive drawing time to re-position all the controls.

User avatar
RobertL
Posts: 540
Joined: 18 Jan 2014, 01:14
Location: China

Re: evilC

Post by RobertL » 30 Sep 2014, 09:37

evilC wrote:create a child GUI for each control that you wish to be able to delete
Nice idea, use a GUI window to delegate control(s).
Trade performance for flexibility.
evilC wrote:all the GUI controls below the deleted control
I will look over deferwindowpos what is below mean..when needed.
Thanks~
我为人人,人人为己?

Post Reply

Return to “Ask For Help”