Ok, I have it moveable. But now I have another problem.
If the mouse is clicked within the left and right sides and within 25 from the top (ie: the title bar!) it will be moveable when you drag until you let go, just like a normal app window.
Now I'm using GetCursorPos() to get the coords (obviously ) on WM_MOUSEMOVE so that it'll move roughly the right direction. My problem is that it has an offset to the actual mouse position and I'm not sure how to make it correct.
http://mhtml.ithium.net/offsite/cursorMove.jpg - The blue dot is where my curosr would be about when draging, as you can see the tool window has a large offset on the x and y.
Code:
case WM_LBUTTONDOWN:
{
GetWindowRect(hwnd,&rc);
if(pos.x < rc.right && pos.x > rc.left && pos.y < rc.top+25 && pos.y > rc.top)
{
fDragMode = true;
SetCapture(hwnd);
return 0;
}
break;
}break;
case WM_MOUSEMOVE:
{
if(fDragMode == false) break;
GetCursorPos(&pos);
MoveWindow(hwnd,pos.x,pos.y,rc.right-rc.left,rc.bottom-rc.top,TRUE);
UpdateWindow(hwnd);
return 0;
}
case WM_LBUTTONUP:
{
if(fDragMode == false) break;
fDragMode = false;
ReleaseCapture();
return 0;
}
fDragMode, rc and pos are declared earlier as bool, RECT and POINT respectively.
Cheers,
Michael.