Valhalla Legends Forums Archive | C/C++ Programming | Get Device Caps

AuthorMessageTime
KoRRuPT
[code]GetDeviceCaps(hDC, COLORRES) == 18[/code]

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:

[code]HDC hDC;[/code]

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.

[code]
HDC hDC;
HWND hWnd;
hDC = GetDC(hWnd);

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

ReleaseDC(hWnd, hDC);

[/code]

This is the exact code I use but still hDC and hWnd are said to be undeclared by the compiler.
April 8, 2004, 12:31 AM
Eibro
#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.
April 8, 2004, 1:05 AM
KoRRuPT
Alright, I'll try that tommorrow at work, thanks alot for your assistance.
April 8, 2004, 1:16 AM

Search