PDA

View Full Version : ABC Update



peter
24-11-2013, 20:22
Hi,


Updated abc.dll and abc.inc


For interrested programmers;

Note:
GetHandleDC now needs two parametres, device contex and Window handle
Mouse buttons can also be used.


Mouse Button Left =1
Mouse Button Right =2
Mouse Button Middle =3


here is a small demo.


Uses "ui"
#INCLUDE "abc.inc"


DWord hdc, hwnd
hwnd = Canvas_Window("ThinBasic",0,0,640,480)
Canvas_Attach(hwnd,0,%TRUE)
hdc = Canvas_GetDC()
SetHandleDC hdc, hwnd
SetFont 10,20,%FW_BOLD,""


Long mx,my


Type Buffer
x As Long
y As Long
z As Long
End Type
Dim cBuf(120) As Buffer


While IsWindow(hwnd) And KeyDown(27)=0
Canvas_Clear 0
mx = xMouse
my = yMouse


DrawText 10,20, "xMouse " & mx, Rgb 255,255,255
DrawText 10,40, "yMouse " & my, Rgb 255,255,255


If mButton=0 Then
DrawText 220,180,"No Button Pressed", Rgb 255,255,255
End If


If mButton=1 Then
DrawText 220,180,"Left MouseButton Pressed", Rgb 210,210,255
ClickBuffer mx, my
ElseIf mButton=2 Then
DrawText 220,180,"Right MouseButton Pressed", Rgb 210,210,255
ClickBuffer mx, my
ElseIf mButton=3 Then
DrawText 220,180,"Middle MouseButton Pressed", Rgb 210,210,255
ClickBuffer mx, my
End If


DrawText 220,200,"PRESS A MOUSE BUTTON",Rgb 85,164,250
Clicked


Canvas_Redraw
Sleep 10
Wend


FreeGraphic
Canvas_Window End


Sub ClickBuffer(x, y As Long)
Local i As Long
For i=1 To 120
If cBuf(i).x=0 Then
cBuf(i).x=x
cBuf(i).y=y
cBuf(i).z=2
Exit Sub
End If
Next
End Sub

Sub Clicked()
Local i As Long
For i=1 To 120
If cBuf(i).x >0 Then
DrawCircle cBuf(i).x-10,cBuf(i).y-10,cBuf(i).z,0, Rgb 0,Rand(128,255),0
cBuf(i).z +=1
If cBuf(i).z=20 Then
cBuf(i).x=0
End If
End If
Next
End Sub