Results 1 to 7 of 7

Thread: Make a form appear within a form...

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    15

    Post

    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~

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308

    Post

    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

  3. #3
    Guest

    Post

    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

  4. #4
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308

    Post

    Usually second form is Modal, if not then modeless means independant and shouldn't follow the first form.
    That why you have MDI


  5. #5
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386

    Post

    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).

  6. #6

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    15

    Post

    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~

  7. #7
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386

    Post

    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 :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width