问题是这样的:
有一段时间,我的Delphi6中大多数控件的String类型的属性都具有多行编辑的功能(可能安装了什么东西),很方便,可不知什么时候又没了(Delphi6重新安装过)。比如,Label的Caption属性,一般可视控件的Hint属性等,它们在属性编辑器里除了可以直接输入字符串值以外,右边还有“...”,点击可以打开一个多行编辑窗口,就象Memo的Lines属性一样。不知道是怎么有的,又不知怎么没了。
我想,可能是需要安装了什么设计期包吧!不知道大家明白我的意思没有?
请高手指点。
有一段时间,我的Delphi6中大多数控件的String类型的属性都具有多行编辑的功能(可能安装了什么东西),很方便,可不知什么时候又没了(Delphi6重新安装过)。比如,Label的Caption属性,一般可视控件的Hint属性等,它们在属性编辑器里除了可以直接输入字符串值以外,右边还有“...”,点击可以打开一个多行编辑窗口,就象Memo的Lines属性一样。不知道是怎么有的,又不知怎么没了。
我想,可能是需要安装了什么设计期包吧!不知道大家明白我的意思没有?
请高手指点。
autosize := false;就OK了
我指的是在属性编辑器里边在输入Caption或Hint属性时,本来就有一个可以输入多行字符串的功能。可以直接输入多行的文本,就象Memo的Lines属性一样,点击"..."就会弹出一个StringsEditor。
label.caption:='aaa'+#13#10+'bbb';
RegisterPropertyEditor(TypeInfo(TString), TWinControl, '', TMyPropertyEditor);
另外你也可以安装下面的Pas单元到你的dclusr中即可:
unit StrEditor;interfaceuses Windows,Classes, Controls, StdCtrls,Buttons, TypInfo,Forms,ExtCtrls,
{$IFDEF VER140}DesignIntf, VCLEditors {$ELSE} DsgnIntf{$ENDIF};type
TStrEditDlg = class(TForm)
Memo: TMemo;
BtnOK: TBitBtn;
BtnCancel: TBitBtn;
Bevel1: TBevel;
BtnAbout: TBitBtn;
Label1: TLabel;
procedure BtnAboutClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure CreateParams(var Param:TCreateParams);override;
end;type
TCaptionEditor = class(TCaptionProperty)
public
function GetAttributes: TPropertyAttributes; override;
procedure Edit; override;
end;procedure Register;implementation{$R *.DFM}procedure Register;
begin
RegisterPropertyEditor(TypeInfo(TCaption), TObject, 'Caption', TCaptionEditor);
RegisterPropertyEditor(TypeInfo(TCaption), TObject, 'Text', TCaptionEditor);
RegisterPropertyEditor(TypeInfo(string), TObject, 'Hint', TCaptionEditor);
end; { Register }{ THintProperty }procedure TCaptionEditor.Edit;
var
Comp : TPersistent;
begin
with TStrEditDlg.Create(Application) do
try
Comp := GetComponent(0);
if Comp is TComponent then
Caption := TComponent(Comp).Name + '.' + GetName
else
Caption := GetName;
Memo.Text :=GetStrValue;
Memo.SelectAll;
if ShowModal = mrOk then
SetStrValue(Memo.Text);
finally
Free;
end;
end; { TCaptionEditor.Edit }function TCaptionEditor.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paDialog];
end; { TCaptionEditor.GetAttributes }procedure TStrEditDlg.BtnAboutClick(Sender: TObject);
begin
MessageBox(Handle,'Copyright (C) Kingron 2002','Info',MB_OK+MB_ICONINFORMATION);
end; { TStrEditDlg.BtnAboutClick }procedure TStrEditDlg.CreateParams(var Param: TCreateParams);
begin
inherited;
Param.WndParent :=GetActiveWindow;
end;end.
Left = 283
Top = 106
BorderStyle = bsDialog
Caption = 'String Editor'
ClientHeight = 221
ClientWidth = 347
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Position = poDesktopCenter
DesignSize = (
347
221)
PixelsPerInch = 96
TextHeight = 13
object Bevel1: TBevel
Left = 8
Top = 11
Width = 329
Height = 161
Anchors = [akLeft, akTop, akRight, akBottom]
Shape = bsFrame
end
object Label1: TLabel
Left = 17
Top = 20
Width = 139
Height = 13
Caption = 'Press Ctrl+Enter to break line:'
end
object Memo: TMemo
Left = 16
Top = 40
Width = 313
Height = 121
Anchors = [akLeft, akTop, akRight, akBottom]
HideSelection = False
ScrollBars = ssVertical
TabOrder = 0
WantReturns = False
end
object BtnOK: TBitBtn
Left = 176
Top = 188
Width = 75
Height = 25
Anchors = [akLeft, akBottom]
Caption = '&OK'
TabOrder = 1
Kind = bkOK
end
object BtnCancel: TBitBtn
Left = 264
Top = 188
Width = 75
Height = 25
Anchors = [akLeft, akBottom]
Caption = '&Cancel'
TabOrder = 2
Kind = bkCancel
end
object BtnAbout: TBitBtn
Left = 8
Top = 188
Width = 75
Height = 25
Anchors = [akLeft, akBottom]
Caption = '&About'
TabOrder = 3
OnClick = BtnAboutClick
Kind = bkHelp
end
end