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

Considered using WinWaitClose?

Using that in IconEx.

;show modal
WinWaitClose, ahk_id %IconEx_hwnd% 
DllCall("EnableWindow", "uint", IconEx_prntHwnd, "uint", 1)
Winactivate, ahk_id %IconEx_prntHwnd%
return IconEx("result")

Posted Image

  • Guests
  • Last active:
  • Joined: --
Is there a way, besides using:

Attach(Window_2, "-")

to completely remove an ancor from a handle?

Cause what I;m trying to do is (Remove attach, resize control, then reattach):

;Windw_2 is a browser window embedded with COM, but that's not really important. Just think of it as a normal control.

Attach(Window_2, "-")

WinGetPos,,, Window_2_Width,, ahk_id %Window_2%
Window_2_Width += 210
WinMove, ahk_id %Window_2%,,0, 50, %Window_2_Width%
WinMove, ahk_id %Window_2%,,0, 50, %Window_2_Width%

Attach(Window_2, "w h")

It works great. However, sometimes when the window is maximized or restored, it seems it jumps between the original anchor and the new one.

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
You don't have to disable control for that. You do - thing when control is invisible (i.e. on different tab or just hidden).

You need to reset attach after resizing control programmatically or if you are changing attach definition for control.

So, if your GUI window containing control is hGui, then

Resize( window )
Attach(hGui)   ;reset hGUI

Posted Image

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
*** v1.1 ***
+ Works with AHK_L
Posted Image

ddk
  • Members
  • 43 posts
  • Last active: Oct 12 2010 11:03 PM
  • Joined: 28 Dec 2009
Hey majkinetor!
Can I 'attach' sub-window to the main-window? Like the sub-window stays in same place in the main-window, even the main-window would be moved or resized?

Wicked
  • Members
  • 504 posts
  • Last active: Nov 18 2018 02:17 AM
  • Joined: 07 Jun 2008

Hey majkinetor!
Can I 'attach' sub-window to the main-window? Like the sub-window stays in same place in the main-window, even the main-window would be moved or resized?

A child window in a parent window, yes. Just treat the children like GUI controls.

ddk
  • Members
  • 43 posts
  • Last active: Oct 12 2010 11:03 PM
  • Joined: 28 Dec 2009

Hey majkinetor!
Can I 'attach' sub-window to the main-window? Like the sub-window stays in same place in the main-window, even the main-window would be moved or resized?

A child window in a parent window, yes. Just treat the children like GUI controls.

Thank you for a quick answer :)

hughman
  • Members
  • 192 posts
  • Last active: Feb 14 2016 06:59 AM
  • Joined: 11 Feb 2007
In ahk_l, Up-Down control of Tab can't be displayed when attach it. attach Also, scrol bar can't be displayed when attach treeview or other control.

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
sample ?
Posted Image

hughman
  • Members
  • 192 posts
  • Last active: Feb 14 2016 06:59 AM
  • Joined: 11 Feb 2007
I have found the reason. It's caused by a skin plugin named skin sharp, which is the most perfect skin plugin for ahk I can find.
But if I disable attach, it's normal too. So attach conficts with skinsharp.

Mystiq
  • Members
  • 83 posts
  • Last active: Nov 06 2011 07:07 PM
  • Joined: 08 Jan 2007

*** v1.1 ***
+ Works with AHK_L


Thanks!

Lucid_Method
  • Members
  • 147 posts
  • Last active: Dec 06 2014 08:39 AM
  • Joined: 19 Apr 2010
Does attach work with the statusbar? I've tried and haven't had any luck so far getting the statusbar parts to scale

Gui, Add, Button, x56 y47 w150 h50 hwndHandle1 vButton_1, Button
Gui, Add, Button, x66 y137 w200 h40 hwndHandle2 vButton_2, Button
Gui, Show, x131 y91 h377 w477, New GUI Window
Gui, Add, StatusBar, hwndStatusBarHwnd, 
SB_SetParts(200, 500)
Gosub SetAttach ;Used by Attach to Resize Gui
Return

SetAttach:  
Attach("OnAttach")
AttachResize = p r2

;Define Handles to Attach To 
Attach(Handle1, AttachResize)
Attach(Handle2, AttachResize)
Attach(StatusBarHwnd, AttachResize)
Return


Posted Image
Macro Everything
Lucid_Method Index

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
No, it resizes itself on its own.

You don't need Attach("OnAttach") in your sample.
Posted Image

DataLife
  • Members
  • 1022 posts
  • Last active: Nov 27 2015 01:09 AM
  • Joined: 27 Apr 2008

You don't have to disable control for that. You do - thing when control is invisible (i.e. on different tab or just hidden).

You need to reset attach after resizing control programmatically or if you are changing attach definition for control.

So, if your GUI window containing control is hGui, then

Resize( window )
Attach(hGui)   ;reset hGUI


I have the same problem. When I resize my control programmatically, Attach always remembers the original size. I am trying to reset Attach using your example here.

Here is my code using winxp images in the c:\windows folder.
#Include Attach.ahk
 gui, Add, Picture, hwndHandle1 w-1 h200, c:\windows\greenstone.bmp
 gui, Add, Button, x15  y300 w100 h40 +BS_Center 0x300 hwndHandle2, Resize Image
 Gui,+Resize
 gui, show, x100 y100 w400 h400,Example Gui
 Gosub SetAttach
 return 
 
buttonResizeImage:  
guicontrol,,static1, *w100 *h-1 c:\windows\Rhododendron.bmp ;change picture and resize
Attach(hGui)   ;reset hGUI
return
 
SetAttach:  ;Used to Resize GUI
 {
  Attach("OnAttach")
  RT = p r2
  Attach(Handle1, RT)
  Attach(Handle2, RT)
  Return
 }

guiclose:
guiescape:
ExitApp
What am I doing wrong.
Thanks
Datalife

Edit: I found my mistake.
The hGui in Attach(hGui) is actually the hwnd of the Gui that control is in.
Check out my scripts.  (MyIpChanger) (XPSnap) (SavePictureAs) All my scripts are tested on Windows 7, AutoHotkey 32 bit Ansi unless otherwise stated.

DataLife
  • Members
  • 1022 posts
  • Last active: Nov 27 2015 01:09 AM
  • Joined: 27 Apr 2008
How can I get Attach.ahk to resize my text control

My code below does not resize the text. It does resize the button. The ControlGetPos shows the width and height of the text changing but the text never changes. Is this a redraw problem?
#Include Attach.ahk
Gui 1: font, s14, MS sans serif
Gui 1: Add, Text,HwndHandle1 , Attach ahk does not resize text controls
Gui 1: Add, Button,HwndHandle2, Demo
Gui 1: +Resize
Gui 1: show, AutoSize, Need to resize text
Gosub SetAttach
Return

SetAttach:
Attach("OnAttach")
Attach(Handle1, "w.5 h1/3 r2")
Attach(Handle2, "p r2")
Return


GuiClose:
GuiEscape:
ExitApp

GuiSize:
ControlGetPos,,,w,h,,ahk_id %Handle1%
traytip,, Text Width %w%`nText Height %h%
return
thanks
DataLife
Check out my scripts.  (MyIpChanger) (XPSnap) (SavePictureAs) All my scripts are tested on Windows 7, AutoHotkey 32 bit Ansi unless otherwise stated.