Greetings. There is a task: when the mouse moves in a window, the static should move inside this window. For some reason unknown to me, the WM_MOUSEMOVE message works out continuously if the mouse cursor is in the window, but does not move. The static itself, like the dialog box, is created in the project resources. It was checked on 2 laptops where the touchpad was disconnected programmatically and the mouse disconnected. The code itself:
BOOL CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM); void GetStaticRect(HWND hWnd, RECT &rect); int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPTSTR lpszCmdLine, int nCmdShow) { return DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAINDIALOG), NULL, DlgProc); } HWND hStatic; RECT rect; BOOL CALLBACK DlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CLOSE: EndDialog(hWnd, 0); return TRUE; case WM_INITDIALOG: hStatic = GetDlgItem(hWnd, IDC_RUNNINGSTATIC); return TRUE; case WM_MOUSEMOVE: GetStaticRect(hWnd, rect); MoveWindow(hStatic, rect.left + 1, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE); return TRUE; } return FALSE; } void GetStaticRect(HWND hWnd, RECT &rect) { GetWindowRect(hStatic, &rect); POINT p; px = rect.left; py = rect.top; ScreenToClient(hWnd, &p); rect.left = px; rect.top = py; px = rect.right; py = rect.bottom; ScreenToClient(hWnd, &p); rect.right = px; rect.bottom = py; } Please help with finding the error. Thank you for attention.