Results 1 to 3 of 3

Thread: Q: API Setparent -> GPF

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2001
    Posts
    7

    Question Q: API Setparent -> GPF

    Hello all

    I have an application in wich I use the API SetParent. I works fine, but when i close the VB application, VB crashes!

    Why...?

    Info: VB 6.0 EE. SP5, Win 2000 Prof. SP2

    Kind Regards

    Jacob Laue Petersen

  2. #2
    jim mcnamara
    Guest
    Where hWnd is the window handle of the created child -- do this in your form unload event. That's the one called when your program exits.

    Code:
    Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
    Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
    Private hWnd as Long
    
    Private Sub Form_Unload(Cancel As Integer)
        DestroyWindow hWnd
        ' the last line is not required
        TerminateProcess GetCurrentProcess, 0
    End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2001
    Posts
    7

    It worked!

    Thank you very much, i worked!

    JLP

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