Valhalla Legends Archive

Programming => General Programming => C/C++ Programming => Topic started by: Akamas on April 07, 2004, 07:31 PM

Title: Get Device Caps
Post by: Akamas on April 07, 2004, 07:31 PM
GetDeviceCaps(hDC, COLORRES) == 18

I need to use the above code in an if statement in a MFC application but I cannot get it to work because VC6++ tells me that hDC is undeclared which isn't true because just before this code I declare the following:

HDC hDC;

It seems I can't retrieve the device context properly for some reason. I am trying to run this code from a dialog box, I don't know if that is part of the problem or not. Most likely you'll need the code here it is.


HDC hDC;
HWND hWnd;
hDC = GetDC(hWnd);

if (GetDeviceCaps(hDC, COLORRES) == 18)
{
AfxMessageBox("My Message");
}

ReleaseDC(hWnd, hDC);



This is the exact code I use but still hDC and hWnd are said to be undeclared by the compiler.
Title: Re:Get Device Caps
Post by: Eibro on April 07, 2004, 08:05 PM
#include <windows.h>

Also, don't do this:
HWND hWnd;
hDC = GetDC(hWnd);

hWnd is uninitialized, either pass GetDC a valid window handle or NULL.
Title: Re:Get Device Caps
Post by: Akamas on April 07, 2004, 08:16 PM
Alright, I'll try that tommorrow at work, thanks alot for your assistance.