PDA

Click to See Complete Forum and Search --> : Make a form appear within a form...


Stoinker
Jan 11th, 2000, 07:12 AM
What I'm trying to do is create a form (say 50 X 50 pixels) appear inside of another form (640 X 480 pixels) but always have it located at a certain X,Y location relative to the large form.

I think I need to use the SetWindowPos API. But I'm not sure. If I do need to use it, can someone tell me how to get the "hWnd" of the larger form.

Any help would be very much appreciated.

~Stoinker~

LG
Jan 11th, 2000, 09:08 AM
What you need is:


On load last line (or rezise event)

form2.Move Form1.Left + X, form1.Top + Y, Form2.Width, Form2.Height

Where X, Y desired coordinates

Jan 11th, 2000, 09:21 AM
I have done this before. But there is one problem with doing it this way LG, If you move the main form it won't move the 2nd form. Got any ideas how to litteraly dock it to the main form?

Knight

LG
Jan 11th, 2000, 10:29 AM
Usually second form is Modal, if not then modeless means independant and shouldn't follow the first form.
That why you have MDI

Crazy D
Jan 11th, 2000, 02:51 PM
change the style of the window to WS_CHILD (using SetWindowLong), and use te SetParent API to make your main form the parent of the child. THe child form is shown now in the main form (and it will move with the main form).

Stoinker
Jan 12th, 2000, 03:41 AM
It appears I worded it badly. What I meant was that I'm making a project that contains one form and only one form. Now I also have an executable to a program that I did not create nor do I have the source to. I want to dock my vb form into the executable at a given set of x,y coordinates and whenever i move the form of the executable, the form of my program will move with it.

~Stoinker~

Crazy D
Jan 12th, 2000, 05:01 AM
Use FindWindow (or FindWindowEx) to find the window (duh) and get the hWnd of that window.
Set, modify yourself (windowstyle) to current style Or WS_CHILD. Then call SetParent to make yourself a child of the other program. And set the position of your form.
I don't know if Windooz or VB allows you to subclass that program. If it does, subclass it, and catch WM_MOVING so you can move yourself when the program moves. If it doesn't, I'd say use a timer to check the position of the application.
Not sure if it works, but at least you can give it a try :-) Theoretically it should :-)