dcromley
04-09-2010, 05:02
Hi,
Here's a short program that works -- just drag the mouse in the Canvas Window to draw tracks in the window.
My question -- am I missing anything? -- are there other thinBasic features that I should be using?
Thanks, Dave
Uses "UI"
Begin Const
%xLeft = 40
%yUpper = 30
End Const
Sub TBMain()
Local hwnd, x1, y1 As Long
GetAsyncKeyState(-1)
hWnd = Canvas_Window "Drag the mouse - ESC to exit", %xLeft, %yUpper, 400, 300
Canvas_Attach hWnd, 0, %FALSE
Do While CkWin(hwnd)
If MouseDown(x1, y1) Then
Canvas_Ellipse x1-3, y1-3, x1+3, y1+3, , -1
End If
loop
End Sub
Function CkWin(hwnd As Long) ' stop if no window or ESC
If Not IsWindow(hwnd) Then Stop
If GetAsyncKeyState(%VK_ESCAPE) <> 0 Then Stop
Function = -1
End Function
Function MouseDown(ByRef px As Long, ByRef py As Long) As Long
Local p1 As pointapi
Function = GetAsyncKeyState(%VK_LBUTTON) ' mousedown
Win_GetCursorPos(p1)
px = p1.x - %xLeft - 3: py = p1.y - %yUpper - 29 ' correction ?
End Function
Here's a short program that works -- just drag the mouse in the Canvas Window to draw tracks in the window.
My question -- am I missing anything? -- are there other thinBasic features that I should be using?
Thanks, Dave
Uses "UI"
Begin Const
%xLeft = 40
%yUpper = 30
End Const
Sub TBMain()
Local hwnd, x1, y1 As Long
GetAsyncKeyState(-1)
hWnd = Canvas_Window "Drag the mouse - ESC to exit", %xLeft, %yUpper, 400, 300
Canvas_Attach hWnd, 0, %FALSE
Do While CkWin(hwnd)
If MouseDown(x1, y1) Then
Canvas_Ellipse x1-3, y1-3, x1+3, y1+3, , -1
End If
loop
End Sub
Function CkWin(hwnd As Long) ' stop if no window or ESC
If Not IsWindow(hwnd) Then Stop
If GetAsyncKeyState(%VK_ESCAPE) <> 0 Then Stop
Function = -1
End Function
Function MouseDown(ByRef px As Long, ByRef py As Long) As Long
Local p1 As pointapi
Function = GetAsyncKeyState(%VK_LBUTTON) ' mousedown
Win_GetCursorPos(p1)
px = p1.x - %xLeft - 3: py = p1.y - %yUpper - 29 ' correction ?
End Function