Windows

Win32 API绘图避免闪烁

首先在创建窗口时候设置背景为NULL wc.hbrBackground = NULL; 然后在WM_CREATE中 hdc = GetDC(hWnd); //获取设备 hdcBuffer = CreateCompatibleDC(hdc); //给设备分配一个内存空间 hBitMap = CreateCompatibleBitmap(hdc, 1200, 700); //创建一个cxClient, c…

Win32API窗口输出浮点数

使用TextOut()在窗口中输出数值时一般的方式是,先将数值存到字符数组,再打印出来: wsprintf(szData, TEXT("Data = %d"), data); TextOut(hdc, x, y, szData, lstrlen(szData)); 有一个问题是, wsprintf()这个函数无法处理浮点数。这里需要将其替换成spri…

Real Loop in Win32 Program

To introduce real loop in Win32 program. “GetMessage()” need to be replaced by “PeekMessage()” The traditional GetMessage loop looks like: while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0) { if (bRet == -1) { break; } else { TranslateMess…

(Microsoft VC++ Express)LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt

There are several "cvtres.exe" in C disk, maybe installed by .NET Framework. Replace the old one in VC/bin by the first one(new?) in C disk. 连接器LNK是通过调用cvtres.exe完成文件向coff格式的转换的,所以出现这种错误的原因就是cvtres.exe出现…

マウスで円を描くコード

「猫でもわかるWindowsプログラミング」より ↓こんな感じ。 #include <windows.h> LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); ATOM InitApp(HINSTANCE); BOOL InitInstance(HINSTANCE, int); void DrawRect(HWND, POINTS, POINTS); TCHAR szClassName[] = </windows.h>…