openMSX
win32-windowhandle.cc
Go to the documentation of this file.
1 #ifdef _WIN32
2 
3 #include "win32-windowhandle.hh"
4 #include "MSXException.hh"
5 #include <SDL.h>
6 #ifdef WIN32_LEAN_AND_MEAN
7 #undef WIN32_LEAN_AND_MEAN // For <SDL_syswm.h>, which defines it carelessly
8 #endif
9 #include <SDL_syswm.h>
10 
11 namespace openmsx {
12 
13 HWND getWindowHandle()
14 {
15  // There is no window handle until the video subsystem has been initialized.
16  if (!SDL_WasInit(SDL_INIT_VIDEO)) {
17  SDL_InitSubSystem(SDL_INIT_VIDEO);
18  }
19 
20  SDL_SysWMinfo info;
21  SDL_VERSION(&info.version);
22  if (SDL_GetWMInfo(&info) != 1) {
23  throw MSXException("SDL_GetWMInfo failed: ", SDL_GetError());
24  }
25  return info.window;
26 }
27 
28 } // namespace openmsx
29 
30 #endif
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5