Results 1 to 3 of 3

Thread: Using frame to link another form

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2008
    Posts
    2

    Using frame to link another form

    hey everyone.

    I've been searching around for help but wansn't able to find anything, so i decided to make an account here and ask for help.

    So uhm, while searching i found similar topics but nothing i was looking for, what i would like to do is link, for example, "Form 2" inside the "form1", Using something like a frame (like frontpage in poor words).

    So yeah, if for example i'd have that form 1 and would like to open the form 2 inside the form 1 in the center, i need a code for this.

    I was thinking to make the form2.show and then set the position in the center of form 1, but then if i'd move it the form 2 wouldn't move as well, so i'm looking for a code that opens Form 2 inside the Form 1 (but that doesn't delete Form 1 content, just open the form2 in a setted position).

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Using frame to link another form

    Are you sure you do not want to use MDI forms?
    Placing another vb form inside of a frame or another container can be done pretty easily... The only difficult thing is positioning it inside the new container. VB Frames are always scalemode of Twips, so in the code below, I am placing the form 3 pixels from left edge & 15 pixels from top edge.

    Add 2 forms to your project. On Form1 add 1 command button & 1 frame. Make Form2 (the one that will be hosted) borderstyle = zero. Then run the project
    Code:
    Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    
    Private Sub Command1_Click()
        SetParent Form2.hWnd, Frame1.hWnd
        Form2.Move Screen.TwipsPerPixelX * 3, Screen.TwipsPerPixelY * 15
        Form2.Show
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        Unload Form2 ' gotta do this else project will not close properly
    End Sub
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2008
    Posts
    2

    Re: Using frame to link another form

    Thanks for your time =).

    That helped me A lot, thanks very much!

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