Find parent window HWND from loaded DLL module?

372 views
Skip to first unread message

Den...@nospam.com

unread,
Dec 28, 2004, 1:11:30 PM12/28/04
to
I have a C++ DLL that is loaded by someone else's windows program.

I need to know the HWND of the parent window of that program so that I can issue
an error message if one occurs.

How do I find the parent window handle?

Thanks.

Dennis

KaKeeware

unread,
Dec 29, 2004, 6:18:38 PM12/29/04
to
> How do I find the parent window handle?

maybe try GetCurrentThreadId & EnumThreadWindows?

KaKeeware
http://www.kakeeware.com

r_z_...@pen_fact.com

unread,
Dec 30, 2004, 2:09:56 PM12/30/04
to

I'm a bit surprised no one has answered already. I've never tried to
do such a thing, because I gather it is tricky and have managed to
avoid needing it. With a little work, I found a useful search string
for google (http://groups.google.com/advanced_group_search). I
searched for
hwnd from hinstance
(exact phrase) and got 16 hits. I took a look at the first few, and
think they will be useful, though probably not what you really want.

Good luck.


>
>Thanks.
>
>Dennis
>

-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
500 Harrison Ave., Suite 3R
Boston, MA 02118
www.penfact.com

r_z_...@pen_fact.com

unread,
Dec 31, 2004, 2:15:37 PM12/31/04
to
On Thu, 30 Dec 2004 14:09:56 -0500, r_z_aret@pen_fact.com wrote:

>On Tue, 28 Dec 2004 18:11:30 GMT, Den...@NoSpam.com wrote:
>
>>I have a C++ DLL that is loaded by someone else's windows program.
>>
>>I need to know the HWND of the parent window of that program so that I can issue
>>an error message if one occurs.
>>
>>How do I find the parent window handle?
>
>I'm a bit surprised no one has answered already. I've never tried to

Oops. KaKeeware _had_ answered and I had read that post before I
replied. My memory slipped.

Den...@nospam.com

unread,
Dec 31, 2004, 3:11:38 PM12/31/04
to
Den...@NoSpam.com wrote:

I tried a handle=0 and it worked.

The message function put the message on top of the parent window with the
required "ok" button.

Dennis

r_z_...@pen_fact.com

unread,
Jan 3, 2005, 3:26:58 PM1/3/05
to

I suspect you're passing 0 to MessageBox. If so, then you are
effectively saying the window created by the MessageBox function is a
child of the desktop. That means the window will always be on top of
everything. This _may_ be appropriate in some situations, but is
generally considered rude. In particular, error messages for one
application should not be on top of everything.

>
>Dennis

Reply all
Reply to author
Forward
0 new messages