Results 1 to 3 of 3

Thread: SetParent API Question

  1. #1

    Thread Starter
    Lively Member HeVa's Avatar
    Join Date
    Jul 2001
    Location
    DC
    Posts
    115

    SetParent API Question

    There's probably an easy answer to this question, but I haven't been able to find any information...

    I'm using the SetParent API to parent forms in a frame object, like this:

    Code:
        SetParent frm.hwnd, Frame1.hwnd
        frm.Show
    I want to switch between viewing several different forms in this frame. Is there a way to query the frame to see what is the name of the child form that is showing?

    Any info would be greatly appreciated!

    TIA
    H e*V a

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    You can try this..it will get the caption of the form in the frame
    VB Code:
    1. Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    2. Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    3.  
    4. Dim ChildhWnd As Long
    5. Private Sub Command1_Click()
    6.  
    7. Dim strCaption As String
    8. strCaption = String(100, Chr$(0))
    9.  
    10. GetWindowText ChildhWnd, strCaption, 100
    11.  
    12. MsgBox strCaption
    13.  
    14. End Sub
    15.  
    16. Private Sub Form_Load()
    17.  
    18. Dim frm As Form
    19.  
    20. Set frm = Form2
    21.  
    22. SetParent frm.hwnd, Frame1.hwnd
    23. frm.Show
    24. ChildhWnd = frm.hwnd 'store for later
    25.  
    26. End Sub

  3. #3

    Thread Starter
    Lively Member HeVa's Avatar
    Join Date
    Jul 2001
    Location
    DC
    Posts
    115

    Thumbs up That does the trick!

    Thanks, Chrisjk ... that was exactly what I needed.
    H e*V a

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