- //该函数用于在 rect区域内输出字符串dataShow
- void DrawEditControl(CHAR* dataShow)
- {
- HDC hdc;
- RECT rect;
- static HBRUSH hbrBkgnd; // handle of background-color brush
- static COLORREF crBkgnd;
- hdc = GetDC(g_hWnd);
- crBkgnd = GetBkColor(hdc);
- hbrBkgnd = CreateSolidBrush(crBkgnd);
- SetRect(&rect, 15, 15, 170, 138);
- FillRect(hdc, &rect, hbrBkgnd); //清空该矩形内容
- DrawTextA(hdc, dataShow, -1,&rect, DT_RIGHT);
- ReleaseDC(g_hWnd, hdc);
- }
- //调用函数
- int AddKeyNum(CHAR* key)
- {
- if (strlen(szKeyNum) < MAX_LEN)
- {
- strcat(szKeyNum, key);
- DrawEditControl(szKeyNum);
- // SendMessage(g_hWnd, WM_PAINT, 0, 0);
- return 1;
- }
- else
- return 0;
- }