peter
19-11-2013, 10:22
Hi Eros,
New Dll to test. Runs with ThinBasic 1.9.11.0 without intricacies.
But one mysterious thing happens with an Api declaration.
It is TextOut, the screen coordinates of this function are not correctly shown.
And SetBkColor does not work as expected !
Uses "ui"
#INCLUDE "abc.inc"
DWord hdc, hwnd
hwnd= Canvas_Window("ThinBasic",xMiddle(320),yMiddle(240),320,240)
Canvas_Attach(hwnd,0,%TRUE)
hdc = Canvas_GetDC()
SetHandleDC hdc
SetFont 12,24,%FW_BOLD,""
SetColorKey Rgb(255,255,255)
Dim a(8) As Byte
Long mem, h, x, z, b1, b2
String s
s="PETER"
b1 = LoadIcon "icon/acorn.ico"
b2 = LoadBmp "bmp/panorama.bmp",30
mem= NewMemory (20)
h= OpenFile "abc_test.txt"
WriteByte h,s,5
CloseFile h
h= OpenFile "abc_test.txt"
ReadByte h,s,5
CloseFile h
bPoke mem,0,80
bPoke mem,1,69
bPoke mem,2,84
bPoke mem,3,69
bPoke mem,4,82
a(1) = bPeek mem,0
a(2) = bPeek mem,1
a(3) = bPeek mem,2
a(4) = bPeek mem,3
a(5) = bPeek mem,4
PlayWav "scream"
While IsWindow(hwnd)
If GetAsyncKeyState(27) Then Exit While
Canvas_Clear(Rgb(0,0,255))
For x=1 To 5
Say(x*16-16,80,Chr$(a(x)),Rgb(255,255,255))
Next
Say(100,20," BANANA", Rgb(255,255,0))
DrawIcon b1,100,110,128,128,0
DrawBmp b2,135,50,50,50,z
z +=1
If z=30 Then z=0
Canvas_Redraw
SetFps (60)
Wend
KillMemory(mem)
FreeGraphic
Canvas_Window End
'Does not work here! Coordinates show a wrong behaviour.
Function Say(ix As Long, iy As Long, txt As String, col As Long) As Long
SetBkMode hdc,1
SetBkColor hdc, 255*256 'green, but doesn't work!
SetTextColor hdc, col
TextOut hdc,ix,iy,txt,Len(txt)
End Function
New Dll to test. Runs with ThinBasic 1.9.11.0 without intricacies.
But one mysterious thing happens with an Api declaration.
It is TextOut, the screen coordinates of this function are not correctly shown.
And SetBkColor does not work as expected !
Uses "ui"
#INCLUDE "abc.inc"
DWord hdc, hwnd
hwnd= Canvas_Window("ThinBasic",xMiddle(320),yMiddle(240),320,240)
Canvas_Attach(hwnd,0,%TRUE)
hdc = Canvas_GetDC()
SetHandleDC hdc
SetFont 12,24,%FW_BOLD,""
SetColorKey Rgb(255,255,255)
Dim a(8) As Byte
Long mem, h, x, z, b1, b2
String s
s="PETER"
b1 = LoadIcon "icon/acorn.ico"
b2 = LoadBmp "bmp/panorama.bmp",30
mem= NewMemory (20)
h= OpenFile "abc_test.txt"
WriteByte h,s,5
CloseFile h
h= OpenFile "abc_test.txt"
ReadByte h,s,5
CloseFile h
bPoke mem,0,80
bPoke mem,1,69
bPoke mem,2,84
bPoke mem,3,69
bPoke mem,4,82
a(1) = bPeek mem,0
a(2) = bPeek mem,1
a(3) = bPeek mem,2
a(4) = bPeek mem,3
a(5) = bPeek mem,4
PlayWav "scream"
While IsWindow(hwnd)
If GetAsyncKeyState(27) Then Exit While
Canvas_Clear(Rgb(0,0,255))
For x=1 To 5
Say(x*16-16,80,Chr$(a(x)),Rgb(255,255,255))
Next
Say(100,20," BANANA", Rgb(255,255,0))
DrawIcon b1,100,110,128,128,0
DrawBmp b2,135,50,50,50,z
z +=1
If z=30 Then z=0
Canvas_Redraw
SetFps (60)
Wend
KillMemory(mem)
FreeGraphic
Canvas_Window End
'Does not work here! Coordinates show a wrong behaviour.
Function Say(ix As Long, iy As Long, txt As String, col As Long) As Long
SetBkMode hdc,1
SetBkColor hdc, 255*256 'green, but doesn't work!
SetTextColor hdc, col
TextOut hdc,ix,iy,txt,Len(txt)
End Function