Click here to Skip to main content
6,822,123 members and growing! (17,451 online)
Email Password   helpLost your password?
Desktop Development » Dialogs and Windows » General     Intermediate License: The Code Project Open License (CPOL)

Form Docker

By Programble

Form Docker is a class library (DLL) that can dock any form to different parts of the screen.
VB (VB9.0), Windows, .NET (.NET3.5), Visual-Studio (VS2008), Dev
Posted:23 Sep 2008
Views:9,790
Bookmarked:16 times
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
4 votes for this article.
Popularity: 1.40 Rating: 2.33 out of 5
1 vote, 25.0%
1
2 votes, 50.0%
2

3

4
1 vote, 25.0%
5

Introduction

This class library can dock any form, on different parts of the screen. It acts just as the Dock property of a control acts, only with more options. Not only can this class library dock to the top, bottom, left, right, and fill, it can also dock to corners of the screen (top right, bottom left, etc.). It can also leave space around the edges of the screen, using the Padding property.

Background

While updating one of my projects, I found I was writing a lot of code for keeping the form in a certain place over and over again. I decided to write this class library to make it easier to keep forms in specific spots, and because I think it can be quite useful. If controls can be docked, why can't forms be docked?

Using the Library

The class library is provided as a DLL that can be referenced from your project. For those who don't know, you can add a reference by choosing "Add Reference..." from the "Project" menu and then selecting "Browse" to find the file.

Once referenced, you will need to create a new instance of the FormDocker class:

Dim Docker As New FormDocker.FormDocker(Me, _
           FormDocker.FormDocker.FormDockMode.Top, New Padding(5))

If you wish to take advantage of the events in the class, it can also be declared using WithEvents:

WithEvents Docker As New FormDocker.FormDocker(Me, _
           FormDocker.FormDocker.FormDockMode.Top, New Padding(5))

The first parameter represents the form to dock. The second is where to dock it, and the third is the padding. There are also optional parameters.

Once declared, the form will automatically be docked. The docking can be re-applied, that is the form re-positioned, any time, by using Refresh():

Docker.Refresh()

To undock the form, use UnDockForm(). To dock the form again, use DockForm(). These are equivalent to Dock = False and Dock = True.

'Undock form:
Docker.UnDockForm() 
'Or:
Docker.Dock = False

'Dock form:
Docker.DockForm()
'Or:
Docker.Dock = True

Feel free to explore other parts of the library, everything is commented. If you have any questions about how to use this library, please post a comment.

History

  • 23/09/08 - Version 1.0 released.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Programble


Member
I am a hobby VB programmer.
Location: Canada Canada

Other popular Dialogs and Windows articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 5 of 5 (Total in Forum: 5) (Refresh)FirstPrevNext
GeneralMy form does not move Pinmembereusta5:13 5 Feb '09  
GeneralWeifen Luo DockPanel Suite PinmemberPinx10:05 26 Oct '08  
GeneralRe: Weifen Luo DockPanel Suite PinmemberProgramble10:13 26 Oct '08  
Generalso what ? Pinmemberwakashich0:42 24 Sep '08  
GeneralRe: so what ? Pinmemberprogramble6:39 27 Sep '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads.

PermaLink | Privacy | Terms of Use
Last Updated: 23 Sep 2008
Editor: Smitha Vijayan
Copyright 2008 by Programble
Everything else Copyright © CodeProject, 1999-2010
Web21 | Advertise on the Code Project