如果您有一個帶TEdit「TestEdit」的非主題,非Unicode VCL應用程序並將TestEdit.Font.Charset設置爲RUSSIAN_CHARSET TestEdit顯示西里爾文字符。但是,如果您切換應用程序使用主題,這不再工作。請嘗試以下操作以查看此信息:如何使Edit1.Font.Charset與主題(視覺樣式)一起工作
- 創建一個新的VCL應用程序。
- 關閉默認Unit1而不保存。
- 將項目源代碼(Project1.pas)替換爲本帖子底部的代碼,並另存爲CharsetTest.pas。
- 取消選中項目選項中的運行時主題。
- 運行該程序,單擊單選按鈕,觀看編輯框的字體。
- 現在檢查項目選項中的運行時主題或將XPMan添加到uses子句。
- 重複步驟5.
我的問題是:有沒有一種方法,使應用程序兌現的字符集,甚至當主題? (無需切換到Unicode。)
program CharsetTest;
uses
Windows,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
StdCtrls,
ExtCtrls;
{$R *.res}
type
TForm1 = class(TForm)
private
CharsetRadioGroup: TRadioGroup;
TestEdit: TEdit;
procedure CharsetRadioGroupClick(Sender: TObject);
public
constructor Create(AOwner: TComponent); override;
end;
constructor TForm1.Create(AOwner: TComponent);
begin
inherited CreateNew(AOwner);
BorderWidth := 8;
Caption := 'Charset Test';
ClientHeight := 180;
ClientWidth := 250;
CharsetRadioGroup := TRadioGroup.Create(Self);
CharsetRadioGroup.Name := 'CharsetRadioGroup';
CharsetRadioGroup.Height := 105;
CharsetRadioGroup.Align := alTop;
CharsetRadioGroup.Caption := 'Charset';
CharsetRadioGroup.Parent := Self;
CharsetRadioGroup.Items.Add('Default');
CharsetRadioGroup.Items.Add('Russian');
CharsetRadioGroup.Items.Add('Greek');
CharsetRadioGroup.OnClick := CharsetRadioGroupClick;
TestEdit := TEdit.Create(Self);
TestEdit.Name := 'TestEdit';
TestEdit.Align := alBottom;
TestEdit.Font.Size := 20;
TestEdit.Font.Name := 'Courier New';
TestEdit.Text := 'äöüÄÖÜß';
TestEdit.Parent := Self;
CharsetRadioGroup.ItemIndex := 1;
end;
procedure TForm1.CharsetRadioGroupClick(Sender: TObject);
begin
case CharsetRadioGroup.ItemIndex of
0:
TestEdit.Font.Charset := DEFAULT_CHARSET;
1:
TestEdit.Font.Charset := RUSSIAN_CHARSET;
2:
TestEdit.Font.Charset := GREEK_CHARSET;
end;
end;
var
Form1: TForm1;
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
字符集* *所以* DOS/Windows 3.1/Windows 9x ... – 2010-11-02 19:15:25
我知道。但該應用程序的作品,我們現在不想做的Unicode步驟。 – 2010-11-02 19:17:12