IonicWind Software

IWBasic => GUI Central => Topic started by: v_ung_usa on April 26, 2008, 09:27:21 PM

Title: What is wrong with this sample code?
Post by: v_ung_usa on April 26, 2008, 09:27:21 PM
The following sample code is supposed to open a window and display 4 numbers and the 4 Unicode (card suit) characters.
What did I do wrong?  And what do I need to do in order to get the desired results?

DEF j as INT
DEF w1 as WINDOW
OPENWINDOW w1,0,0,350,350,@HSCROLL|@VSCROLL|@MINBOX|@MAXBOX|@SIZE,NULL,"Simple Window",&main
SETFONT w1,"Arial",20,400,0x00010000
for i=1 to 4
GETDATA suits,j
print w1,wchr$(j)
next i
DATABEGIN suits
DATA 0x2660,0x2663,0x2665,0x2666
DATAEND
WAITUNTIL w1 = 0
END
'---
SUB main
    IF @MESSAGE = @IDCLOSEWINDOW
        CLOSEWINDOW w1
    ENDIF
RETURN
ENDSUB
Title: Re: What is wrong with this sample code?
Post by: pistol350 on April 27, 2008, 03:29:23 AM
I can't compile the code now, but what i see is that you use the PRINT command without the MOVE command,
so i guess this is the main reason why anything is displayed.
Title: Re: What is wrong with this sample code?
Post by: v_ung_usa on April 27, 2008, 06:05:36 AM
Does not help.  I replaced the print statement in the above example with the following 2 lines of code:

move w1, 0,(i-1)*30
print w1,j,wchr$(j)

The result is 4 lines of whatever "J" is, but no "WCHR$(J)" output.
Title: Re: What is wrong with this sample code?
Post by: billhsln on April 27, 2008, 06:38:33 AM
I am not 100% sure, but I don't think Arial has the full Unicode character set.  I have tried using a Character set that says it is Unicode, but all I end up with is '?' for each character.

Plus, the only way I am getting '?'s is by doing:

print w1,w2s(Wchr$(j))

Bill
Title: Re: What is wrong with this sample code?
Post by: v_ung_usa on April 27, 2008, 06:45:13 AM
Been there, got that, LOL!  I **know** Arial supports those characters, because I verified the Unicode values against the Windows "Character Map" utility.
Title: Re: What is wrong with this sample code?
Post by: Ionic Wind Support Team on April 27, 2008, 08:10:15 AM
PRINT only supports ANSI characters, when you use w2s you are converting a unicode character to ansi, which doesn't have equivelents to those special characters so you get a ?

You need to use the API function TextOutW...


DECLARE IMPORT, TextOutW(uint hdc, int x, int y, wstring str, int count)

DEF j as WORD
DEF hdc as UINT
DEF w1 as WINDOW
OPENWINDOW w1,0,0,350,350,@HSCROLL|@VSCROLL|@MINBOX|@MAXBOX|@SIZE,NULL,"Simple Window",&main
SETFONT w1,"Arial",20,400
hdc = GetHDC(w1)
for i=1 to 4
GETDATA suits,j
TextOutW(hdc,0,0,wchr$(j),1)
next i
ReleaseHDC w1,hdc

WAITUNTIL w1 = 0
END
'---
SUB main
    IF @MESSAGE = @IDCLOSEWINDOW
        CLOSEWINDOW w1
    ENDIF
RETURN
ENDSUB

DATABEGIN suits
DATA 0x2660,0x2663,0x2665,0x2666
DATAEND


Paul
Title: Re: What is wrong with this sample code?
Post by: v_ung_usa on April 27, 2008, 08:28:40 AM
Thanks!
;D
That caveat about PRINT being ASCII only needs to be in the help file.
Title: Re: What is wrong with this sample code?
Post by: v_ung_usa on April 27, 2008, 08:35:12 AM
Uh, why can't I find TextOutW in the help file?
???
Title: Re: What is wrong with this sample code?
Post by: v_ung_usa on April 27, 2008, 08:42:13 AM
...because TextOutW is a Windows API function...

Ok, so I think a caveat about PRINT is in order for the help file and perhaps a mention of how to do itusing TextOutW.