There are many gui's like Windows, Linux flavors, etc. But what if we want to make a new one ? Where to start ? Well i started by trying to make a colored window with a bar on top. So far so good. But problems started when i tried to use the mouse ...

The problem is i can't fix the mouse position inside top area when i am pressing a button. If i move it "violently" up, down, left, right it will go off the limits of top bar ...:(

Here is my code. Any ideas ? Making experiments with this for hours. I am using Windows 7.

'check if mouse is in top area if pressed=1 then if (e.x>=0 and e.x<=1024 and e.y>=0 and e.y<=40) then 'move window ScreenControl GET_WINDOW_POS, wx, wy ScreenControl SET_WINDOW_POS, wx + e.dx, wy + e.dy end if end if

Still trying to move shapedwindow with mouse to work just like windows. Well made some advances. This is my best mojo so far.Left and right movement with mouse in top area is working fine(i think). Problems start when you move window up and down. But if you move window at low speed everything looks to be fine. At high speed mouse tends to block movement. I think mouse is not staying in the same place even with setmouse activated. setmouse bug/lag ? Any ideas ?

if (ScreenEvent(@e)) then Select Case e.type Case EVENT_MOUSE_BUTTON_PRESS If (e.button = BUTTON_LEFT) Then getmouse(mxpressed,mypressed,,buttons) if (mxpressed>=0 and mxpressed<=1023 and mypressed>=0 and mypressed<=40) then dragging = 1

mxold=mxpressed myold=mypressed

end if end if

Case EVENT_MOUSE_BUTTON_RELEASE If (e.button = BUTTON_LEFT) Then dragging = 0 end if

Sub drawpolygon(p() As Point,Byref col As Ulong,Byref c As Point=type(0,0)) Dim k As Long=Ubound(p)+1 Dim As Long index,nextindex Dim As Long cx,cy For n As Long=1 To Ubound(p) cx+=p(n).x:cy+=p(n).y index=n Mod k:nextindex=(n+1) Mod k If nextindex=0 Then nextindex=1 Line (p(index).x,p(index).y)-(p(nextindex).x,p(nextindex).y),col Next cx/=Ubound(p):cy/=Ubound(p) c=type(cx,cy) Paint (cx,cy),col,colEnd Sub

sub circulate(p() as point,byref c as point)

For p1 as long = lbound(p) To ubound(p)-1 For p2 as long = p1 + 1 To ubound(p) if atan2(p(p1).y-c.y,p(p1).x-c.x)< atan2(p(p2).y-c.y,p(p2).x-c.x) then swap p(p1),p(p2) end if Next p2 Next p1end sub

Sub _line(x1 As Integer,y1 As Integer,x2 As Integer,y2 As Integer,l As Integer,col As Uinteger,Byref xp As Integer=0,Byref yp As Integer=0) Dim As Integer diffx=x2-x1,diffy=y2-y1,ln=Sqr(diffx*diffx+diffy*diffy) If ln=0 Then ln=1e-6 Dim As Single nx=diffx/ln,ny=diffy/ln xp=x1+l*nx:yp=y1+l*nyEnd Sub

Thanks for trying to help. Tested you program and ... if you point your mouse to the end of arrow and start dragging it up and down with "violence" you will separate mouse from form(arrow) when you are pressing left button.We both need the secret of OS windows movement. You can move them slowly and hard and that the mouse stays on the same position. Just open notepad window and move it to see what i mean. :)

the lag does not make sense to me - where is it coming from? I can think of a crude work-around:

when the mouse button is pressed, make an image of the window including the mouse cursor and then hide the cursor and move that image around until button is released.... i dont like it, but it would work