If you haven't used EnumChildWindows before you might find
it a little bit tricky. It enumerates all child windows, all the
way down, using a callback function.
Private Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As
Long, ByVal lpEnumFunc As Long, lParam As Long) As Long
Dim LRet as Long, H1 as long
LRet = EnumChildWindows(H1, AddressOf EnumChildProc, 0)
In the two lines above, H1 is the handle of window
you want to find all children of. EnumChildProc is the
callback.
As shown below, EnumChildProc receives the handle of each
child window in turn. You can then use that to check classname,
title, etc. The sample here uses a global variable HCur to
receive the handle of the relevant window when it's found.
This sample is looking for a window with class name that
matches another global variable, sClassName. But of course
you can put any check, or combination of checks, into your
EnumChildProc function.
The EnumChildWindows function will continue until either
all children have been returned or you return 0 from EnumChildProc.
Public Function EnumChildProc(ByVal hWnd As Long, lParam As Long) As Long
Dim s2 As String
s2 = GetWinClass(hWnd)
If InStr(1, s2, sClassName, 1) > 0 Then
HCur = hWnd
EnumChildProc = 0
Else
EnumChildProc = 1
End If
End Function
Hi I used the following code:
//I found the window(which gives wrong window)
_windowHandle = FindWindow("#32770", null);
if (_windowHandle != IntPtr.Zero)
{
//I try to get all the child windows for that window
List<IntPtr> childWindows =
OutlookWin32Window.EnumChildWindows(_windowHandle);
// get a list of captions for the child windows
List<string> childWindowNames =
OutlookWin32Window.GetWindowNames(childWindows);
}
This is all getting me wrong window basically _windowHandle =
FindWindow("#32770", null); itself is returning wrong window.
How do I get the right window. Sorry if I am asking very basic
question as I am not at all familiar with win32 api's
Thorsten Albers - 29 Apr 2008 16:00 GMT
vidishasharma@gmail.com schrieb im Beitrag
<0ef7cc4f-0608-4ec3-8fa9-702d1c3967f8@z24g2000prf.googlegroups.com>...
> _windowHandle = FindWindow("#32770", null);
Obviously you are in the wrong newsgroup since your code is C/C++ code.
This newsgroup is for API programming with MS Visual Basic <= 6.0 (aka
'classic'). You should ask your question in an appropriate newsgroup!

Signature
----------------------------------------------------------------------
Thorsten Albers albers(a)uni-freiburg.de
----------------------------------------------------------------------