For Win32,
static void HandleClientAreaDrag (HWND hwnd, UINT msg, int mouseX, int mouseY)
{
static int captureX = 0;
static int captureY = 0;
switch (msg)
{
case WM_LBUTTONDOWN:
captureX = mouseX;
captureY = mouseY;
SetCapture (hwnd);
break;
case WM_LBUTTONUP:
ReleaseCapture();
break;
case WM_MOUSEMOVE:
if (GetCapture() == hwnd)
{
RECT rc;
GetWindowRect (hwnd, &rc);
int newX = rc.left + mouseX - captureX;
int newY = rc.top + mouseY - captureY;
int width = rc.right - rc.left;
int height = rc.bottom - rc.top;
UINT flags = SWP_NOZORDER | SWP_NOACTIVATE;
SetWindowPos (hwnd, NULL, newX, newY, width, height, flags);
}
break;
}
}
case WM_MOUSEMOVE:
{
int xPos = GET_X_LPARAM(lParam);
int yPos = GET_Y_LPARAM(lParam);
HandleClientAreaDrag(m_hWnd, WM_MOUSEMOVE, xPos, yPos );
break;
}
case WM_LBUTTONUP:
{
int xPos = GET_X_LPARAM(lParam);
int yPos = GET_Y_LPARAM(lParam);
HandleClientAreaDrag(m_hWnd, WM_LBUTTONUP, xPos, yPos);
break;
}
case WM_LBUTTONDOWN:
{
int xPos = GET_X_LPARAM(lParam);
int yPos = GET_Y_LPARAM(lParam);
HandleClientAreaDrag(m_hWnd, WM_LBUTTONDOWN, xPos, yPos );
break;
}
This might be helpful for you.
http://www.programmersheaven.com/mb/CandCPP/60606/60606/move-a-window-in-mfc/