Results 1 to 12 of 12

Thread: Form within a frame

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Posts
    4

    Form within a frame

    Is it possible to call and use a form from within the frame of another form? If so, how would I do it?

    Thanks in Advance

  2. #2
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    VB Code:
    1. Private Declare Function SetParent _
    2. Lib "user32" ( _
    3. ByVal hWndChild As Long, _
    4. ByVal hWndNewParent As Long) As Long
    5.  
    6. Private Sub form_load()
    7.     SetParent Form2.hWnd, Frame1.hWnd
    8.     Form2.Show
    9. End Sub
    Try this
    -Excalibur

  3. #3
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Question

    huh?

    i started a new project, added a second from, and ran it, but nothing happened.

    it didn't work for me - but maybe i'm missing something....
    ~Peter


  4. #4
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    Did you add a frame to form 1?
    -Excalibur

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    I tried it as well, and it did work, but I was wondering if there would be a way to center the form inside the frame.

    When I ran it, half the form was below the bottom of the frame, and trying to move the form around using its caption was a total trip.

  6. #6
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    *grin* just set the left/top properties of the form you're putting in the frame. You can also set the windows startup position to centerowner.
    -Excalibur

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    *grin* *grin*

    I tried that already....unless I did something wrong (and I can't figure out how even I could screw a .Top .Left setting), it still did crazy things.

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    I've been playing with this, and I got it to work that way I want by playing with the screen properties of Form2 until it popped up, with the Frame on Form1, exactly where I wanted it.

    Then, I set the border style of Form2 to 0 - None, and the controls on Form2 look just like they were placed there, rather than on a separate form.

    What a great idea for a large wizard where you might run into the problem of too many controls on one form (that happened to me once)

  9. #9
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    heh it is pretty nifty. You could conceivably put an mdi form on a form with mdi children, but that'd be silly
    -Excalibur

  10. #10
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Smile

    I got it to work by adding this code to the second form:

    Code:
    Private Sub Form_Load()
        Me.Left = 0
        Me.Top = 0
    End Sub
    And you also need to have Form2 set to be StartUpPosition = 0 at design time.

    Very cool effect. Thanks guys.
    ~Peter


  11. #11
    Junior Member
    Join Date
    Dec 2001
    Location
    Dallas, Tx
    Posts
    29
    this works fine for me, but i have a few quetions:

    When I maximize the form inside the frame, i still have the ability to move the frame around. :/ Is there a way to lock the form once maximized?

    Also, when I move the form around in the frame and try to maximize, it makes the form the same size as the frame but does not properly make it maximized in the frame. How can I keep this from happening.

    Thanks in advance.

    *My First Post*

  12. #12
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Post

    I removed the title bar from the form within the frame. Then the user has nothing to grab on to, so they can't move it.

    And i set the form to be maximized on start up.

    Worked fine for me.
    ~Peter


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