我的GDI代码存在问题。 我用C ++。 这是代码:
int main()
{
DWORD pwdGDIStartup;
GdiplusStartupInput GDIstartupInp;
GdiplusStartup(&pwdGDIStartup, &GDIstartupInp, NULL);
Pen pnPen_Blue(Gdiplus::Color(255, 0, 0, 255), 2.0F);
PAINTSTRUCT ps;
LPCSTR LGameWindow = "Counter-Strike: Global Offensive";
HWND hGameWindow = FindWindow(NULL, LGameWindow);
Graphics graphics(GetDC(hGameWindow));
WCHAR string[] = L"Das";
HDC hdc;
HDC hdcBuffer;
hdc = BeginPaint(hGameWindow, &ps);
int i = 10000;
Font myFont(L"Arial", 10);
RectF layoutRect(100.00f, 100.00f, 100.00f, 150.00f);
StringFormat format;
format.SetAlignment(StringAlignmentCenter);
SolidBrush blackBrush(Color(255, 255, 100, 0));
;
for (;;) {
graphics.DrawString(
string,
11,
&myFont,
layoutRect,
&format,
&blackBrush);
i++;
graphics.DrawLine(&pnPen_Blue, 300, 700, 500, 600);
graphics.DrawLine(&pnPen_Blue, 400, 700, 400, 600);
}
}