Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[function] Attach 1.1


  • Please log in to reply
62 replies to this topic
majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
NOTE: Latest Attach is in the Formsframework.

A t t a c h
Determines how a control is resized with its parent.



Download          Documentation




Thread Highglihts
[*:36ptocs2] Difference between Anchor and Attach
Posted Image

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Cool 8)

Thank you very much ;)

toralf n-l-i
  • Guests
  • Last active:
  • Joined: --
Hi majkinetor,

That looks interesting. What are the advantages over Anchor()?

regards
toralf

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
Hey mate, good to see you again here.

What are the advantages over Anchor()?

- It can correctly reset , which was one of the reasons to do it.
- It can work with container controls so it allows for kind of multidimensional anchoring. When I release Panel control you will be able to use this function to attach controls inside it.
- It has p parameter for proportional following.
- It has delayed redrawing (r2).
- Its faster, especially with larger number of controls as it always sets things in 1 function call, it cashes dll call entry points, use "assume static" instead NumGet/Put for storage etc...
- You can enable/disable function for control. This can be used, for instance, for invisible controls so they are not being attached while in hidden state.
- Different modules can use it simultaneously as it doesn't require GuiSize to be set.
- Designed for highly dynamic window scenarios in mind.

- On the minus side, you can't feed controls AHK names, only handles are supported (intentiously tho, I mostly don't use control names as they are global)
Posted Image

n-l-i-d
  • Guests
  • Last active:
  • Joined: --
majkinetor is on a coding spree!

8)

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
I am actually polishing my previuosly unreleased work, inspired by recent AHK changes made mostly by Lexikos.

Expect many more goodies soon.
Posted Image

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
Looks like another winner. Thanks. 8)

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
Small bug with reseting of disabled hidden controls fixed.
Please re-download.
Posted Image

freakkk
  • Members
  • 182 posts
  • Last active: Dec 16 2014 06:23 PM
  • Joined: 29 Jul 2005

majkinetor is on a coding spree!

I am actually polishing my previuosly unreleased work, inspired by recent AHK changes made mostly by Lexikos. 

F*ing A!! 8)

When I release Panel control you will be able to use this function to attach controls inside it. 

Expect many more goodies soon.

I can't wait!   :D

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
*** version 1.01 ***
! Fix for reset on non-triggered WM_SIZE on Gui, Show when it was preceded by Gui, Show, Hide without autosize.


This fix is required when using controls that require window dimensions to be set in advance (Toolbar, Rebar..) or in any other scenario that requires that, and you later showed the window using simply Gui, Show without using Autosize. Example:

	Gui, +LastFounds +Resize
	hGui := WinExist()

	Gui, Show, w400 h500 Hide

	Gui, Add, Edit, HWNDhEdt1,
	Gui, Add, Button, HWNDhBtn1, Top
	Gui, Add, Button, HWNDhBtn2, Bottom
	Gui, Add, MonthCal, HWNDhCal

	Align(hEdt1, "Left")
	Align(hBtn1, "Top")
	Align(hBtn2, "Bottom")
	Align(hCal,   "Fill")

	Attach(hEdt1, "h")
	Attach(hBtn1, "w")
	Attach(hCal,  "w h")
	Attach(hBtn2, "y w")

	Gui, Show    ; , Autosize
return

F1::
	WinHide, ahk_id %hBtn2%
	WinHide, ahk_id %hEdt1%	
	Align(hGui)	;re-align
 	Attach()		;reset attach
return


This code first creates Gui , then adds controls, then calls the function that allign controls to the window (so it reqiures to know window size) then it shows the Gui without autosize.

Unless you specify autosize, last Gui, Show never triggers WM_SIZE message (and consequently, Attach fails to initialize window size)

This is not the problem unless you immediately reset Gui without changing the placement of the window (rare situation, but again, bug). If you resizesd window previously it would work. So above code would scramble controls if you pressed F1 on startup.
Posted Image

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
*** version 1.02 ***
! Resetting before adding any control would make function unusable.
Posted Image

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
*** version 1.04 ****
+ "-" can now be used in attach definition string to set-up control as initially disabled.
* "p" now doesn't have to be used as the first option.
! Bugfix for container controls. "Attach_" can be used now as WM_SIZE handler for any control that need to attach its children.
! Small bugfix with reseting.
Posted Image

hughman
  • Members
  • 192 posts
  • Last active: Feb 14 2016 06:59 AM
  • Joined: 11 Feb 2007

When I release Panel control you will be able to use this function to attach controls inside it.


wow, I want to know when you release Panel control. I long for it all the time.

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
The control is already developed. I'll release it when I finish all the tests I have in mind (which is quite a lot, so it will take some time).
Posted Image

  • Guests
  • Last active:
  • Joined: --
Pardon my ignorance, but I've been trying a while and I'm not the best at this sort of thing.

I'm trying to use this to Attach an emeded Firefox. I'm looking to replace what I used to use: Anchor("AtlAxWin1", "wh").

PWB := COM_AtlAxGetControl(COM_AtlAxCreateContainer(Gui_1_ID, 0, 25, 870, 375, "Mozilla.Browser"))

I've tried to get the HWND of the embedded Firefox using:
ControlGet, Handle, Hwnd,, AtlAxWin1, Example_Window
ControlGet, Handle, Hwnd,, PWB, Example_Window
... Etc. Like I said, pardon my ignorance.

Thank you for your time.