Forum > LCL
setting tMenuItem.Caption with german umlauts and tab char fails
Martin V:
Hello,
I use Menuitem.Caption := MyString in Windows. MyString has got german umlauts (ASCII > #127) and a Tab (#9) separator. Only simple text appears in the menu of my app, instead of Umlauts '?' appears, the tab character is not interpretated correctly.
(I need the Tab separator because of writing exotic key combinations which are not part of tMenuitem.Shortcut.)
A dirty hack using the old Windows API function ModifyMenu function works:
Windows.ModifyMenu(Menuitem.Parent.Handle, Menuitem.Command, MF_STRING,Menuitem.Command,PChar(MyAnsiStringCaption));
The lcl function win32wsmenus.inc UpdateCaption uses the more current Windows API function SetMenuItemInfo which causes the problem. I wonder why these two Windows API functions handle the string different. The string is not converted by lcl before executing SetMenuItemInfo.
Is this a bug in LCL or do I need to convert the string before assigning to Menuitem.Caption?
The problem does not appear when using a lfm ressource. Then the string is handled correctly, both umlauts and tabs appear.
I do not know the behaviour on other OS.
JuhaManninen:
Which version of Lazarus you have?
Please test with the latest SVN version. If it has the same problem then this is worth a bug report.
Regards,
Juha
Martin V:
The Lazarus version is 0.9.28.2. I checked the bugtracker, nothing has been reported. If noone has any idea, I will try to make a proposal for a lcl fix. Anyway, I would be interested in Linux / Mac behaviour. Does these OS also accept for example MenuItem.Caption := '&Save'#9'Ctrl-S ?
Martin_fr:
--- Quote from: Martin V on May 28, 2010, 11:13:33 am ---Hello,
I use Menuitem.Caption := MyString in Windows. MyString has got german umlauts (ASCII > #127) and a Tab (#9) separator. Only simple text appears in the menu of my app, instead of Umlauts '?'
--- End quote ---
Without having tested anything, but you speak of ASCII > 127
If you give the LCL (and through the LCL to windows) any ASCII chars of that range, then that is supposed to fail.
The LCL works with UTF8 only.
If your code actually passes the utf8 sequence fur an umlaut to the LCL, and if that fails to show up correctly in the end-result => then there is a bug.
If you type the char directly into your source, using the IDE as editor, then please check the encoding of your file (pop-up-menu => file-settings => encoding)
It must be utf8.
if you use #162 (or whatever value) then that is wrong, utf8 umlaut has multiply bytes.
JuhaManninen:
Hi,
I am also confused with the encodings.
However, this works under Linux using SVN Lazarus:
MenuItem3.Caption := '&Open äöåÅÄÖ'#9'Ctrl-O';
MenuItem4.Caption := '&Save'#9'Ctrl-S';
äöåÅÄÖ are shown correctly.
Ctrl-O and Ctrl-S get nicely aligned due to the TAB char. I didn't know that feature.
Please test again with the latest version. There has been some work on char encodings.
Juha
Navigation
[0] Message Index
[#] Next page