如何使Edit1.Font.Charset使用主题(视觉样式)
如果您有一个非主题的非Unicode VCL应用程序,其TEdit为“TestEdit”,并将TestEdit.Font.Charset设置为RUSSIAN_CHARSET,则TestEdit将显示西里尔字符。但是,如果您将应用程序切换为使用主题,则此功能不再适用。请尝试以下方法来查看:
创建一个新的VCL应用程序。
关闭默认的Unit1而不保存。
将项目源代码(Project1.pas)替换为此帖子底部的代码,并另存为CharsetTest.pas。
取消选中项目选项中的运行时主题。
运行程序,单击单选按钮,观看编辑框'字体。
现在检查项目选项中的运行时主题或将XPMan添加到uses子句。
重复步骤5。
我的问题是:即使有主题,有没有办法让应用程序尊重charset? (不切换到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.
没有找到相关结果
已邀请:
2 个回复
搜洼挂时
细瑞