peter
24-10-2012, 00:43
Hi Eros,
Canvas blocked my SetText routine. Has really strange behaviour.
It doesn't like the xPosition and yPosition of the SetText function.
I tried it directly, without A.dll. and there was no problem. But this isn't what I want.
Do you have an explanation for this predicament ?
Uses "ui","A"
Declare Function LoadByte Lib "A.dll" Alias "LoadByte" (ByVal nName As String, ByRef Destination As Any) As Long
Declare Function SaveByte Lib "A.dll" Alias "SaveByte" (ByVal nName As String, ByRef Destination As Any,ByVal count As Long) As Long
Declare Function FileExits Lib "A.dll" Alias "FileExits" (ByVal nName As String) As Long
Declare Function FilePointer Lib "A.dll" Alias "FilePointer" (ByVal FileHandle As Long,ByVal count As Long) As Long
Declare Function OpenFile Lib "A.dll" Alias "OpenFile" (ByVal nName As String) As Long
Declare Function FileSize Lib "A.dll" Alias "FileSize" (ByVal FileHandle As Long) As Long
Declare Function CloseFile Lib "A.dll" Alias "CloseFile" (ByVal FileHandle As Long) As Long
Declare Function ReadLong Lib "A.dll" Alias "ReadLong" (ByVal FileHandle As Long,ByRef Destination As Any,ByVal count As Long) As Long
Declare Function ReadInt Lib "A.dll" Alias "ReadInt" (ByVal FileHandle As Long,ByRef Destination As Any,ByVal count As Long) As Long
Declare Function ReadByte Lib "A.dll" Alias "ReadByte" (ByVal FileHandle As Long,ByRef Destination As Any,ByVal count As Long) As Long
Declare Function WriteLong Lib "A.dll" Alias "WriteLong" (ByVal FileHandle As Long,ByRef Destination As Any,ByVal count As Long) As Long
Declare Function WriteInt Lib "A.dll" Alias "WriteInt" (ByVal FileHandle As Long,ByRef Destination As Any,ByVal count As Long) As Long
Declare Function WriteByte Lib "A.dll" Alias "WriteByte" (ByVal FileHandle As Long,ByRef Destination As Any,ByVal count As Long) As Long
Declare Function PlayWav Lib "A.dll" Alias "PlayWav" (ByVal WavFile As String) As Long
Declare Function SetFont Lib "A.dll" Alias "SetFont" (ByVal hdc As Long,ByVal Width As Long,ByVal Height As Long,ByVal Style As Long,ByVal FontName As String) As Long
Declare Function SetText Lib "A.dll" Alias "SetText" (ByVal hdc As Long,ByVal xPos As Long,ByVal yPos As Long,ByVal lpText As String,ByVal Colour As Long) As Long
'for testing
Declare Function GetDC Lib "user32.dll" Alias "GetDC" (ByVal hwnd As Long) As Long
Declare Function TextOut Lib "gdi32.dll" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Declare Function TextColor Lib "gdi32.dll" Alias "SetTextColor"(ByVal hdc As Long, ByVal crColor As Long) As Long
Declare Function SetBkMode Lib "gdi32.dll" Alias "SetBkMode" (ByVal hdc As Long, ByVal nBkMode As Long) As Long
%BOLD =700
DWord hwnd,hdc,hdc1
hwnd=Canvas_Window("Dll Test",320,240,640,480)
Canvas_Attach(hwnd,0,%TRUE)
hdc=Canvas_GetDC()
hdc1=GetDC(hwnd)
SetFont(hdc,20,88,%BOLD,"")
Dim map(1200) As Byte
Long L
Asciiz s="HELLO YOU"
Asciiz a=" "
SaveByte("hello.txt",s,Len(s))
LoadByte("hello.txt",a)
L=LoadByte("map1-1.txt",map)
PlayWav("success.wav")
While IsWindow(hwnd)
Canvas_Clear(&hFF0000)
SetText(hdc,80,80,a + " ",&h64F080)
SetText(hdc,180,140,L + " BYTES LOADED",&hFFFFFF)
'Test
SetFont(hdc1,64,188,%BOLD,"")
TextColor(hdc1,Rgb(255,255,0))
TextOut(hdc1,100,100,"HELLO",5)
Canvas_Redraw
If GetAsyncKeyState(27) Then Exit While
Wend
Canvas_Window End
'Sub SetText(x,y As Long, txt As String, xkol,ykol As Long)
' Canvas_Color(xkol,ykol)
' Canvas_SetPos(x,y)
' Canvas_Print(txt)
'End Sub
Canvas blocked my SetText routine. Has really strange behaviour.
It doesn't like the xPosition and yPosition of the SetText function.
I tried it directly, without A.dll. and there was no problem. But this isn't what I want.
Do you have an explanation for this predicament ?
Uses "ui","A"
Declare Function LoadByte Lib "A.dll" Alias "LoadByte" (ByVal nName As String, ByRef Destination As Any) As Long
Declare Function SaveByte Lib "A.dll" Alias "SaveByte" (ByVal nName As String, ByRef Destination As Any,ByVal count As Long) As Long
Declare Function FileExits Lib "A.dll" Alias "FileExits" (ByVal nName As String) As Long
Declare Function FilePointer Lib "A.dll" Alias "FilePointer" (ByVal FileHandle As Long,ByVal count As Long) As Long
Declare Function OpenFile Lib "A.dll" Alias "OpenFile" (ByVal nName As String) As Long
Declare Function FileSize Lib "A.dll" Alias "FileSize" (ByVal FileHandle As Long) As Long
Declare Function CloseFile Lib "A.dll" Alias "CloseFile" (ByVal FileHandle As Long) As Long
Declare Function ReadLong Lib "A.dll" Alias "ReadLong" (ByVal FileHandle As Long,ByRef Destination As Any,ByVal count As Long) As Long
Declare Function ReadInt Lib "A.dll" Alias "ReadInt" (ByVal FileHandle As Long,ByRef Destination As Any,ByVal count As Long) As Long
Declare Function ReadByte Lib "A.dll" Alias "ReadByte" (ByVal FileHandle As Long,ByRef Destination As Any,ByVal count As Long) As Long
Declare Function WriteLong Lib "A.dll" Alias "WriteLong" (ByVal FileHandle As Long,ByRef Destination As Any,ByVal count As Long) As Long
Declare Function WriteInt Lib "A.dll" Alias "WriteInt" (ByVal FileHandle As Long,ByRef Destination As Any,ByVal count As Long) As Long
Declare Function WriteByte Lib "A.dll" Alias "WriteByte" (ByVal FileHandle As Long,ByRef Destination As Any,ByVal count As Long) As Long
Declare Function PlayWav Lib "A.dll" Alias "PlayWav" (ByVal WavFile As String) As Long
Declare Function SetFont Lib "A.dll" Alias "SetFont" (ByVal hdc As Long,ByVal Width As Long,ByVal Height As Long,ByVal Style As Long,ByVal FontName As String) As Long
Declare Function SetText Lib "A.dll" Alias "SetText" (ByVal hdc As Long,ByVal xPos As Long,ByVal yPos As Long,ByVal lpText As String,ByVal Colour As Long) As Long
'for testing
Declare Function GetDC Lib "user32.dll" Alias "GetDC" (ByVal hwnd As Long) As Long
Declare Function TextOut Lib "gdi32.dll" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Declare Function TextColor Lib "gdi32.dll" Alias "SetTextColor"(ByVal hdc As Long, ByVal crColor As Long) As Long
Declare Function SetBkMode Lib "gdi32.dll" Alias "SetBkMode" (ByVal hdc As Long, ByVal nBkMode As Long) As Long
%BOLD =700
DWord hwnd,hdc,hdc1
hwnd=Canvas_Window("Dll Test",320,240,640,480)
Canvas_Attach(hwnd,0,%TRUE)
hdc=Canvas_GetDC()
hdc1=GetDC(hwnd)
SetFont(hdc,20,88,%BOLD,"")
Dim map(1200) As Byte
Long L
Asciiz s="HELLO YOU"
Asciiz a=" "
SaveByte("hello.txt",s,Len(s))
LoadByte("hello.txt",a)
L=LoadByte("map1-1.txt",map)
PlayWav("success.wav")
While IsWindow(hwnd)
Canvas_Clear(&hFF0000)
SetText(hdc,80,80,a + " ",&h64F080)
SetText(hdc,180,140,L + " BYTES LOADED",&hFFFFFF)
'Test
SetFont(hdc1,64,188,%BOLD,"")
TextColor(hdc1,Rgb(255,255,0))
TextOut(hdc1,100,100,"HELLO",5)
Canvas_Redraw
If GetAsyncKeyState(27) Then Exit While
Wend
Canvas_Window End
'Sub SetText(x,y As Long, txt As String, xkol,ykol As Long)
' Canvas_Color(xkol,ykol)
' Canvas_SetPos(x,y)
' Canvas_Print(txt)
'End Sub