RE: Finding HWND of the current thread

Andrew Grant <[email protected]>
Newsgroups gmane.games.devel.windows
Message-ID <56C9B4CE640B7044AAF74431F9C963E103BDF151@tankard.brighton.climax.co.uk>
Couldn't you just create a simple hidden window and pass that handle in?

Really though if this is a library wouldn't you want to allow the user to
pass in a handle and handle the case of being a console app at a higher
level...

Andy



-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Brian
Hook
Sent: 15 July 2004 17:38
To: [email protected]
Subject: [GD-Windows] Finding HWND of the current thread

For my simple audio library I'm stuck doing something a little gross, and
that's passing an HWND to the library upon initialization, only because
IDirectSound::SetCooperativeLevel() needs an HWND.

Now, you CAN use GetDesktopWindow() and NULL, but that's not the correct way
and there are supposedly some failure cases when you use those (e.g.
multiple instances using GetDesktopWindow()), and God knows what the HWND is
really used for in DirectSound and what can happen if you do something like
create a hidden window and bind DS to that instead of to your real
application window.

Anyway, that aside, instead of passing in HWND, I was thinking it might be
possible to find the window of the current thread by enumerating all windows
in the system and comparing their owner threads with the current thread and
using that.

Is there anything glaringly wrong with that, other than the potential
situation that there is none (e.g. console application) and having to
fallback at that point.

Brian




-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise
J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idG21&alloc_id040&op=click
_______________________________________________
Gamedevlists-windows mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_idU5


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
Gamedevlists-windows mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=555
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.