Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form docking?

Status
Not open for further replies.

sdh

Programmer
Apr 30, 2001
121
GB
I have a main form in a sdi application which contains a large picturebox I would like to be able to get other forms in the application to dock inside that picturebox can anybody help?

I have tried making the form.top and .left = the picturebox.top and left to no avail.

Please help

thanks
sdh
::)
 
use the following, where Form1 is the main form containing the picture box, Picture1 is the picture box, and Form2 is the form you are trying to dock:

Form2.Move (Form1.Top + Picture1.Top + 4), (Form1.Left + Picture1.Left + 4)

I added 4 pixel for the Form1 border. Adjust this as necessary.

Best Regards and many Thanks!
Michael G. Bronner X-)

"They who drink beer will think beer." Washington Irving
 
Thanx Micheal I will try it when I am back in the office.

-I assume it goes in the form2 load event?

have a good weekend

sdh
::)
 
Exactly :) You might need to play around with the +4 to get it exactly on the pixel you want.
:)

Take Care Best Regards and many Thanks!
Michael G. Bronner X-)

"They who drink beer will think beer." Washington Irving
 
Would this be possible to use with a MDI also?


newbie..
 
sure :) just write it like this:

Form1.Move (MDIForm1.Top + Picture1.Top + 4), (MDIForm1.Left + Picture1.Left + 4) Best Regards and many Thanks!
Michael G. Bronner X-)

"They who drink beer will think beer." Washington Irving
 
Hi,
I get run-time error 424, objekt required when I try this both on a MDIform and a SDIform.
Anyone know what I'm doing wrong???


Thanks, Jan Tore
 
I tried what Michael suggested (setting the form's left and top) ..but it seems like some property needs to be set..for the picturebox...since my form2 appears below the picturebox and a little right of the left border of the mdi form...

I also tried form2.left = mdiform.left and it didn't work either.

Help.
 
Anyone think of maybe using the SetParent API?

Code:
'Global declare
Public Declare Function SetParent Lib "USER32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long

Private sub Form1_Load()
    SetParent form1.hWnd, frmMain.picture1.hWnd
end sub

Now I am not sure how stable the SetParent is or if it will work well in this instance, but you may want to give it a shot.

Hope this helps out some.
Mavors
Cincinnati, Ohio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top