Sdl window id (win32)

Under windows, I create an OpenGL window using stadard SDL_Init (SDL
1.2.7)
I need to get the window id of that window in order to pop up a
MFC CFileDialog as a child window.

I know that one solution is to use the SDL_WINDOWID hack but I want my
application to remain as cross platform as possible.

When i try to use the SDL_GetWMInfo after window initialization the
function returns -1
and the
SDL_SysWMInfo::window variable is invalid.

Does the SDL_GetWMInfo work with OpenGL???

Regards,
Nick

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Vasileiou Nikolaos wrote:
| Under windows, I create an OpenGL window using stadard SDL_Init (SDL
| 1.2.7)
| I need to get the window id of that window in order to pop up a
| MFC CFileDialog as a child window.
|
| I know that one solution is to use the SDL_WINDOWID hack but I want my
| application to remain as cross platform as possible.

Erm, you just mentioned using MFC, surely that’s gonna scupper any
possible cross platform idea?


http://www.mattsscripts.co.uk/
~ - A great source for free CGI and stuff

Computers will not be perfected until they can compute how much more
than the estimate the job will cost.
~ th
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBKhp/ms1059AAPcwRAhjDAKCjFJdwaWpmt8WoLZwfTlNqc+AqAQCg1iqh
248MJBDPC+BJwbcwKSYprv4=
=ta5c
-----END PGP SIGNATURE-----

Under windows, I create an OpenGL window using stadard SDL_Init (SDL
1.2.7)
I need to get the window id of that window in order to pop up a
MFC CFileDialog as a child window.

I know that one solution is to use the SDL_WINDOWID hack but I want my
application to remain as cross platform as possible.

When i try to use the SDL_GetWMInfo after window initialization the
function returns -1
and the
SDL_SysWMInfo::window variable is invalid.

Does the SDL_GetWMInfo work with OpenGL???

It should. Did you fill in the version structure that was passed in?
See the “scrap” demo on the SDL website to see how this is done.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Vasileiou Nikolaos wrote:
| Under windows, I create an OpenGL window using stadard SDL_Init (SDL
| 1.2.7)
| I need to get the window id of that window in order to pop up a
| MFC CFileDialog as a child window.
|
| I know that one solution is to use the SDL_WINDOWID hack but I want my
| application to remain as cross platform as possible.

Erm, you just mentioned using MFC, surely that’s gonna scupper any
possible cross platform idea?

Using an MFC file requester on windows, and a custom file requester on
unix systems I think maintains the cross platform idea and it
works on my application great so far.

//////

Sam, thanks for the help!

Maybe it should be made more clear on the sdl_syswm.h header doc that the
version
information should be filled before calling SDL_GetWMInfo along with a
short example such as:

SDL_SysWMinfo info;
SDL_VERSION(&info.version);
SDL_GetWMInfo(&info);

It could be very usefull to new usersOn Mon, 23 Aug 2004, Matt Wilson wrote:

Sam Lantinga wrote:

Under windows, I create an OpenGL window using stadard SDL_Init (SDL
1.2.7)
I need to get the window id of that window in order to pop up a
MFC CFileDialog as a child window.

Perhaps you should take a look at wxWidgets. This would provide a
cross-platform solution:

http://www.wxwidgets.org/manuals/2.4.2/wx140.htm#wxfiledialog

Then when you find a solution, you could post the code so we can all se
how to do cross platform open file dialogs. :slight_smile:

Or… alternativley if you use Win32 API rather than MFC, you can call
’GetOpenFileName’. You just need to fill in an ‘OPENFILENAME’ struct,
you can leave the hwnd NULL, then it will be a child of the desktop window:

This will work fine with MFC. As MFC just sits on top of API anyway.

/*


  • This code has never seen a compiler, so it probably will need tweaking
    */

OPENFILENAME openFileName;

char fileName[MAX_PATH];

fileName[0]=0;

memset((void*)(&openFileName), 0, sizeof(OPENFILENAME));

openFileName.lStructSize=sizeof(OPENFILENAME);
openFileName.hInstance=GetModuleHandle(NULL);
openFileName.lpstrFilter=“Foo Files\0*.foo\0\0”;
openFileName.lpstrFile=&buffer[0];
openFileName.nMaxFile=MAX_PATH;
openFileName.lpstrTitle=“Open a “foo” file for input”;
openFileName.flags=OFN_FILEMUSTEXIST ;

::GetOpenFileName(&openFileName);

/*


*/

HTH,

  • Tom