AutoHotkey Community

It is currently May 25th, 2012, 5:49 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 352 posts ]  Go to page 1, 2, 3, 4, 5 ... 24  Next
Author Message
PostPosted: May 21st, 2007, 4:00 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
    D o c k
    Dock desired top level windows (dock clients) to any top level window (dock host)

    Download                 Documentation

     
      Image



    Example
    Code:
    Run notepad,,,nPID
       WinWait ahk_pid %nPID%
       Dock_HostID := WinExist("ahk_pid " . nPID)

       Gui +LastFound -Caption +ToolWindow +Border
       Gui Add, Text,,Docked Window
       Gui Show

       Dock(WinExist(), "0,0,0,    0,-1,-5,    0,120,   0,30")      ; above, left, fixed width
    return

    #include Dock.ahk


    See also Title Button


    History
    v2.0 b3
    - Fixed bug with "working cursor" and T clients.
    - Removed "+" option. You should start dock with hidden windows, and Dock will show them after it positioned them correctly if they are hidden. So, Dock itself hides and shows the windows, you just need to Toggle it on once you set up the new host as it will still turn off when Host dies. To let the client be hidden, you must undock it. This is better anyway, as previously hidden clients were still aranged by the Dock, although they were invisible, so update was slower.

    v2.0 b2
    - Bug fix when host is alive in the moment of registration. Clients are now (hopefully) positioned correctly.

    v2.0 b1
    - Topmost clients reimplement. Now they work much faster. New example: _Bmcclure.ahk. It shows how to dock to the control. "Docking relative to the control" will be added in next version.

    v2.0 a5     Screenshot1 Screenshot 2

    - Dock definition alternative notation for shorter expressions
    - Optimisation & bug fixes
    - Dock definition changed to more clear notation. This intorduced some new docking shemes (X & Y class can be omitted now). See _Mini WIn.ahk & Roll.ahk
    - TopMost clients added as 11th parameter of dock definition. See help in the archive for details about topmost clients. This feature allows new dimension of docking as you can dock inside the Host. This also makes possible to create arbitrary number of title buttons (you can see that in one of the samples in the archive)

    1.0
    - Final version
    - Documentation updated (switched from mht to html, presets section added, dock defintion explained, remarks about topmost clients added, now available online)

    1.0 rc4
    - Activating client will now activate host. All in all, composite window now behaves like single window.

    1.0 rc3
    - Dock now also monitors SHOW and HIDE states of the Host (if DetectHiddenWindows is set). Furthermore, when Host terminates, all clients will be hidden from now on and you must explicitely show them if you re-enable dock with new Host. See _Test2.ahk for example.
    - Dock_HostDied removed from API. Dock now automaticaly Toggle's itself OFF when Host dies (and hides the clients)
    - New cool example added (set host and number of clients, can be used for mass client testing)
    - Some bugs fixed:
      Improper Z-order if Host was active in the time script was executing
      Toggle improved so it returns error when you try to enable already enabled dock

    1.0 rc2
    - New function - Dock_Toggle. Dock_Enabled removed for optimisation reason. Dock_Toggle makes suspended state of module 100% idle.

    1.0 rc1
    Bugfixes:
    - Removed "F" from RegisterCallback
    - If you call Dock again for the same client it will update previous settings
    - Shutdown will clean all internal data and module can be used again after shutdown is called.
    - WinSetDelay doesn't influence module anymore
    Addons:
    - New global, Dock_Enabled to temporary disable dock
    - Dock definition can now accept only X & Y parameters (first 6). W & H parameters can now be omited. Module will let the client keep its size. You can also omit only W or only H.
    - Dock definition can now be entirely omited. In that case client will be docked relatively to already running Dock_Host, i.e. it will keep the distance it had from the Host at the moment Dock was callled.
    - You can use "+" now when passing client's ID to make module show hidden client before docking it to the host.
    - New _Test.ahk, demonstrating all the things mentioned above.

    1.0 b2
    - wineventhook.dll removed

    1.0 b1
    - Added another 2 global variables Dock_OnHostDeath and Dock_HostDied. Set first one to subroutine to make engine call it when host dies. This routine is called only once and it will change global Dock_HostDied to true. If you want to switch the host you will have to reenable Dock_OnHostDeath by setting HostDied to 0.

    0.99
    - Multidock implemented
    - Dock syntax changed as of multidock feature
    - Optimisation, stripped version of script is less then 100 lines (no comments, empty lines etc..)

    0.96 - Another optimisation
    0.95 - Encapsulation.
    0.91 - New interface and optimisation (thx Laszlo)
    0.00 - Initial


Reference

Thank you
    JGR, Laszlo, Joy2DWorld, bmcclure
[/list]

_________________
Image


Last edited by majkinetor on January 14th, 2008, 11:27 am, edited 98 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2007, 4:11 pm 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2540
Cool. Very nice :) .

In your example it might help demonstrate if you add a Run, notepad line. Also, could you have the script close once the notepad window that it docks to is closed?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2007, 4:20 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Yes, I will eventualy do everything like described in Dock wish.

- Hide/Show dock client with dock host. User handler when dockHost exits so you can terminate app or do other things.
- Expressions in sizeX and sizeY so you can say something like A_DockHostWidt//2

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2007, 4:55 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8647
Location: Salem, MA
Very nice script, majkinetor. I like the idea.

For others who read this thread, please note that AHK version 1.0.46.13+ is required.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2007, 5:07 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8647
Location: Salem, MA
The only other thing I could ask for is some way for the Dock Client to detect when it has been moved relative to it's docked position, as if it has (have the option to) remember the new Dock_dx and Dock_dy value.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2007, 5:35 pm 
Well, I created this so to show to Chris it is very easy to implement (counting hook dll)

However, I am planning to update this. One option I forgot is to dock based on child control in dock client. This is very useful in some situations. For instance, if you set the little gui to dock bellow Total Commander left Panel (TMyPanel3) the one can replace entire TC panel with its own GUI so it looks like QuickView of TC. I already demonstrated this in QuickView script, but using much more complex script.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2007, 8:11 pm 
Offline

Joined: July 29th, 2005, 5:32 pm
Posts: 179
This is excellent!! This is something i've sought after for quite some time w/ no satisfactory success. I suppose this provides a simple means for creating custom skins for gui's too! I'll be sure to keep my eyes glued to this post for any updates :D

Thanks majkinetor !!

_________________
.o0[ corey ]0o.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2007, 8:21 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
LOL


Create any GUI you like, you just need to pass its handle to the dock command.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2007, 8:32 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Very nice demo of a new toolset! However, you can have similar effects in much simpler way, so the real value of the hooks could be seen in more complex examples.
Code:
Gui -Caption +Border
Gui Show, x200 y50 w600 h500
WinGet gID, ID, %A_ScriptName%

Run notepad,,,nPID
WinWait ahk_pid %nPID%
WinMove ahk_pid %nPID%,,0, 0, 600, 300
WinGet nID, ID, ahk_pid %nPID%

DllCall("SetParent", UInt,nID, UInt,gID)
WinActivate ahk_id %gID%
WinActivate ahk_id %nID%
Here a larger Gui window is created and Notepad is docked to it with the SetParent dll call. The visible part of the Gui can have information texts, buttons, menus, etc.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2007, 8:58 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Well, I am sorry to dissapoint you, but that "method" is very bad (no offense, this is well known method for long time), and very limited. I already played with it a lot previously. It is also not documented as such on MSDN, it is buggy, and it has nothing to do with docking.

You also can't do any feature of Dock wish with it, u acctually pined Notepad inside your GUI, not your GUI aside Notepad. While you can easily do the oposite, try to pin your gui inside notepad ( Dock("M","M") ) and you will see that Edit1 of Notepad will always hide Gui. Success depend on internals of app (i.e. how dock host handle its children)

If you still think I am wrong, please recreate Dock function with SetParent (with all its current features).

Unfortunately, without hooking or subclasing this is not possible to do. In QuickView script I used another technique with 1s timer. Here timer is 0ms adn it is active only while you move your window. This is the reason for GUI repositioning so fast, but "chacing" the Dock Host is visible even with this type of hook (as of WinEventHook limiation)

_________________
Image


Last edited by majkinetor on May 21st, 2007, 9:33 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2007, 9:07 pm 
Offline

Joined: June 15th, 2006, 6:29 am
Posts: 59
Location: Oriel College
Win32 programmer's Reference:
Quote:
The SetParent function changes the parent window of the specified child window.
...
Remarks

An application can use the SetParent function to set the parent window of a pop-up, overlapped, or child window. The new parent window and the child window must belong to the same application.
...


The main thing however, is that you haven't actually "docked" anything, you've just reduced the amount of screen which notepad can use.

To see what we mean by "docking", try Winamp.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2007, 9:08 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Exactly.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2007, 9:21 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
2Laszlo
Ah, my research about SetParent is even documented :D

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2007, 10:39 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
majkinetor wrote:
that "method" is very bad (no offense, this is well known method for long time), and very limited.
There were scripts posted to the Forum already two years ago, which used SetParent. I did not find any bugs in my scripts using it. There are trivial things you have to keep in mind: WinSet Region is sometimes necessary, because some windows occupy larger (transparent) area than meets the eye. You want to prevent moving the docked window, or even remove its title bar.
majkinetor wrote:
u acctually pined Notepad inside your GUI, not your GUI aside Notepad.
This is the right way, because you can reserve room for Notepad in your GUI, not the other way around.
majkinetor wrote:
recreate Dock function with SetParent (with all its current features).
What are these features? I have many uses of SetParent, and it was sufficient for providing tabs, buttons, info fields, etc. around simple applications. It works. And moving around the GUI moves the docked window smoothly, while the movement of your docked window is jerky.

I did not say that hooks are not important, but often you can have even better results with SetParent, than docking.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2007, 11:08 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Quote:
What are these features?

See the function above.

In your example above Notepad is half paint in my situation. WHen I move it, picture becomes garbage.

SetParent can not be made to work generaly good. You can just try to use it for particular app and see how it works, and if placement, size and everything is correct, it might work...

Other then that, its general usage is equal to 0.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 352 posts ]  Go to page 1, 2, 3, 4, 5 ... 24  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 6 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group