How to get Windows Device Context?

Is there any way to get the windows device context (HDC) from SDL_Surface or is there any other way to get an HDC for a window that has been created using SDL? Thanks in advance.

sohyl.---------------------------------
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!

Quoting sohyl siddiqui <sohyl_s at yahoo.com>:

Is there any way to get the windows device context (HDC) from
SDL_Surface or is there any other way to get an HDC for a window that
has been created using SDL? Thanks in advance.

There are a couple of globals that exist when SDL is compiled on windows that
you can access. I don’t remember it exactly – I don’t have the code in front of
me – but you can search through the SDL code to find the details.

Code like this will get you access to the global that you’re not really looking for:

extern “C” { // only needed if your code is C++
extern HWND SDL_Window;
}

I think SDL_Window is the right name. If you search for it and HDC, you’ll
probably find what you’re looking for. I have done this before, so I know it is
there.

Jeff Jackowski

Here’s the correct API use:

#ifdef _WIN32
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if ( SDL_GetWMInfo(&info) < 0 )
fail();

hwnd = info.window;

#endifOn Wed, Jul 07, 2004 at 12:48:29PM -0500, Jeff Jackowski wrote:

Is there any way to get the windows device context (HDC) from
SDL_Surface or is there any other way to get an HDC for a window that
has been created using SDL? Thanks in advance.

There are a couple of globals that exist when SDL is compiled on windows that
you can access. I don’t remember it exactly – I don’t have the code in front of
me – but you can search through the SDL code to find the details.

Code like this will get you access to the global that you’re not really looking for:

extern “C” { // only needed if your code is C++
extern HWND SDL_Window;
}


Glenn Maynard