🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #11720

Re: How to retrieve HWND trough HINSTANCE or HANDLE

#11720
From: Remy Lebeau (TeamB)
Date: Tue, 20 Jan 2004 18:27
26 lines
2128 bytes
"Rodrigo" <rmorteo@eudoramail.com> wrote in message
news:400d5cee$1@newsgroups.borland.com...

> The the information returned to SHELLEXECUTEINFO (by ShellExecuteEx)
> only returns a HANDLE to the hProcess and a HINSTANCE to hInstApp.
> My question is how to associate one (or both) of those handles to the
app's
> main window handle so I can post messages to it?

There is no direct way to do it.  You will need to use EnumWindows() to
enumerate through every available window manually.  You can use
GetWindowLong() to obtain an HINSTANCE for each window and compare it to the
HINSTANCE that ShellExecuteEx() returns.  Alternatively, if you use
CreateProcess() instead of ShellExecuteEx(), you will get a process ID as
well, which you can then use to do comparisons using
GetWindowThreadProcessId() instead of GetWindowLong().

> Specificaly I need to use the IsIconic() fuction to check if the spawned
> apps are minimized and, if so, post a message to restore them.

Why not simply set the nShow member of the SHELLEXECUTEINFO structure
instead to force the spawned app to always be restored in the first place?


Gambit
Technical Details
Message-ID: <400d719e$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <400d5cee$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,1512656f64100b24
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-01-20 10:39:28 PST
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <400d5cee$1@newsgroups.borland.com>
Subject: Re: How to retrieve HWND trough HINSTANCE or HANDLE
Date: Tue, 20 Jan 2004 10:27:47 -0800
Lines: 28
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: <400d719e$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1074622878 67.22.138.253 (20 Jan 2004 10:21:18 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail