Advertisement

Moving a window without border

Started by May 23, 2002 06:06 AM
4 comments, last by TimeStorm 22 years, 5 months ago
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?
Advertisement
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:


  	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
ok... i hope it will work
This is what I use :

case WM_LBUTTONDOWN:
return DefWindowProc(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, lParam);
break;

Use this in your Wnd_Proc. The window reacts as if the user had started to drag the window by the caption-bar.

Works for me...
--< beer is liquified bread >--

This topic is closed to new replies.

Advertisement