Page 1 of 1
How to change charset of ANSI ComboBox
Posted: 24 Feb 2011, 18:02
by doublespin
Hi
I' m trying to use an ANSI ComboBox control to choose and display greec, romanian and turkish text. I want to set the language codepage by changing the font.charset property (for example 161 for greec). But the items of combobox doesn't display correctly. For all other controls I tried this works fine - not for comboboxes.
If I choose one faulty entry of the comboboxes list by clicking it, the choosen text will be assignd to comboboxes.Text property and it shows correctly. Notice: Only the list content doesn't work.
By the way: The combobox controls from MS (standard and forms2) does display the list items incorrect too.
Any ideas?
Thx
Doublespin
Re: How to change charset of ANSI ComboBox
Posted: 24 Feb 2011, 22:18
by TiKu
Why don't you use the Unicode ComboBox? It does not need this charset rubbish. ANSI is dead.
Re: How to change charset of ANSI ComboBox
Posted: 25 Feb 2011, 09:44
by doublespin
Because my App is an "old" one and it contains a lot of controls that doesn't support Unicode but working with charset property. And unfortunately there is no suitable alternative to replace the controls.
Re: How to change charset of ANSI ComboBox
Posted: 25 Feb 2011, 10:49
by TiKu
Okay, users could enter Unicode characters into the Unicode controls and your app could not handle these characters. This is the only problem I can see.
If you provide a small sample app that exhibits the problem, I'll do some tests tonight. Maybe the combo box simply does not update the drop-down list's font automatically. This could be worked around.
Re: How to change charset of ANSI ComboBox
Posted: 25 Feb 2011, 12:06
by doublespin
Hi TiKu
Thank you for your time.
To write Greek characters: In Control Panel, Regional and Language Options, Languages, Details add Greek Keyboard Layout
Choose the "EL Greek" keyboard and test it in Notepad. Type keys a, b, g on german or us keyboard will display the Greek chars Alpha, Beta, Gamma (αβγ)
Here ist my sampe.
On a form place one ANSI combobox and one textbox.
In Form_Load event paste the following:
Code: Select all
Private Sub Form_Load()
Const GREEK_CHARSET = 161
ComboBox1.Style = sComboDropDownList
ComboBox1.UseSystemFont = False
ComboBox1.Font.Charset = GREEK_CHARSET
ComboBox1.ComboItems.RemoveAll
'Add the Greek chars Alpha, Beta, Gamma (Keys a, b, g on german keyboard)
ComboBox1.ComboItems.Add "áâã"
'Add the Greek chars Delta, Epsilon, Zeta (Keys d, e, y on german keyboard)
ComboBox1.ComboItems.Add "äåæ"
'Assign the chars Alpha, Beta, Gamma (Keys a, b, g on german keyboard)
ComboBox1.Text = "áâã"
'--> The text on combo will be OK
'--> The items list will not
'For control fill textbox
Text1.Font.Charset = GREEK_CHARSET
Text1.Text = "áâã"
'--> No Problem to display correct chars
End Sub
Thx
Doublespin
Re: How to change charset of ANSI ComboBox
Posted: 25 Feb 2011, 22:11
by TiKu
Interesting: If I specify a manifest, so that Visual Styles are used, neither the text box nor the combo box display the characters correctly.
Re: How to change charset of ANSI ComboBox
Posted: 25 Feb 2011, 23:28
by TiKu
This seems to be an issue with Windows' native list box control. I don't know how to work around this bug.