先写个GDI绘制方块的程序以便测试
#include<Windows.h>
#include<tchar.h>
#define TOP_HEIGHT 25
RECT g_winRect = {
0 };
HWND g_hWnd_Overlay;
void DrawEsp(HWND hwnd, float x, float y, float width, float height);
LRESULT CALLBACK WindowProc_Overlay(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
void CreateOverlayWindow();
void Clear();
BOOL GameIsForegroundWindow();
//定义游戏句柄
HWND gamehwnd= FindWindowW(L"valve001", NULL);
int main()
{
if (gamehwnd == NULL)
return -1;
GetWindowRect(gamehwnd, &g_winRect);
g_winRect.top += TOP_HEIGHT;
CreateOverlayWindow();
MSG msg;
ZeroMemory(&msg, sizeof(MSG));
while (msg.message != WM_QUIT)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg)