In a current project I am working on, I have the need to dock forms on each other. For example, you have form1 and when you move form2 close to the borders of it, it attaches itself to form1. Then it could move with form1.
I would have thought that this would be a built in feature already in .NET, but after doing some brief searches I was not able to find it.
If anyone knows how to do this automatically in C# .NET, or if you have a different solution on how to accomplish it, please let me (and everyone) know.
Thanks,
Bentley.
10 27684
Looks like you found a solution - Attachments on thescripts. Not sure why you thought it would be built-in or is that what you found?
kenobewan,
To me, this seems like something many people would have wanted to do before. Also, many applications already incorporate this type of behavior.
I really like the way that Winamp does it. It's very smooth. The code I wrote to try and duplicate this type of behavior is similar, but a little jumpy when trying to dock. I was hoping to find other people that have run into this same situation of wanting this behavior and who either found some other solution or created one themselves.
The question of attachments in the forum is still unanswered. I would like to post the simple project I made, but there still is no way to do that here. I'm assuming that it's turned off to prevent people from uploading stuff to each other through this site, but isn't that what the moderators are here for?
Anyways, back to the subject. Has anyone needed to have forms dock with each other before?
I've just received instructions on how to attach files to my posts by msquared, so I'll be posting my attempt at solving this issue very soon.
So, here's what I could figure out...
After searching the internet like a big boy in fat camp looking for cupcakes, I found many articles talking about overriding the WndProc protected method and catching messages from the operating system. This seemed like a great idea but after hours of playing with all of the messages, I was unable to find what I was looking for.
I found that if the message is WM_NCHITTEST and the WParam is HTCAPTION, then you can catch it and stop the form from going into it's "moving" mode. What I was really looking for was a way to stop the repainting of the form while it was being moved so that then I could repaint it only when the form wasn't in the designated docking distance of the parent form.
If I kept going down that road, the only way I could see to do it would be to stop the form from going into "moving" mode, then track the mouse movements on the screen with a WIN32 GetCursorPos call, see how that would translate into the hypothetical movement of the form, check the hypothetical new gap distance from the parent form, and end up moving the form manually to its new correct place on the screen.
Needless to say, I don't want this functionality THAT bad.
I am attaching to this post my original simple implementation to try and get this functionality that is far easier to understand than all of this was for me. The one drawback is that when you are moving the form within the gap distance of the parent form, it jumps around a little bit because it is redrawing itself. It is a Visual C# 2008 Express project and was just meant to test how this could work for me. I hope it helps someone else out there as well.
Cheers,
Bentley.
Well, it appears that I did want it THAT bad. I did some more searching on the net to see how to stop Windows from doing the form move so that I could do it myself programmaticall y. Here is the article that gave me the best clues: http://www.syncfusion.com/FAQ/window...5c.aspx#q1091q
Attached (as soon as I edit this post) is the new version I have been working on for docking one form onto another. It is just a simple example to illustrate the theory and principle of how it can work, so you'll still have to adapt the actual functionality to how you would want it to work in your application. I think it's a good start though.
The main change from my previous version is that now instead of using the move event of the form, I am catching the Windows messages that are passed to actually do the moving of the form. This way I can keep it from moving when I don't want it to. After intercepting the intial message to start the move, I then move the form the way that I intend it to move.
Another change is that now the window will dock with the sides of the screen as well as the sides of Form1.
It appears to work pretty smoothly, but if you find it not working correctly or have another way of doing this same type of thing, I would really like to hear about it.
Hope it helps someone,
Bentley.
Hello to anybody still interested in this...
This morning I've published a working class library and source code onto SourceForge of my most recent version of the form docking functionality. https://sourceforge.net/projects/dockableform
One of the issues that still exists in this current implementation is related to the way that I've chosen to implement the functionality. That issue is that sometimes the operating system decides not to fire move events, probably in an effort to maximize efficiency. This can cause the forms to sometimes become undocked. I have coded around the problem a little bit, but I think the best way would be to approach this functionality from another angle. Possibly an external form movement manager. Perhaps I'll work on that later...
If you'd like to play around with the source code, feel free to go to the SourceForge link above to download it. I will attach to this post a goofy little demo I made of this functionality that you can take a look at (or maybe your kids would be amused by it). :)
Cheers,
Bentley.
Hi bentlyw,
Thanks for posting the code on docking windows. I would like to get the source code for the test application you posted using your component.
I would like to use this for one of the projects we are working on where there are a lot many windows floating on the desktop. From what i understand that the "connectfor m" method needs to be called from within one window to connect to the other ? I am still a bit unclear on how to use this dockign library ? please help ?
hi bentleyw,
i have only one form in my application and i want it to dock it to one of the nearest borders of the screen (top, left, right or bottom when i drag near to them).
so i think i don't need to give a parameter to ConnectForm(); function?
how can i do it?
Dear bentleyw,
Great work! This is exactly what I was looking for. :)
Is this a free software? Can I use it without any concerns?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Lecture Snoddddgrass |
last post by:
Greetings,
Can anyone recommend a good 3rd party docking windows component for
WinForms? I'm looking for something that allows windows to not only be
docked but to "popout", much like the Solution Explorer or Toolbox in Visual
Studio.NET. For my last project, I used the SyncFusion component for docking
windows, but my experience is that SyncFusion is buggy. I'd prefer to use a
different vendor for this project. Any advice?
Thanks,
|
by: Franck Jobard |
last post by:
Hello
I have a form (winform) with 2 panels.
The first one (panel_cmd) is dock to bottom.
The Second one (panel_all) is dock to fill.
At design, When i resize the form, the panel_cmd don't follow the new size.
If i resize the height, it stay an empty place on the bottom. No panel have
been resized.
|
by: Gislain ROCHE |
last post by:
Hello,
I'm trying this two component to implement Docking Windows in my
application, but whitch is the better.
Could you tell me your expcrience witich one of these component, the
advantage, the problem, ..., technical support, ...
Web site
http://www.dotnetmagic.com/
http://www.innovasys.co.uk/products/dockstudioxp.asp
|
by: Gary Shell |
last post by:
We are playing around with using the splitter on a form and want to do the
following:
1. On the left side of the form will be a tree view.
2. To the right of that tree view would be a splitter.
3. To the right of that splitter would be a second tree we call a palette.
4. To the right of the palette would be another splitter.
5. To the right of that splitter would be our "content area".
We are trying to find a way to allow this...
|
by: Dennis |
last post by:
Has anyone really gotten the Docking and Splitter Bars to work for anyting
but the simplest application for two controls and one splitter bar filling
the whole form? If so, can you enlighten my on HOW! I even tried creating
background panels and docking them with the controls on the panels but the
docking order seems to be random! Another useless control from Microsoft I
think!
--
Dennis in Houston
| |
by: Enrique |
last post by:
hi all,
i'd like to know how i could do a docking menu and docking toolbar.
i know it's not so easy y VS .NET 2002 and 2003.
anything will help me: links, code, articles.....
thanks a lot for your responses and i wish you a merry christmas :-)
|
by: Joe |
last post by:
I'm creating a C# application, and want to use docking windows. However,
I want the docking windows to look like the docking windows withing
VS2005, with a title bar, close button, etc... When the user clicks and
drags the docking window, it'll un-dock, and open in a tool window, and
also allow the user to re-dock it elsewhere...
Any ideas where I can go to look up how to accomplish this?
Thanx!
--
|
by: Matt Brown - identify |
last post by:
Hello,
I've spent the better part of the day going over code and thinking and
have come up with the following docking method that works perfectly.
At this point, my brain is about to explode and I was wondering if
someone can help me figure out the calculations for right and bottom
docking:
note: lRelOffsetLeft and lRelOffsetTop are calculated on mousedown
(location of mouse in relation to top and left of picturebox)
|
by: adebiasio |
last post by:
Does anybody have any code samples that show me how to dock tabs
around a form. I have found numerous controls out there that does the
job, but I want to learn how to code it myself.
Any sites that show how to code this.
Thanks!
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |