Article View: borland.public.cppbuilder.nativeapi
Article #10848Re: is the window handle always the window handle?
From: Mortz
Date: Wed, 10 Mar 2004 22:53
Date: Wed, 10 Mar 2004 22:53
50 lines
3091 bytes
3091 bytes
Hi everyone: Thank you for your answer Gambit... > An HWND always points to the same window at all times. It does not change > value anytime during the lifetime of the window that it points to. If your > main code is posting to different windows at different times, then you are > working with multiple HWNDs to begin with. 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; thats why sometimes I get a DDE server HWND instead of the app's main window. So, what to do?, I just need to post messages the main windows of applications spawned with "CreateProcess" any ideas? > Why not just pass the NodeInfo* pointer itself directly, and leave the > TreeNode alone altogether? I pass the node as a parameter because when the process finishes I still need to know what node in the TTreeView refers to that process in order to update the treeview labels. > You should not be re-retrieving the HWND anew each time, especially since a > HWND never changes anyway. Also, a program may have multiple windows, your > current code would not be guaranteed to find the same HWND each time due to > Z-order changes and such. You should only be retreive the desired window > once and then keep it. Don't go re-looking for the window over and over. > It is unnecessary. I noticed that calling "LookForWindowHandle" right after the process is created does not guarantee to retrieve the handle (maybe because of the time that takes for an application to load). This is why I re-retrieve the HWND. Although, you are right! once gotten there's no need to re-retrieve it. Now, if a program can have multiple windows (like word documents or IE) how does windows distinguishes among all them?, isn't that why the HWND is there in the first place? 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. Any help will be greatly appreciated...
Technical Details
Message-ID:
<404f9b65@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<404f4eb5$1@newsgroups.borland.com> <404f6927$1@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 14:59:38 PST Reply-To: "Mortz" <rmorteo@hotmail.com> From: "Mortz" <rmorteo@hotmail.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <404f4eb5$1@newsgroups.borland.com> <404f6927$1@newsgroups.borland.com> Subject: Re: is the window handle always the window handle? Date: Wed, 10 Mar 2004 14:53:10 -0800 Lines: 53 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: 200.38.16.98 Message-ID: <404f9b65@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1078958949 200.38.16.98 (10 Mar 2004 14:49:09 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail