How to set hWnd of an SSTab control as parent of a form using SetParent function ?
Hello I am using Visual basic 6. I need to set hWnd of an SSTab control as parent of a non mdi form using SetParent function in Win32 API. It won't work after changing the tab. For a better understanding of the problem which I am facing, Try this small example (Included as attachment).
Create a standard exe project.
Add an SSTab control (SSTab1) to default form (form1).
Place this code to the form.
Code:
Option Explicit
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Sub SSTab1_Click(PreviousTab As Integer)
If SSTab1.Tab = 2 Then
Load Form2
Form2.Show
SetParent Form2.hWnd, Form1.SSTab1.hWnd
Else
Unload Form2
End If
End Sub
Add new form (Form2) to the project
Now Form1 is the startup object. When we click the third tab (indexed 0), Form2 will be loaded. If we click any tab other than third one, Form2 is unloaded. These two things (loading and unloading Form2 again and again as we change tab) is what I am trying to do. But once we unloaded Form2 like this, It won't load (or appear) anymore even if we click third tab. It works fine if we close Form2 manually using close button.
Re: How to set hWnd of an SSTab control as parent of a form using SetParent function
It has nothing to do with SSTab. You've just got your two windows handles reversed in your call to SetParent.
Take Care,
Elroy
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.