Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Tutorial #3 in series of Paltalk programming tutorials....
- Imports System.Runtime.InteropServices
- Public Partial Class MainForm
- Public Class PalHwnds
- Public hMainHwnd As IntPtr
- Public hIncommingHwnd As IntPtr
- Public hOutgoingHwnd As IntPtr
- Public hNickListHwnd As IntPtr
- End Class
- <DllImport("user32.dll", CharSet:=CharSet.Auto)> _
- Private Shared Function EnumChildWindows(ByVal hWndParent As System.IntPtr, ByVal lpEnumFunc As EnumWindowsProc, ByVal lParam As PalHwnds) As Boolean
- End Function
- Private Delegate Function EnumWindowsProc(ByVal hWnd As IntPtr, ByVal lParam As PalHwnds) As Boolean
- <DllImport("user32.dll", EntryPoint:="FindWindow", SetLastError:=True, CharSet:=CharSet.Auto)> _
- Private Shared Function FindWindowByClass( _
- ByVal lpClassName As String, _
- ByVal zero As IntPtr) As IntPtr
- End Function
- <DllImport("user32.dll", SetLastError:=True)> _
- Private Shared Function IsWindowVisible(ByVal hWnd As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
- End Function
- <DllImport("user32.dll")> _
- Public Shared Function GetDlgCtrlID(ByVal hwndCtl As Integer) As Integer
- End Function
- Public Sub New()
- ' The Me.InitializeComponent call is required for Windows Forms designer support.
- Me.InitializeComponent()
- '
- ' TODO : Add constructor code after InitializeComponents
- '
- End Sub
- Public Shared Function ProcessChildWindows(ByVal hWnd As IntPtr, ByVal lParam As PalHwnds) As Boolean
- Dim ID As Integer = GetDlgCtrlID(hWnd.ToInt32)
- If IsWindowVisible(hWnd) = True Then
- Select Case ID
- Case 202
- LParam.hIncommingHwnd = hWnd
- Case 203
- LParam.hOutgoingHwnd = hWnd
- Case 1789
- LParam.hNickListHwnd = hWnd
- Case Else
- Return True
- End Select
- End If
- Return True
- End Function
- Sub Button1Click(sender As Object, e As EventArgs)
- Dim wInfo As New PalHwnds
- wInfo.hMainHwnd = FindWindowByClass("DlgGroupChat Window Class", IntPtr.Zero)
- If wInfo.hMainHwnd = IntPtr.zero Then
- Exit sub
- End If
- EnumChildWindows(wInfo.hMainHwnd, AddressOf ProcessChildWindows, wInfo)
- txtIncomming.Text = wInfo.hIncommingHwnd.tostring
- txtOutgoing.Text = wInfo.hOutgoingHwnd.tostring
- txtNicklist.Text = wInfo.hNicklistHwnd.tostring
- txtMainHwnd.Text = wInfo.hMainHwnd.tostring
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement