Results 1 to 5 of 5

Thread: Neat little thing.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    Norway
    Posts
    112

    Wink

    Create 4 forms and try this code from a module.
    Form4 remains inside Form3, Form 3 remains inside Form2, Form2 remains inside Form1.

    Code:
    Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    
    Sub Main()
        MsgBox "test"
        Load Form1
        Load Form2
        Load Form3
        Load Form4
        SetParent Form4.hWnd, Form3.hWnd
        SetParent Form3.hWnd, Form2.hWnd
        SetParent Form2.hWnd, Form1.hWnd
        Form1.Show
        Form2.Show
        Form3.Show
        Form4.Show
    End Sub

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Yeah that's indeed pretty cool but don't forget to place this in the parent form for nice unloading
    Code:
    Private Sub Form_Unload(Cancel As Integer)
    Dim frm As Form
    For Each frm In Forms
       Unload frm
       Set frm = Nothing
    Next
    'End isn't that rude anymore because everything is unloaded
       End
    End Sub
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  3. #3
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    You can use this code te crash the computer:
    Code:
    Setparent Form1.hwnd, Form1.hwnd

  4. #4
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Talking

    Very nice!!!
    Keep puttin ones like those here (www.eeggs.com) vb trick here too.

    oetje, why do you think he was trying to crash the pc?

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  5. #5
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Originally posted by alex_read
    oetje, why do you think he was trying to crash the pc?
    I just wanted to say, that you must be careful when using setparent.

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