0

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.
}
Yoranos
  • 11
  • You pasted C++ code in a C# project. – Jimi Feb 02 '20 at 18:07
  • Oh serious? ;0 My friend is developer and he gave me, So what shall I do? Maybe u can make for me a code for c#? or help me to learn how to make a one? – Yoranos Feb 02 '20 at 18:42
  • 2
    This platform is a place to get help with programming, not to get programming done for you. There are tons of resources out there to get you started. – Jesse Feb 02 '20 at 20:54

0 Answers0