Error while accessing GetDC(NULL) in vs2015 c++ windows10. Error:C3861'GetDC' identifier not found and Identifier 'GetDC' is undefined.

290 views Asked by At

I need a winRt c++ component , callable from JavaScript that could control screen brightness. I am unable to call the function GetDC(NULL), error pops up. Here is my code snippet:

#include "pch.h"
#include "Class1.h" // The one which i created.
#include <windows.h>

....

BOOL Class1::SetBrightness(HDC hDC, WORD wBrightness)
{

BOOL bReturn = FALSE;
HDC hGammaDC = hDC;


if (hDC == NULL)
{

HDC hGammaDC = GetDC(NULL); //  Error 'GetDC' identifier not found.
}
if (hGammaDC != NULL)
{
WORD GammaArray[3][256];

for (int iIndex = 0; iIndex < 256; iIndex++)
{
int iArrayValue = iIndex * (wBrightness + 128);

if (iArrayValue > 65535)
iArrayValue = 65535;

GammaArray[0][iIndex] =
GammaArray[1][iIndex] =
GammaArray[2][iIndex] = (WORD)iArrayValue;

}
bReturn = SetDeviceGammaRamp(hGammaDC, GammaArray);
}

if (hDC == NULL)
ReleaseDC(NULL, hGammaDC);

return bReturn;
}

Reply means a lot to me. Thanks in advance

0

There are 0 answers