remarknibor wrote:
> Once I've done 'CreateProcess()' to open Notepad, it's process id can
> be found at pi.dwProcessId (where pi is the PROCESS_INFORMATION
> structure)?
> Therefore, I should use EnumWindows to compare windows' processids to
> that one? Something like:
>
> HWND notepadHandle;
>
> BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam) {
> DWORD processId;
> DWORD threadId = GetWindowThreadProcessId(hWnd,&processId);
> if(processId == pi.dwProcessId) {
> notepadHandle = hWnd;
> return FALSE; //Correct window - stop enum
> }
> return TRUE; //Continue enum
> }
>
> EnumWindows(EnumWindowsProc, 0); (in main())
>
> Then I will have the correct handle to the Notepad window stored
> at 'notepadHandle?
> (Obviously, something is wrong with this as it doesn't work. Could
> you help me to figure out what it is?)
>
> Thanks.
It should work. The problem is most likely you aren't waiting for the
process to actually create the window.
--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197
*NEW* MyTaskFocus 1.1
Get on task. Stay on task.
http://www.CubicleSoft.com/MyTaskFocus/