ok, i created a program that has no border, but i still wanted it to be moveable, so i wrote this code, and found that if the user moves the mouse and clicks fast enough, the window manages to move itself entirely off the screen. it doesn't get closed or hidden, just moved off the viewable boundaries, any help would be much appreciated. .elseif uMsg==WM_LBUTTONDOWN .if KeyDown==FALSE mov eax,lParam shr eax,16 mov lMouseY0,eax mov eax,lParam and eax,0FFFFh mov lMouseX0,eax mov KeyDown,TRUE invoke SetCapture,hWnd .endif .elseif uMsg==WM_LBUTTONUP .if KeyDown==TRUE mov KeyDown,FALSE invoke ReleaseCapture .endif .elseif uMsg==WM_MOUSEMOVE .if KeyDown==TRUE invoke GetWindowRect,hWnd,addr rect mov eax,lParam and eax,0FFFFh sub eax,lMouseX0 add rect.left,eax mov eax,lParam shr eax,16 sub eax,lMouseY0 add rect.top,eax invoke SetWindowPos, hWnd, NULL, rect.left, rect.top, NULL, NULL, SWP_NOZORDER or SWP_NOSIZE
Posted on 2001-01-12 19:13:00 by mc
The usual method is to fool Windows that your client area IS the title bar. You can do this by processing WM_NCHITTEST. Windows sends this message to your window everytime it needs to determine what part of your window the mouse cursor is currently resting on. If you always return the value HTCAPTION, Windows will assume that everywhere in your window (except the child windows) is the title bar and thus you can drag the window anywhere without the title bar .elseif uMsg== WM_NCHITTEST mov eax, HTCAPTION ret
Posted on 2001-01-12 19:33:00 by Iczelion
i was actually using the code i had in order to keep windows from ever creating the dotted box while dragging, ie. i want windows to always display my client and it's contents. using the wm_ncihittest method, it leaves the image of the client behind and moves a dotted box.
Posted on 2001-01-12 19:42:00 by mc
I achieve that result by checking "Show window contents while dragging" in the display property. Perhaps there is a special API for doing that
Posted on 2001-01-12 20:34:00 by Iczelion
I always moved the mouse like this: In WM_LBUTTONDOWN, hit test to see if the mouse clicked on the MOVE spot. If it did, save the mouse X-Y position, and SetCapture the mouse to your window. Also set a flag that the window is to be moved with the mouse. In WM_MOUSEMOVE, check your flag. If valid, GetWindowRect and compute: new rect.top = present mouse Y - initial Y0 new rect.left = present mouse X - initial X0 Then just SetWindowPos the window there. Finally, in WM_LBUTTONUP, reset the flag and ReleaseCapture the mouse. This moves the whole window with the mouse, not just the outline rect no matter what the sys settings are. I posted some code including this, check Custom window shapes at here.is/COMinASM
Posted on 2001-01-12 23:54:00 by Ernie
well Ernie, that's basically the same code i've got and it still has problems with fast movements. for some reason it likes placing the window off the viewable screen dimensions, it's really driving me nuts, i guess i'll just keep at it. maybe it's just in windows 2000 that this happens..
Posted on 2001-01-13 17:52:00 by mc
If the problem is the window going offscreen, you may just need to add the extra code to ensure your new rectangle coordinates aren't offscreen. To do that, start by getting the coordinates of the desktop window.
Posted on 2001-01-13 18:32:00 by tank
Also, in Win2k, you may want to see if you need to use 32-bit coordinates. You may need them if you are using a very high resolution screen.
Posted on 2001-01-14 03:14:00 by tank
I'm not sure if you can use this: .elseif uMsg==WM_LBUTTONDOWN mov eax, lParam invoke PostMessage,hWnd,WM_NCLBUTTONDOWN,HTCAPTION,eax cya
Posted on 2001-01-14 05:50:00 by [SaFc0n]