Results 1 to 2 of 2

Thread: How to set hWnd of an SSTab control as parent of a form using SetParent function ?

Threaded View

  1. #1

    Thread Starter
    Junior Member Anees's Avatar
    Join Date
    Jun 2016
    Location
    Ernakulam,Kerala,India
    Posts
    27

    Question 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.

    Thanks in advance.
    Attached Files Attached Files
    Last edited by Anees; Oct 8th, 2016 at 06:13 AM.

Tags for this Thread

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