Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

VanKurt

SDL-window and the handle (HWND)

This topic is 5276 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there! After creating a SDL window (which is soooo simple!) I''d like to get the window''s handle, so that I can display Windows(TM) MessageBoxes and Dialogs in my new window. But somehow there seems to be no function to do that...so where do I get the HWND from? I suppose there HAS TO BE ONE (how else could a window be displayed under Windows?)... Thanks for your help! :-D

Share this post


Link to post
Share on other sites
Advertisement
Considering that SDL is a cross-platform library, it really can''t explicitely provide you MS Windows window handles. You might have some luck looking through the headers and finding where that handle is stored, then accessing it yourself.

Of course, that makes your application non-portable, which defeats the purpose of using SDL in the first place.


“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”
— Brian W. Kernighan

Share this post


Link to post
Share on other sites
Two Methods:

1) After you initialize SDL
SDL_SysWMinfo sdlinfo;
SDL_version sdlver;
SDL_VERSION(&sdlver);
sdlinfo.version = sdlver;
SDL_GetWMInfo(&sdlinfo);
gHwnd = sdlinfo.window;//All this to get the window handle

2) In the event loop
while( SDL_PollEvent( &event ) ) {
switch( event.type ) {
...
case SDL_SYSWMEVENT:
SDL_SysWMmsg *msg;
msg = event.syswm.msg;
gHwnd = msg->hwnd; //One way to get the windows handle
break;
...

BASS sound library needs the window handle so that why I needed it.

Share this post


Link to post
Share on other sites
"SDL_SysWMinfo" hu?? That function doesn''t seem to exist! (Nor the SDL-Docu nor my compiler knows it)...8-}

Share this post


Link to post
Share on other sites
Undocumented, you need a special header to get it

look at the SDL headers it should be apparent which one to include.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!