My coding isn't working what's wrong here??? I tried to set my window direct as "Dmo" (Game) But when I'm using this code I've 31 Errors Like : Severity Code Description Project File Line Suppression State Error CS0103 The name 'NULL' does not exist in the current context Or : Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'HBITMAP' could not be found (are you missing a using directive or an assembly reference?)
class Win32
void CaptureWindow()
{
RECT rc;
HWND hwnd = ::FindWindow(0, _T("Dmo"));//::FindWindow(0,_T("ScreenCapture (Running) - Microsoft Visual Studio"));//::FindWindow(0, _T("Calculator"));//= FindWindow("Notepad", NULL); //You get the ideal?
if (hwnd == NULL)
{
return;
}
GetClientRect(hwnd, &rc);
//create
HDC hdcScreen = GetDC(NULL);
HDC hdc = CreateCompatibleDC(hdcScreen);
HBITMAP hbmp = CreateCompatibleBitmap(hdcScreen,
rc.right - rc.left, rc.bottom - rc.top);
SelectObject(hdc, hbmp);
//Print to memory hdc
PrintWindow(hwnd, hdc, PW_CLIENTONLY);
//copy to clipboard
OpenClipboard(NULL);
EmptyClipboard();
SetClipboardData(CF_BITMAP, hbmp);
CloseClipboard();
//release
DeleteDC(hdc);
DeleteObject(hbmp);
ReleaseDC(NULL, hdcScreen);
//Play(TEXT("photoclick.wav"));//This is just a function to play a sound, you can write it yourself, but it doesn't matter in this example so I comment it out.
}