Moving a window without border
How can i move a window that has no border in Visual C?
I need a routine that does the moving and the resizing
MoveWindow() can move and resize a window, is that what you''re looking for?
no ... i''m lookin for a routine that let''s me move the window using the mouse... i''m not asking for the function that does the mouvement .. but a function that captures the mouse position and moves my window
Are you looking for a way to move/resize a borderless window with the mouse? If so, the easiest way is probably to write a handler for the WM_NCHITTEST message. Put something like this in your WindowProc:
You could also test for HTBOTTOMLEFT, HTBOTTOMRIGHT, etc.
switch(message) { case WM_NCHITTEST: { RECT rc; GetClientRect(m_hWnd, &rc); // Get size of the client area POINT ptMouse = {LOWORD(lParam), HIWORD(lParam)}; ScreenToClient(m_hWnd, &ptMouse); // Convert cursor pos to client coords if(ptMouse.y < 3) return HTTOP; if(ptMouse.y < 50) return HTCAPTION; if(ptMouse.x < 3) return HTLEFT; if(ptMouse.x > rc.right-3) return HTRIGHT; if(ptMouse.y > rc.bottom-3) return HTBOTTOM; return HTCLIENT; // By default, the cursor is within the client area } break; }
You could also test for HTBOTTOMLEFT, HTBOTTOMRIGHT, etc.
"-1 x -1 = +1 is stupid and evil."-- Gene Ray
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement