zomgistania

Main page | About | Articles | Previous Posts | Archives

Saturday, May 27, 2006

Docking

Someone asked if it's possible to "dock" other windows to your form in #C# channel in Quakenet... The idea was so intresting I had to try it out myself since he didn't seem to have any idea on how it could be done.

Looking at MSDN is always helpful, so I started looking for native Windows-functions for changing the position of a window.

Here is a list of native Windows-functions and structs and other stuff at MSDN


Using P/Invoke in C#, I made an app which uses GetWindowPlacement, GetClientRect and SetWindowPos to sort/dock all windows that are visible and not maximized. It uses .NET built in System.Diagnostics.Process to get a list of all processes and uses the MainWindowHandle property to check if the process has a window.

You can find the source code and a binary of the application here


I tried to add useful comments to the source, so even if you're not very used to calling native windows functions and other things, you can hopefully learn something.


Now, it does not exactly dock things to itself... it just moves other forms next to it. And the algorithm which does that is not very good.. does it's job, but it could be done more effectively and such.

For "true" docking, you probably would have to add something which rearranges the other forms if you move the main form. Also you'd have to add something which monitors other processes running to see if there's a new window which needs to be docked or a process has been shut down and should be removed from the docking list.

Labels:

5 Comments:

  • Nice! Where you get this guestbook? I want the same script.. Awesome content. thankyou.
    »

    By Anonymous Anonymous, at 5:09 AM  

  • I find some information here.

    By Anonymous Anonymous, at 8:59 PM  

  • Link to the source is broken, could you re post

    By Anonymous Anonymous, at 7:46 PM  

  • Yeah link is dead, could you repost?

    By Blogger Cody, at 12:53 AM  

  • I don't think I have the code anywhere anymore :/ Sorry

    By Blogger Jani, at 12:54 AM  

Post a Comment

<< Home