Solved

Cyrillic in Menus

Posted on 2000-03-06
28
551 Views
Last Modified: 2008-02-20
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
Comment
Question by:rosethorn111199
  • 14
  • 6
  • 2
  • +5
28 Comments
 
LVL 9

Expert Comment

by:ITugay
ID: 2587572
What you see in menu? Something like this: "ýòî òåõò íà ðóññêì ÿçûêå"?
Is it?
0
 
LVL 1

Author Comment

by:rosethorn111199
ID: 2587603
Yes that is exactly what I am seeing now.

Cheers
Paul
0
 
LVL 9

Expert Comment

by:ITugay
ID: 2587641
Well, tell me more about your windows version, is it NT?
0
 

Expert Comment

by:Gurkan
ID: 2587728
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
 
LVL 9

Expert Comment

by:ITugay
ID: 2587838
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
 
LVL 1

Author Comment

by:rosethorn111199
ID: 2588080
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
 

Expert Comment

by:Dmitry_
ID: 2588539
Use multilanguage component, for example: http://members.tripod.com/~sushko/,
look into download ->TLanguage
I use these component and it's ok.
0
 
LVL 1

Author Comment

by:rosethorn111199
ID: 2589097
Adjusted points to 300
0
 
LVL 1

Author Comment

by:rosethorn111199
ID: 2589098
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
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2589336
Listening
0
 

Expert Comment

by:Dmitry_
ID: 2590576
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
 
LVL 1

Accepted Solution

by:
sassas081597 earned 500 total points
ID: 2590602
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
 
LVL 9

Expert Comment

by:ITugay
ID: 2590645
You can send me  compilled part of application via e-mail, and I tell you how it look.

Best regards,
igor@novell.kz
0
 
LVL 1

Author Comment

by:rosethorn111199
ID: 2591478
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 1

Expert Comment

by:DValery
ID: 2596109
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
 
LVL 1

Author Comment

by:rosethorn111199
ID: 2596970
That looks promising.

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

Thanks.
Paul
0
 
LVL 1

Author Comment

by:rosethorn111199
ID: 2597160
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
 
LVL 9

Expert Comment

by:ITugay
ID: 2599738
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
 
LVL 1

Author Comment

by:rosethorn111199
ID: 2601594
Adjusted points to 500
0
 
LVL 1

Author Comment

by:rosethorn111199
ID: 2601595
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
 
LVL 17

Expert Comment

by:geobul
ID: 2611829
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
 
LVL 1

Author Comment

by:rosethorn111199
ID: 2612102
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
 
LVL 17

Expert Comment

by:geobul
ID: 2612725
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
 
LVL 1

Author Comment

by:rosethorn111199
ID: 2613856
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
 
LVL 9

Expert Comment

by:ITugay
ID: 2639507
Hi Paul,

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

Cheers,
Igor.
0
 
LVL 1

Author Comment

by:rosethorn111199
ID: 2640035
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
 
LVL 1

Author Comment

by:rosethorn111199
ID: 2640107
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
 
LVL 1

Author Comment

by:rosethorn111199
ID: 2640121
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now