Delphi的VCL是不支持Unicode的,我查了很多!
后来我用一组叫TntUnicodeControls的控件就能解决输入和显示的问题了,但还是不能打印我就把QRLable改了一下
,我能修改它的Caption为Unicode字符了,但却显示不了! 我把代码贴出来,大家帮我改改!
unit QQRCustomLabel1;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, QuickRpt, QRCtrls, Graphics,
TntControls,TntWideStrPropHelper;
type
TtntQRCustomLabel = class(TQRCustomLabel)
private
FSettingWideCaption: Boolean;
FCaption: TWideCaption;
function IsCaptionStored: Boolean;
procedure SetInheritedCaption(const Value: AnsiString);
procedure WMSetText(var Message: TWMSetText); message WM_SETTEXT;
function GetCaption: TWideCaption;
procedure SetCaption(const Value: TWideCaption);
procedure CMDialogChar(var Message: TCMDialogChar); message CM_DIALOGCHAR;
protected
procedure DefineProperties(Filer: TFiler); override;
procedure DoDrawText(var Rect: TRect; Flags: Longint); dynamic;
function GetLabelText: WideString; reintroduce; virtual;
property Caption: TWideCaption read GetCaption write SetCaption stored IsCaptionStored;
published
end;
TtntQRLabel = class(TtntQRCustomLabel)
private
protected
published
property Alignment;
property caption;
property AutoStretch;
property Color;
property Font;
property onprint;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Tnt', [TtntQRLabel]);
end;
procedure TtntQRCustomLabel.SetInheritedCaption(const Value: AnsiString);
begin
inherited Caption := Value;
end;
procedure TtntQRCustomLabel.WMSetText(var Message: TWMSetText);
begin
if not FSettingWideCaption then
FCaption := Message.Text;
inherited;
end;
procedure TtntQRCustomLabel.DoDrawText(var Rect: TRect; Flags: Longint);
var
Text: string;
begin
Text := GetLabelText;
if (Flags and DT_CALCRECT <> 0) and ((Text = '') and
(Text[1] = '&') and (Text[2] = #0)) then Text := Text + ' ';
// if not FShowAccelChar then Flags := Flags or DT_NOPREFIX;
Flags := DrawTextBiDiModeFlags(Flags);
Canvas.Font := Font;
if not Enabled then
begin
OffsetRect(Rect, 1, 1);
Canvas.Font.Color := clBtnHighlight;
DrawText(Canvas.Handle, PChar(Text), Length(Text), Rect, Flags);
OffsetRect(Rect, -1, -1);
Canvas.Font.Color := clBtnShadow;
DrawText(Canvas.Handle, PChar(Text), Length(Text), Rect, Flags);
end
else
DrawText(Canvas.Handle, PChar(Text), Length(Text), Rect, Flags);
end;
function TtntQRCustomLabel.GetCaption: TWideCaption;
begin
Result := GetWideNonWinControlCaption(WideString(FCaption), inherited Caption);
end;
procedure TtntQRCustomLabel.SetCaption(const Value: TWideCaption);
begin
FSettingWideCaption := True;
try
SetWideNonWinControlCaption(Value, WideString(FCaption), inherited Caption, SetInheritedCaption);
finally
FSettingWideCaption := False;
end;
end;
procedure TtntQRCustomLabel.DefineProperties(Filer: TFiler);
begin
inherited;
DefineWideProperties(Filer, Self);
end;
function TtntQRCustomLabel.GetLabelText: WideString;
begin
result := Caption;
end;
function TtntQRCustomLabel.IsCaptionStored: Boolean;
begin
result := TntIsCaptionStored(Self)
end;
procedure TtntQRCustomLabel.CMDialogChar(var Message: TCMDialogChar);
begin
{ if (FocusControl <> nil) and Enabled and ShowAccelChar and
IsWideCharAccel(Message.CharCode, Caption) then
with FocusControl do
if CanFocus then
begin
SetFocus;
Message.Result := 1;
end; }
end;
end.