Dockable Window Control

Cost
Free
Version
1

Readme

~~~~~~~~~~~~~~~~~~~~~~~~~~~
(c) VB Web Development 2000
VB Web Dockable Window Control
Please visit www.vbweb.co.uk

Please email [email protected] if you intend to use the Control
in a commercial program. Credit would be appreciated!

Please DO NOT make modifications to this Control
If you can improve the code, please email
[email protected] and it will be encorporated
into the next release. Thanks.

Parts of this code is from vbaccelerator.com

~~~~~~~~~~~~~~~~~~~~~~~~~~~

Installation

To install this ActiveX Control, simply place vbwDock.ocx in your windows system folder, and call

regsvr32.exe vbwDock.ocx

from the run window. There is also an example project with the source code for the control. Open grpDock.vbg to view this.

This control requires ssubtmr.dll from VB Accelerator or http://www.vbweb.co.uk/code/downloads/ssubtmr.zip

~~~~~~~~~~~~~~~~~~~~~~~~~~~

Notes

This control currently only works with 1 dockable window, and works best if you have the Show Window Contents When Dragging option enabled in your display preferences (control panel). If anyone has some code that will work when this mode is disabled, please email [email protected].

Thanks

If you have any improvements, comments or suggestions, you are welcome to email me at the address above

~~~~~~~~~~~~~~~~~~~~~~~~~~~

Usage

Using this ActiveX control in your project is more complicated than I would like it, but dockable windows are complex anyway!

1) You need two forms, a MDI form, and the dockable window form. In these instructions, I will call them frmParent and frmDock. Add a reference to vbwDock.ocx by clicking Project|Components.

2) Add a picture box to the MDI form (we will call it picHolder), set its border to nothing, and its backcolor to 'Button Face'

3) In your startup code, you will need the following controls. Please note that you do not have to use the names provided, but if you change them, you also need to change the names in the code for part 4)
PictureBox (Name: picSizer, Width: 45, Align: 4, Border: 0, BackColor: Button Face)
PictureBox (Name: picSizerTop, Height: 45, Align: 1, Border: 0, BackColor: Button Face)
vbwCaption (Name: vbwCaption1, Align: 1)
Set the forms caption property to nothing, set the BorderStyle to SizableToolWindow, and set ControlBox to False.
4) Now you need to add some code to frmDock. The code is explained in the comments.

  
	'add this to the general declarations section
	Private WithEvents cDock As clsDock

'add this to the Form_Load event Set cDock = New clsDock With cDock Set .frmDockWindow = Me 'the dockable window Set .frmParent = frmParent 'the mdi form Set .picHolder = frmParent.picHolder 'the picture box in the mdi form Set .picSizer = picSizer 'the picture box in the dockable window Set .picSizerTop = picSizerTop 'the other picture box in the dockable window .RegAppName = "DockWindowExample" 'the app name where the position of the 'dockable window will be saved in the registry '(like the first parameter of the SaveSetting procedure) .RegSection = "WindowSettings" 'the section in the registry '(like the second parameter of the SaveSetting procedure) .RegKey = "frmDock" 'the key in the registry (will be saved as frmDock_Top, frmDock_Left etc) .DefaultHeight = ScaleHeight 'the default form height .Defaultwidth = ScaleWidth 'the defaultform height .DefaultPos = vbAlignLeft '(default value) 'sets the default docking position (left, right, top, bottom or none) .Initialize 'tells the class that we have set all the values Form_Resize 'resize the form properly End With vbwCaption1.Caption = "DockWindow" 'the forms caption

'you can call this proc from the parent form 'with bInitialPos = True for startup Public Sub ShowWindow(bInitialPos As Boolean) cDock.ShowWindow (bInitialPos) End Sub

5) Because we have 'faked' the caption bar so that the form can be resized properly when docked in the Form_Resize event, instead of using the Form's left, ScaleWidth etc properties, use the classes. For example,
txtText.Move cDock.FormLeft, cDock.FormTop, cDock.FormScaleWidth, cDock.FormScaleHeight
6) In the dockable windows Form_Unload event, add
Set cDock = Nothing

~~~~~~~~~~~~~~~~~~~~~~~~~~~

Properties, methods etc

- To set the dockable windows caption, use the fake caption controls Caption property

Please note that the Caption control is only there to create the fake caption. To
control the docking, you use the properties of the clsDock class

Methods...

Dock (Align, [bNoCancel]) - docks the window. Align sets where to dock, using the AlignConstants. If bNoCancel is set to true, you cannot cancel the docking with the BeforeDock event
Initialize - tells the class that you have finished setting all the properties
ShowWindow (bInitialPos) - shows the dockable window. If bInitialPos is set to true, the window will be shown in its last position (or not at all if it was closed). If bInitialPos is set to False, the window will be shown, even if it was left hidden last time
UnDockWindow - undocks the window

Events...

BeforeDock - occurs before the window is docked, letting you cancel it
BeforeUnDock - occurs before the window is undocked, letting you cancel it
Dock - occurs when the window is docked. The Pos parameter tells you where.
UnDock - occurs when the window is undocked.

Properties...

frmDockWindow - sets the dockable window
frmParent - sets the mdi form
picHolder - sets the picture box in the mdi form
picSizer - sets the picture box in the dockable window
picSizerTop - sets the other picture box in the dockable window
RegAppName - the app name where the position of the dockable window will be saved in the registry (like the first parameter of the SaveSetting procedure)
RegSection - the section in the registry (like the second parameter of the SaveSetting procedure)
RegKey - the key in the registry (will be saved as frmDock_Top, frmDock_Left etc)
DefaultHeight - the default form height
Defaultwidth - the defaultform height
DefaultPos - sets the default docking position (left, right, top, bottom or none). Default = left.

~~~~~~~~~~~~~~~~~~~~~~~~~~~

Disclaimer: If anything goes wrong, tell me ([email protected]), but don't blame me! Use this ActiveX control at your own risk.

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The question of whether computers can think is just like the question of whether submarines can swim.” - Edsger W. Dijkstra