Two Plus Two Older Archives

Two Plus Two Older Archives (http://archives2.twoplustwo.com/index.php)
-   Software (http://archives2.twoplustwo.com/forumdisplay.php?f=43)
-   -   vb.net win32Api enumchildwindows help (http://archives2.twoplustwo.com/showthread.php?t=283100)

BradleyT 06-29-2005 05:03 PM

vb.net win32Api enumchildwindows help
 
I can get ENUMWINDOWS to work and give me a list of all available windows and their title text. However I can't get ENUMCHILDWINDOWS to work. All examples I see are vb6 and don't convert to vb.net. I'm an asp.net (using vb.net) programmer so I never have to deal with callback functions or win32APIs so I'm lost here.

All I need to do is pass it a known hwnd (say PokerStars.exe) and it gives me the handles for all of the childs. Sounds easy but it's not for a dummy like me.

If anyone has some sample code that works I'd greatly appreciate it.

Vern 06-29-2005 05:15 PM

Re: vb.net win32Api enumchildwindows help
 
Don't use child window, use thread window

Use GetProcessByName to get the process ID ex: "PokerStars"
Use GetWindowThreadProcessID to get the main processes window thread ID
Then use EnumThreadWindows with that Process ID to generate a callback you can capture all the sub window handles from.

Vern

P.S. Win32 API calls suck [img]/images/graemlins/smile.gif[/img]

OrcaDK 06-29-2005 06:18 PM

Re: vb.net win32Api enumchildwindows help
 
[DllImport("User32.dll")]
static extern Boolean EnumChildWindows(int hWndParent,PChildCallBack lpEnumFunc,int lParam);

delegate bool PChildCallBack(int hWnd,int lParam);

private bool EnumChildWindowCallBack(int hwnd, int lParam)
{
// Do some crazy stuff in here
}

--

Call EnumChildWindows like this:
EnumChildWindows(windowHandle, new PChildCallBack(EnumChildWindowCallBack), intSomeInteger);

intSomeInteger can be any integer value, might be an ID of the owner window f.example.


All times are GMT -4. The time now is 02:42 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.