Article View: borland.public.cppbuilder.nativeapi
Article #10849Re: is the window handle always the window handle?
From: Remy Lebeau (TeamB)
Date: Thu, 11 Mar 2004 00:55
Date: Thu, 11 Mar 2004 00:55
46 lines
3140 bytes
3140 bytes
"Mortz" <rmorteo@hotmail.com> wrote in message news:404f9b65@newsgroups.borland.com... > You are right HWND does not change. Therefore, for some > reason the PID I get from the "CreateProcess" is not directly > associated with the application's Main Window Not true. *All* windows in a program belong to the same PID. That is not the issue. The issue is that you have no control over the order in which EnumWindows() finds windows. You have no guarantee that the first window found for the PID will be the main window. That's the part that your code is not taking into account. > So, what to do? I already told you what to do - stop scanning for a new HWND on each iteration of the thread loop. Scan *once* and then re-use the same HWND for all messages. > Now, if a program can have multiple windows (like word > documents or IE) how does windows distinguishes among all > them? A window is a window regardless. The OS doesn't care about how many windows a program has. It is the program's responsibility to keep track of its own windows. Then, if you are looking for a specific window of a specific program, it is your own reponsibility to make sure that you are working with the window that you expect to be working with. There is no straight-forward way to determine whether a given window is a main window. A main window a program-controlled feature, not an OS feature. You have to figure out the main window manually. Have a look at EnumThreadWindows(), GetNextWindow(), and GetParent() for determing the parent<->child and sibling<->sibling relationships of all the windows belonging to the program. Hopefully, the main window will be the first sibling at the top of the window hierachy (but that's no guarantee either). > As an additional comment, I have found that FindExecutable > also retrieves dll modules in windows XP (like for .bmp files) > and (as far as I know) CreateProcess cannot use dlls. It can if you pass the .DLL info to RUNDLL32 or similar app that is designed for executing DLLs. Gambit
Technical Details
Message-ID:
<404fb6e5$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!border1.nntp.ash.giganews.com!border2.nntp.ash.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<404f4eb5$1@newsgroups.borland.com> <404f6927$1@newsgroups.borland.com> <404f9b65@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,6dc76ae9466e5f5 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-03-10 16:52:02 PST From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <404f4eb5$1@newsgroups.borland.com> <404f6927$1@newsgroups.borland.com> <404f9b65@newsgroups.borland.com> Subject: Re: is the window handle always the window handle? Date: Wed, 10 Mar 2004 16:55:25 -0800 Lines: 48 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 67.22.138.253 Message-ID: <404fb6e5$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1078965989 67.22.138.253 (10 Mar 2004 16:46:29 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!border1.nntp.ash.giganews.com!border2.nntp.ash.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail