can't get a device context

Hi!
I’m having some problems when running my
OGL programs in some machines. It works fine
in many machines but in others it fails when
it tries to get the device context like in the line below:
(hDC=GetDC(hWnd))

What can make this procedure to fail??

Thanks a lot for your help!

Hi !

Are you sure that’s the problem ?, getting a DC from a window (that does exist…) would never fail (unless you have messed up bad on a Windows95/98 where you might run out of DC’s if you don’t release them back when you are done with them).

Any difference between the compiters you tried on (W95/98/ME/NT/W2K/XP, video card and so on) ?

Mikael

When it fails, get the last error to see why.

I will make your life easier use this func to get error msg.

if((hDC = GetDC(hWnd)) == NULL){
GetError(“GedDC failed”);
exit(#);
}

void GetError (char *fun_name){
LPVOID lpMsgBuf;
FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL
);
MessageBox( NULL, (LPCTSTR)lpMsgBuf, fun_name, MB_OK | MB_ICONINFORMATION );
LocalFree( lpMsgBuf );
}