Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Controls
  New Posts New Posts RSS Feed - Getting the child handle
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Getting the child handle

 Post Reply Post Reply
Author
Message
eSynaptic View Drop Down
Newbie
Newbie


Joined: 07 March 2006
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote eSynaptic Quote  Post ReplyReply Direct Link To This Post Topic: Getting the child handle
    Posted: 19 March 2011 at 9:23pm
I am dynamically loading a form as a tab item. When I hit the close button on the tab, how can I get the handle of the form so I can unload it when the tab closes?

example:

'load the form as a tab item
With wndTab
 
 Set nTab = .InsertItem(0, "Example Tab", form1.hWnd, 0
 
End With

Now... using the NavigateButtonClick event, how can I get the loaded form to unload it?

Thank you!!

Jason

Back to Top
eSynaptic View Drop Down
Newbie
Newbie


Joined: 07 March 2006
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote eSynaptic Quote  Post ReplyReply Direct Link To This Post Posted: 19 March 2011 at 10:06pm
This is what I am doing... is there an easier way?

Private Sub wndTab_NavigateButtonClick(ByVal Id As Long, Cancel As Variant)
On Error Resume Next
Dim i As Long
Dim szTag As String
Dim oFrm As Form

szTag = wndTab.Selected.Tag

'find the tag name
For i = Forms.Count - 1 To 1 Step -1
    DoEvents
    
    If Forms(i).Tag = szTag Then
      Unload Forms(i)
    End If
Next

End Sub

Back to Top
Xander75 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 April 2007
Status: Offline
Points: 353
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xander75 Quote  Post ReplyReply Direct Link To This Post Posted: 21 March 2011 at 6:25am
Hi,

Use the following code to resolve the issue you have of closing the child form.


Private Sub wndTab_NavigateButtonClick(ByVal Id As Long, Cancel As Variant)
    Dim i As Long

    For i = Forms.Count - 1 To 0 Step -1
        If Forms(i).hWnd = wndTab.Selected.Handle Then
            Unload Forms(i)
        End If
    Next
End Sub

Product: Xtreme SuitePro (ActiveX) v15.3.1
Platform: Windows 7 64-bit (SP1) Professional Edition
Languages: C#.Net using Visual Studio 2012 & Visual Basic 6.0 (SP6)
Back to Top
Xander75 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 April 2007
Status: Offline
Points: 353
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xander75 Quote  Post ReplyReply Direct Link To This Post Posted: 21 March 2011 at 7:12am
Or if you'd prefer to use an API, you can do this with one line of code in the "NavigateButtonClick" event...


Private Declare Function PostMessage Lib "user32.dll" Alias "PostMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Const WM_CLOSE = &H10

Private Sub Form_Load()
    wndTab.ShowCloseItemButton = xtpTabItemButtonSelected
    wndTab.InsertItem 0, "Example Tab", Form2.hwnd, 0
    wndTab.InsertItem 1, "Example Tab", Form3.hwnd, 0
End Sub

Private Sub wndTab_NavigateButtonClick(ByVal Id As Long, Cancel As Variant)
    PostMessage wndTab.Selected.Handle, WM_CLOSE, 0&, 0&
End Sub

Product: Xtreme SuitePro (ActiveX) v15.3.1
Platform: Windows 7 64-bit (SP1) Professional Edition
Languages: C#.Net using Visual Studio 2012 & Visual Basic 6.0 (SP6)
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.266 seconds.