I know the WM_NCLBUTTONDOWN trick to move the window...But i want to know how to do it manually using MoveWindow...I tried but seems i m missing something

	.elseif uMsg==WM_LBUTTONDOWN
mov tFlag,1
invoke GetCursorPos,addr lppointold
invoke SetCapture,hWnd

.elseif uMsg==WM_MOUSEMOVE
.if tFlag==1
invoke GetCursorPos,addr lppointnew
invoke GetWindowRect,hWnd,addr lRect1
mov eax,lppointnew.x
sub eax,lppointold.x
add eax,lRect1.left
mov xpos,eax
mov eax,lppointnew.y
sub eax,lppointold.y
add eax,lRect1.top
mov ypos,eax

mov eax,lRect1.right
sub eax,lRect1.left
mov pt1.x,eax

mov eax,lRect1.bottom
sub eax,lRect1.top
mov pt1.y,eax

invoke MoveWindow,hWnd,xpos,ypos,pt1.x,pt1.y,TRUE
Posted on 2006-08-21 10:25:17 by sonic
Try using SetWindowPos instead..
Posted on 2006-08-21 13:51:49 by Homer
hmm..I tried but it doesn't work....Maybe a little bit of modification to my code...:)...Well i can't figure out why it's not working.....I think the problem is coming due to x n y position..but my method of getting the coordinates looks ok
Posted on 2006-08-21 16:09:59 by sonic

.elseif uMsg==WM_LBUTTONDOWN
mov tFlag,1
invoke GetWindowRect,hWnd,addr rect
invoke GetCursorPos,addr lppointold
mov eax,rect.left
mov edx,rect.top
sub eax,lppointold.x
sub edx,lppointold.y
mov lppointold.x,eax
mov lppointold.y,edx
invoke SetCapture,hWnd

.elseif uMsg==WM_MOUSEMOVE
.if tFlag==1
invoke GetCursorPos,addr lppointnew
mov eax,lppointold.x
mov edx,lppointold.y
add eax,lppointnew.x
add edx,lppointnew.y
invoke SetWindowPos,hWnd,0,eax,edx,0,0,SWP_NOSIZE or SWP_NOZORDER

P.S.: I've used it successfully some time ago, until I learnt about the WM_NCLBUTTONDOWN  :)

Your code doesn't work correctly, because on every new WM_MOUSEMOVE you do:
WindowX += newpoint - oldpoint;
(but you skipped  "oldpoint=newpoint" )

So, if your window is at 0:0, and you first move 100px,them move 1 px:
WindowX = 0 + 100; // first WM_MOUSEMOVE
WindowX = 100 + 101; //second WM_M..M..
Posted on 2006-08-21 18:20:20 by Ultrano
Oh...Thanks...Silly Mistake :P
Posted on 2006-08-22 06:36:39 by sonic