Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 611
  • Last Modified:

Cyrillic in Menus

I am writing a program that must operate in multiple languages.  To do this I use a file which contains all the programming text, displays etc.  This works very nicely until I hit a Cyrillic application.

I can create the text file so that it will display cyrillic in input dialog boxes, the results area, and a display map.  However I can't get the cyrillic to show in the menu items and message boxes.

I have look through the properties of the things that don't work and none of them have the Font - Charset property.  In the other pieces I set this to Russian_Charset and things work properly.

How can I set the Charset for the Menu and Message boxes?

Cheers
0
rosethorn111199
Asked:
rosethorn111199
  • 14
  • 6
  • 2
  • +5
1 Solution
 
ITugayCommented:
What you see in menu? Something like this: "ýòî òåõò íà ðóññêì ÿçûêå"?
Is it?
0
 
rosethorn111199Author Commented:
Yes that is exactly what I am seeing now.

Cheers
Paul
0
 
ITugayCommented:
Well, tell me more about your windows version, is it NT?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
GurkanCommented:
Hi rosethorn,
To handle this problem you need to use ownderdraw (draw the menu yourself). Example unit:

 
unit Odmenu1;
 
interface
 
uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,   Forms, Dialogs, Menus, StdCtrls;
 
type
  TForm1 = class(TForm)
    MainMenu1: TMainMenu;
    Test1: TMenuItem;
    Font1: TMenuItem;
    FontDialog1: TFontDialog;
    DisableFont1: TMenuItem;
    EnableFont1: TMenuItem;
    N1: TMenuItem;
    Exit1: TMenuItem;
    procedure FormCreate(Sender: TObject);
    procedure Font1Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure EnableFont1Click(Sender: TObject);
    procedure Exit1Click(Sender: TObject);
    procedure DisableFont1Click(Sender: TObject);
  private
    { Private declarations }
    BM: TBitmap;
    MenuCap: array [0..255] of char;
    procedure WMMeasureItem(var MInfo: TMessage); message wm_MeasureItem;     procedure WMDrawItem(var DInfo: TMessage); message wm_DrawItem;   public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.DFM}
 
procedure TForm1.FormCreate(Sender: TObject);
begin
  {Create a work area}
  BM := TBitmap.Create;
  {Initialize current font to standard menu text color}
  FontDialog1.Font.Color := GetSysColor(color_MenuText);
  {Tell Windows this menu item is Owner-Draw}
  ModifyMenu(MainMenu1.Handle, Font1.Command,
    mf_ByCommand or mf_OwnerDraw, Font1.Command, nil);
  {Make a copy of menu caption now to save time}
  StrPCopy(MenuCap, Font1.Caption);
  {Does menu item have a shortcut assigned?}
  if Font1.ShortCut <> 0 then
    StrPCopy(StrEnd(MenuCap), #9 + ShortCutToText(Font1.ShortCut)); end;
 
procedure TForm1.FormDestroy(Sender: TObject);
begin
  {Dispose work area}
  BM.Free;
end;
 
procedure TForm1.WMMeasureItem(var MInfo: TMessage);
var
  MIS: TMeasureItemStruct;
const
  zero: integer = 0;
begin
  {Address the Windows supplied info}
  with PMeasureItemStruct(MInfo.lParam)^ do begin
    {Is message for a menu item}
    if CtlType = odt_Menu then begin
      {Is message for Font menu item}
      if ItemID = Font1.Command then begin
        {Assign currently selected font to work space}
        BM.Canvas.Font := FontDialog1.Font;
        {Calculate needed height for current font}
        ItemHeight := BM.Canvas.TextHeight(Font1.Caption);
        {Calculate needed width for caption in current font}
        ItemWidth := LoWord(GetTabbedTextExtent(BM.Canvas.Handle, MenuCap,           StrLen(MenuCap), zero, zero));
        {Tell Windows it's handled}
        MInfo.Result := 1;
      end;
    end;
  end;
end;
 
procedure TForm1.WMDrawItem(var DInfo: TMessage);
var
  oldFont: hFont;
begin
  {Address Windows supplied info}
  with PDrawItemStruct(DInfo.lParam)^ do begin
    {Is message for a menu item?}
    if CtlType = odt_Menu then begin
      {Is message for Font menu item?}
      if ItemID = Font1.Command then begin
        {Select current font into menu's device context}
        oldFont := SelectObject(hDC, FontDialog1.Font.Handle);
        {Set correct background color}
        if (ItemState and ods_Selected) <> 0 then
          BM.Canvas.Brush.Color := clHighlight
        else
          BM.Canvas.Brush.Color := clMenu;
        {Paint the background}
        FillRect(hDC, rcItem, BM.Canvas.Brush.Handle);
        {Adjust left bound of caption}
        Inc(rcItem.Left, LoWord(GetMenuCheckMarkDimensions));
        {Set text color according to state}
        if (ItemState and ods_disabled <> 0)
        or (ItemState and ods_Grayed <> 0) then
          {Use system's 'grayed' color}
          SetTextColor(hDC, GetSysColor(color_GrayText))
        else if (ItemState and ods_Selected <>0) then
          {Use reverse of current font color}
          SetTextColor(hDC, not FontDialog1.Font.Color)
        else
          {Use selected font color}
          SetTextColor(hDC, FontDialog1.Font.Color);
        {Allow background color to surround characters}
        SetBkMode(hDC, Transparent);
        {Draw the menu's caption}
        DrawText(hDC, MenuCap, StrLen(MenuCap), rcItem,
          dt_Top or dt_SingleLine or dt_ExpandTabs);
        {Release current font handle}
        SelectObject(hDC, oldFont);
        {Tell Windows it's handled}
        DInfo.Result := 1;
      end;
    end;
  end;
end;
 
procedure TForm1.EnableFont1Click(Sender: TObject);
begin
  {Tell Windows this menu item is selectable again}
  ModifyMenu(MainMenu1.Handle, Font1.Command,
    mf_ByCommand or mf_Enabled or mf_OwnerDraw, Font1.Command, nil); end;
 
procedure TForm1.DisableFont1Click(Sender: TObject);
begin
  {Tell Windows this menu item not selectable}
  ModifyMenu(MainMenu1.Handle, Font1.Command,
    mf_ByCommand or mf_Grayed or mf_OwnerDraw, Font1.Command, nil); end;
 
procedure TForm1.Font1Click(Sender: TObject);
begin
  if FontDialog1.Execute then
  {Fool Windows into sending another wm_MeasureItem message
  so menu item can be sized for newly selected font.}
    ModifyMenu(MainMenu1.Handle, Font1.Command,
      mf_ByCommand or mf_OwnerDraw, Font1.Command, nil);
end;
 
procedure TForm1.Exit1Click(Sender: TObject);
begin
  Close;
end;
 
end.
0
 
ITugayCommented:
Ow! It's a comment!

I make some experiments and have some recomendations. If you don't need to see russian text in menu at your computer, but only need to be sure that in russian version of windows it will look like "russian", you may keep it as is. I just write and compile small application on computer without russian, then start it on computer with russian version of windows. It look like russian. But if you need to see russian in your computer, just change system settings of windows to russian (keep Windows CD ready;).

Best regards

Tugay.
0
 
rosethorn111199Author Commented:
To: ITugay

That might work if the OS is russian or in my case Bulgarian.  However the client is running Win 95 in English with Bulgarian Keyboard support.  Therefore this is not truly Russian.

To: Gurkan

That is one helluva comment!

If I must draw my own menu, then I will use that code as a sample.

Is there no way to activity the Charset for a menu?

Cheers
Paul
0
 
Dmitry_Commented:
Use multilanguage component, for example: http://members.tripod.com/~sushko/,
look into download ->TLanguage
I use these component and it's ok.
0
 
rosethorn111199Author Commented:
Adjusted points to 300
0
 
rosethorn111199Author Commented:
Sorry Dmitry but the TLanguage Component doesn't solve the problem.

I downloaded, installed and ran the demo.  While it provides nice translations, when you select Russian the Cyrillic text is NOT displayed, but you get the same type of characters that ITugay mentioned in his first comment.

Cheers
Paul
0
 
rwilson032697Commented:
Listening
0
 
Dmitry_Commented:
Try to test the TLanguage component on operating system with cyrillic support.
I'm using this component for switch between hebrew and english languages and it's working properly.
0
 
sassas081597Commented:
Hi
Windows use special fonts in menu - MSSerif and MSSanSerif. If on your computer these fonts are cyrillic incompatible, you will not be able to see russian letters in the menu.
So the recomendations are
1) Rewrite these fonts when you install the program or
2) use soft menu - not the standart one.
As far as I remember soft menu with the same behavior you can find on the Delphi Superpage.

SASSAS
0
 
ITugayCommented:
You can send me  compilled part of application via e-mail, and I tell you how it look.

Best regards,
igor@novell.kz
0
 
rosethorn111199Author Commented:
To: Dmitry

1) Unfortunately my client is restricted to Win95, and they are using Bulgarian support under English OS.
2) I finally got an answer out of MS.  True multilanguage OS is only available with W2K.

Unfortunately this puts a real crimp in your solution.

To: SASSAS

I am not sure what your suggestion is.  I am unfamiliar with soft menus.  Is this the same idea as Gurkan's comment earlier?

To:

I appreciate your offer, but am not sure what to send, or how meaningful the test would be.  If you are running a different OS, than Win95, the test may not have much meaning.

Cheers
Paul
0
 
DValeryCommented:
Hi, rosethorn
May be you will try modify in registry key: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Nls\Codepage
Parameter: 1252 = cp_1252.nls on 1252 = cp_1251.nls

It's common problem with the cyrilic fonts on non russian Windows.
0
 
rosethorn111199Author Commented:
That looks promising.

Much as I hate to work in the Registry, I will give it a cautious try.

Thanks.
Paul
0
 
rosethorn111199Author Commented:
To: DValery

I made the change as suggested.  Rebooted and tested the program.

There was no change.

Was that the only change required?

Cheers
0
 
ITugayCommented:
About testing your application. I have a lot : WIN95, WIN98, NT4, NT2000. All of this is russian version. You need only to create new application, put TMenu here and place MenuItems like this:
&Ôàéë
&Îòêðûòü
&Ñîõðàíèòü
Ñîõðàíèòü ê&àê
&Âûéòè
You may copy it then paste to menu caption. Then you compile it and send .EXE to me. I will try it on different OS. I'm sure, it will look like russian.

Best regards
0
 
rosethorn111199Author Commented:
Adjusted points to 500
0
 
rosethorn111199Author Commented:
To: Itugay

I would like to award some points to you, but I can't do it without closing the question.

The answer you provide is that the correct OS must be used, and that answer will solve my problems.  Unfortunately acquiring and installing the necessary OS is not yet an option.

For all others listening in on this question, let me add the following condition.

The solution must be applicable within the Win 95 OS, English version, but running with Bulgarian language support.

I have increase the point value.

Cheers
Paul

P.S. If this question is ever resolved ITugay deserves partial credit!
0
 
geobulCommented:
Hi Paul,

As your client uses Win95 English version, ask him to buy for you 'FlexType' from Datecs - Bulgarian fonts and keyboard support program under W95. After installing it you will have MS SansSerif and other fonts in Bulgarian. And no problems with Bulgarian in Delphi!

Regards, Geo
0
 
rosethorn111199Author Commented:
I have just been through a horrible situation with the Datecs program.  The fonts it installs were not compatible with any of the fonts and the whole installation conflicted badly with the Pan-European Language Support under Win95.

The Datecs program replaced the keyboard driver in the system.ini file and this caused Win95 to loose the ability to change keyboards.

In Excel, under Datecs, the cyrillic fonts were visible in the cell, but displayed as square boxes (unprintable characters) in the cell edit line.  This suggests an incompatibility between Win95 and Datecs.

The version I was using may have been somewhat dated.  Do you have any updated information on the compatibility between Datecs and MS at the keyboard and language support level.

I am also concerned for the future applications and changes to Win98 and W2K.  According to MS, programs such as Datecs are made unnecessary by the advances in Unicode and W2K.

If this is the case, then the solution is short term at best.

Much thanks for your comments, I am slowly beginning to get an idea of where the root of the problem is, and what possible solutions can do.

Cheers
Paul

0
 
geobulCommented:
Hi Paul,
  It sounds like FT is not setup properly.
  I'm using FlexType 3.0 under w95.
  In my version in FT properties I have three pages: General,Keyboard and Fonts.
  Under General there are three filters and all have to be 'Eastern Europe/Cyrillic'.
  Under Keyboard you can add different keyboard layouts and even edit them. As your keyboard has no BDS (i suppose) use 'Bulgarian Phonetic'.
  Under Fonts set System fonts and Window to 'Eastern Europe/Cyrillic' and Full screen to 'US,Western Europe'.
  I hope this will help you.

Regards, Geo
0
 
rosethorn111199Author Commented:
I would seriously consider getting FT for W95, but I would like to have more information and experience in using FT and W95 Pan-European Language Support.  MS are notorious for doing things the awkward way and making everyone else's products obsolete or incompatible.

I will keep this under serious advisement.  I have one or two tricks that might yet work.

Much thanks for your comments.

Cheers
Paul
0
 
ITugayCommented:
Hi Paul,

It's interesting for me, is FT solve your problem?

Cheers,
Igor.
0
 
rosethorn111199Author Commented:
To: Igor

I have not tried FT for Win 95.  As per earlier comments I have had some bad experiences with the product.

During this project I had to make a decision regarding the language support for the manuals and at that time FT and MS were incompatible and I was looking at real problems in moving the manuals to a non-FT machine.  This forced the MS choice, unpleasant as it was.

Since I am now stuck (!) in the MS world I am very reluctant to retry FT.  There is a very real possibility of creating complete incompatibility between other applications, documents etc.

Please note the I am not against FT, but due to its incompatibility with MS, I am forced away from it.

Cheers
Paul
0
 
rosethorn111199Author Commented:
I went back over all the comments today on this problem and thought long about what yours was about.  It finally occurred to me that what you were suggesting sounded really good.

Change the way Windows displays its menus, rather than change how Delphi works with them!

This problem took a lot of different approaches, but in the end this simple method of changing the fonts in the Windows Settings works really well.

In the end I used a Hebar font and I can see everything in Bulgarian!

Thanks!
Paul
0
 
rosethorn111199Author Commented:
This was a brutal problem and I have to thank everyone involved for their individual contributions and help.  Although the points were awarded to SASSAS, I have to thank everyone.

There were many dimensions, and possible solutions to this one, and in the end I needed to have all the information, from all paths to determine the best, and workable solution.

I can't recall who's comments gave me which ideas, but suffice it to say that everyone contributed something.  Thanks again to ITugay for testing out the program under a russian OS.

Cheers and thanks
Paul
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 14
  • 6
  • 2
  • +5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now