摘要:
练习三碰到的问题 一、窗口创建出来却显示不出来 出错原因: CW_USEDEFAULT 写成了 CW_DEFAULT 造成二、定时器 OnTimer 函数触发不了 出错原因: SetTimer(hWnd, 9001, 2 * 1000, TimerProc); 这个函数用回调函数了, 改成 SetTimer(hWnd, 9001, 2 * 1000, NULL);... 阅读全文
摘要:
//OnPaintvoid OnPaint(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam){ PAINTSTRUCT ps = { 0 }; HDC hDC = BeginPaint(hWnd, &ps); int marc = 0; //控制棋盘所在位置 for (int i = 0; i < 10; i++) //画九格横线 { Mo... 阅读全文
摘要:
//让Edit铺满整个客户区void OnSize(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam){ int nWidth = LOWORD(lParam); int nHeight = HIWORD(lParam); if (g_hEdit != NULL) { MoveWindow(g_hEdit, 0, 0, nWidth, nHei... 阅读全文
摘要:
/*读取文件到字符串pszBuff */ //打开文件,读取数据 FILE *pFile = NULL; fopen_s(&pFile, "c:\\1.txt", "r"); fseek(pFile, 0, SEEK_END);//把fseek移动到文件结尾 long nFileLen = ftell(pFile); //获得文件结尾的长度 fseek(pFile, 0, SEEK_SET); /... 阅读全文
摘要:
/*保存pszBuff字符串到文件*/ FILE *pFile = NULL; fopen_s(&pFile, "c:\\1.txt", "w+"); //打开文件 fwrite(pszBuff, nTextLen, 1, pFile); //把文件写进文件 fclose(pFile);来自为知笔记(Wiz) 阅读全文
摘要:
Win32简单模板// 2Window_Timer.cpp : 定义应用程序的入口点。//#include #include #include "resource1.h"//宏定义输出函数#define PrintLog(x) WriteConsole(g_hStdout, x, strlen(x), NULL, NULL);HINSTANCE g_hInst;HANDLE g_hStdout =... 阅读全文
摘要:
//显示菜单POINT point = { 0 }; //转换时需要POINT数据结构point.x = LOWORD(lParam); //客户区坐标point.y = HIWORD(lParam);//转换成屏幕坐标ClientToScreen(hWnd, &point);//point.x//point.y 这两个坐标可以直接使用 来自为知笔记(Wiz) 阅读全文
摘要:
bool flag if (flag) { xPost += 5; } if (!flag) { xPost -= 5; } if (xPost == 1000 || xPost == -5) //小技巧,这里的一定要是上面位移的倍数,否则会出现判断不正常的情况 { flag = !flag; } 来自为知笔记(Wiz) 阅读全文