SDL-window and the handle (HWND)

Started by
3 comments, last by VanKurt 19 years, 10 months ago
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
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
"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
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.
0xa0000000
"SDL_SysWMinfo" hu?? That function doesn''t seem to exist! (Nor the SDL-Docu nor my compiler knows it)...8-}
Undocumented, you need a special header to get it

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

This topic is closed to new replies.

Advertisement