Nitin Garg 04-27-2002, 05:27 AM Hi guys...
Can you please tell me, how can i make a form dockable(just like Project Window, Properties Window, Toolbar Window in VBIDE).
Check out the SetParent API
Also check this Link (http://www.allapi.net/vbexamples/vbexample.php?vbexample=VPPANEL&category=CONTROLS)
Is this form going to be "docked" on the desktop or are you using MDI forms?
Orbity
Nitin Garg 04-28-2002, 10:05 PM Hi Orbity...
Thanks for helping me.
I am using MDI Form.
I want a form in my application just behave as Project Window behave in VBIDE. Project Window can be aligned to the MDI form of VBIDE or can be free floating window. Just the same functionality I want to add in my application.
divil 04-29-2002, 05:46 AM You can implement this yourself using the SetParent API, and four pictureboxes docked to the side of your MDI parent form. Just how far you implement them, how much like the VB6 IDE ones they behave, is up to your coding :)
Squirm 04-29-2002, 05:46 AM Here is a very simple example. It uses GetWindowLong and SetWindowLong to add and remove the window title bar and borders, then uses SetParent to move the child form to its new position. You need an MDI form with a picturebox called Picture1 and 2 command buttons called Command1 and Command2 and an MDI child form, called Form1. All this code goes in the MDI parent form:
Option Explicit
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetParent Lib "user32" _
(ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function GetParent Lib "user32" _
(ByVal hwnd As Long) As Long
Const WS_CAPTION = &HC00000 'Window with a title bar and border
Const WS_THICKFRAME = &H40000 'Create a window with a sizing border.
Const WS_SYSMENU = &H80000 'Create a window with a system menu on its
'Title bar. Must be combined with WS_CAPTION
Const MY_WS_DOCK = WS_CAPTION Or WS_THICKFRAME Or WS_SYSMENU
Const GWL_STYLE = (-16)
Dim hOldParent As Long
Private Sub Command1_Click()
Dim lStyle As Long
lStyle = GetWindowLong(Form1.hwnd, GWL_STYLE)
lStyle = lStyle And (Not MY_WS_DOCK)
SetWindowLong Form1.hwnd, GWL_STYLE, lStyle
SetParent Form1.hwnd, Picture1.hwnd
Form1.Left = 0
Form1.Top = 0
End Sub
Private Sub Command2_Click()
Dim lStyle As Long
lStyle = GetWindowLong(Form1.hwnd, GWL_STYLE)
lStyle = lStyle Or MY_WS_DOCK
SetWindowLong Form1.hwnd, GWL_STYLE, lStyle
SetParent Form1.hwnd, hOldParent
End Sub
Private Sub MDIForm_Load()
Me.Show
Form1.Show
hOldParent = GetParent(Form1.hwnd)
End Sub
Why use GetParent? Well, it seems the MDI client area has a different hWnd to the MDI form itself. :)
divil 04-29-2002, 05:49 AM Since there seems to be a demand for it, I might post my dockable windows library on the forum, if I can tidy it up a bit.
Nitin Garg 04-29-2002, 10:21 PM Hi Squirm...
Thanks a lot for helping me.
But there is a problem. After docking my Child Form when I resize my MDI Form which make some area of Child Form invisible and then resizie MDI Form so that the invisible area of Child Form become visible again, the picture box on MDI Form do not get refereshed. Piture box shows background image in place of title bar of Child Form.
Please tell me its solution.
Squirm 04-30-2002, 05:51 AM Oops! Thats not too good... :D
And, the solution is very very strange. It seems that altering the dimensions of the form actually fixes the problem. :-\
Place this at the end of Command1_Click event:
Form1.Width = Form1.Width + 30
and this at the end of Command2_Click:
Form1.Width = Form1.Width - 30
I wish I could explain it but I cant. It seems to work perfectly. Thanks to ArnoutV for helping me nail this one. :)
Nitin Garg 04-30-2002, 10:56 PM :) Wonderful Squirm.
It is working.
Thanks a lot.
Squirm 05-01-2002, 06:47 AM That last hack left me feeling a little nasty, so I thought of another approach using SetWindowPos API :
First, the extra declarations:
Private Declare Function SetWindowPos Lib "user32" _
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, _
ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Const SWP_NOMOVE = &H2
Const SWP_FRAMECHANGED = &H20
Const SWP_NOZORDER = &H4
Then, the implementation:
'Sort out the borders
With Form1
SetWindowPos .hwnd, 0, 0, 0, .ScaleX(.Width, vbTwips, vbPixels), _
.ScaleY(.Height, vbTwips, vbPixels), SWP_NOMOVE Or SWP_NOZORDER Or SWP_FRAMECHANGED
End With
:)
dougb2000 04-09-2004, 04:24 AM In the VB environment you can dock a window then maximize other mdi child windows while the others stay visible. i.e. toolbar, project explorer etc.
How do you do this?
lazerfisk 04-16-2004, 05:21 AM You can implement this yourself using the SetParent API, and four pictureboxes docked to the side of your MDI parent form. Just how far you implement them, how much like the VB6 IDE ones they behave, is up to your coding :)
Hi!
I have tried this approach before - At that point it was about merging form displayed by an activex-dll (a plugin) into one of the apps forms (configuration dialog). It looked nice, and it worked and all except for ONE tiny thing:
When i click around in the configuration dialog, everything works fine. Then i click somewhere in the plugin-created part of the configuration dialog, and it loses focus! Even though i'm warping around (from the users point of view) in the configuration-dialog, the title-bar is still greyed out.
How the heck do i get past this? :)
Regards,
Christopher
|