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.
Code: Select all
#include "fbgfx.bi"
Using fb
Dim e As EVENT
Dim As Integer x, y, pressed, buttons, wx, wy
Dim As Any Ptr img
Screen 20, 32,, GFX_SHAPED_WINDOW
img=imagecreate(1024,768)
Line img, (0, 0)-(1024, 768), RGBA(96, 96, 96,255), BF
Line img, (0, 0)-(1024, 40), RGBA(64, 64, 64,200), BF
put (0,0), img
pressed = 0
Do
screenLock()
if (ScreenEvent(@e)) then
if e.type = EVENT_MOUSE_BUTTON_PRESS then
pressed=1
end if
if e.type = EVENT_MOUSE_BUTTON_RELEASE then
pressed = 0
end if
'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
end if
screenunLock()
'Sleep 1
Loop While Not MultiKey(1)