用c语言api编程 如何将文本或者数字放入某个图形中,并且二者可以一起移动

来源:百度知道 编辑:UC知道 时间:2024/05/24 20:48:03
能提供一段代码吗

弄个static控件
在控件里画图,
移动只要移动控件就行了
static HWND hStatic;
..
case WM_CREATE:
hStatic = CreateWindow(_T("static"), _T("aa"), WS_CHILD | WS_VISIBLE | WS_BORDER | SS_CENTER,
100, 100, 80, 80, hWnd, (HMENU)1, hInst, 0);
InvalidateRect(hStatic, NULL, 0);
break;
case WM_KEYDOWN:
MoveWindow(hStatic, 0, 0, 80, 80, 1);
//InvalidateRect(hStatic, NULL, 0);
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);

hdc = BeginPaint(hStatic, &ps);
Rectangle(hdc, 10, 10, 40, 40);
TextOut(hdc, 20, 20, _T("123"), 3);
EndPaint(hWnd, &ps);
break;