Finding HWND of the current thread

Brian Hook <[email protected]>
Newsgroups gmane.games.devel.windows
Message-ID <2004715123751.898249@GATEWAY>
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
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.