News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Unicode listbox

Started by Farabi, April 08, 2011, 06:53:22 AM

Previous topic - Next topic

Farabi

Anyone know how to create a unicode listbox?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

donkey

Use Unicode functions to create the listbox. If its in a dialog use DialogBoxParamW to initialize the dialog box, if you are creating it with CreateWindowEx, use CreateWindowExW etc... In GoAsm use /d UNICODE on the command line and STRINGS UNICODE in your source and it will be done transparently. In MASM it is a little more involved but you can use ANSI messages with Unicode windows, they will be translated to Unicode so it shouldn't be too difficult but it will slow things down a tad.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

hutch--

Onan,

Just make sure that the text you place in the list box is also unicode and use the unicode versions of SendMessage etc ... to load the list box.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

donkey

Quote from: hutch-- on April 08, 2011, 07:09:48 AM
Onan,

Just make sure that the text you place in the list box is also unicode and use the unicode versions of SendMessage etc ... to load the list box.

Makes no difference except in terms of a slight penalty in speed, Windows will translate all messages below WM_USER to Unicode during the marshalling process.

QuoteThe system does automatic two-way translation (Unicode to ANSI) for window messages. For example, if an ANSI window message is sent to a window that uses the Unicode character set, the system translates that message into a Unicode message before calling the window procedure. The system calls IsWindowUnicode to determine whether to translate the message.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

hutch--

 :bg

Fine but don't expect 2 byte strings to load correctly into a list box if the source is not in the right format. I get this with Japanese characters if its done wrong.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

donkey

Quote from: hutch-- on April 08, 2011, 07:14:03 AM
:bg

Fine but don't expect 2 byte strings to load correctly into a list box if the source is not in the right format. I get this with Japanese characters if its done wrong.

You can't send Japanese characters with the ANSI character set so that's a non-issue. They require DBCS in which case you have to set the proper code page and not use a Unicode message.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Farabi

I tried to create the unicode using CreateWindowExW but failed. Anyone successfully use it? Or I need to typ the class name on unicode?
Before I able to create a unicode richedit I need to load some library first, does I need to load something first before using the listbox unicode version?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

hutch--

 :bg

Funny enough I have no problems loading and saving Japanese characters in combined Kanji and Katakana as straight unicode. The problem is it cannot be easily emulated in ANSI characters so you save and load Japanese as unicode. What you do need is to have the east asian fonts loaded so you can display the character sets.

Onan, from memory richedit 1 does not support unicode where richedit 2/3 does. Just make sure you use the correct window class for richedit 2/3. You may have to make sure that in the Windows version you are running that you have the right fonts to display the characters you need.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Farabi

Somebody should say that I need to use unicode for the class name  :lol
is MASM had a macro for unicode text like CADD("text") macro? I think I asked this before, but the thread is gone.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

donkey

Quote from: Farabi on April 08, 2011, 02:15:26 PM
Somebody should say that I need to use unicode for the class nameĀ  :lol
is MASM had a macro for unicode text like CADD("text") macro? I think I asked this before, but the thread is gone.

Hi Onan,

All xxxxxW or unicode functions only accept unicode as input and output unicode. This is a standard in Windows and shouldn't have to be mentioned.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

hutch--

Onan,

MASM does not natively support unicode strings as literal strings, there are some macros that will convert ansi to unicode but this will not help you if the character set requires something that cannot be represented by ANSI text. The conventional way to handle unicode in MASM is to store the string data in the resource section which is native unicode. You can also store unicode string as byte data and pass the address like normal.

隱庵こんにちわ。    Onan konnichiwa.

    Onan db 177,150,181,94,83,48,147,48,107,48,97,48,143,48,00

Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

Quote from: Farabi on April 08, 2011, 02:15:26 PMis MASM had a macro for unicode text like CADD("text") macro? I think I asked this before, but the thread is gone.

MasmBasic Unicode functions: wArrayFill, wCat$, wChr$, wCL$(), wClip$, wData, wDate$, CrtDate$, wInkey, wInstr, wLeft$, wLen, wLet, wLower$, wMid$, wMsgBox, wPrint, wPrint #n, wRes$, wRight$, wSetWin$, wStr$, wTime$, wUpper$, wWin$

Example (sets the text of an editbox using a Unicode string from a resource file's stringtable):

QuotewSetWin$ hEdit=wRes$(1)+wCrLf$+wCrLf$+wRes$(2)
[/b]

Farabi

Hi JJ  :U
Yeah I saw your MASM basic but it yield an error, but I'll try to fix it.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

hutch--

Onan,

I am sure you already have it working but here is a unicode test piece that loads 1 to 10 in Indonesian into a list box.

The RSRC.RC file is written as UNICODE so you need a unicode text editor to change it.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Farabi

Thanks hutch, yeah I already fix it.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"