I think it might be a label's caption font color problem. for you can select it, but label's caption looks blank.
procedure TForm1.SRVButton1Click(Sender: TObject);
var
ACtrl: TLabel;
sItemNo: string;
sName: TRVAnsiString;
aAlign: TRVVAlign;
item: TCustomRVItemInfo;
begin
item := SRichViewEdit1.ActiveEditor.GetCurrentItem;
if item = nil then exit;
ACtrl := TLabel.Create(SRichViewEdit1.ActiveEditor);
ACtrl.Name := 'Lbl1';
ACtrl.Caption := 'Label1';
SRichViewEdit1.ActiveEditor.InsertControl(ACtrl.Name, ACtrl, rvvaBaseline);
SRichViewEdit1.Reformat;
end;
TLabel does not show in ScaleRichViewEdit
-
- Posts: 4
- Joined: Sat Jan 09, 2016 2:56 am
I use TPanel instead, It works fine.
Sorry, TLabel can be replaced by TPanel, I have changed our code
procedure TFInsertControls.ToolButton13Click(Sender: TObject);
var
c: TPanel;
begin
c := TPanel.Create(nil);
c.Parent := SRichViewEdit1.ActiveEditor;
c.Name := 'Panel';
c.Caption := 'Panel';
c.Font.Name := 'Microsoft Sans Serif';
c.Color := clWhite;
c.BevelInner := bvNone;
c.BevelOuter := bvNone;
c.BorderWidth := 0;
c.BorderStyle := bsNone;
c.Ctl3D := False;
SRichViewEdit1.ActiveEditor.InsertControl('teste', c, rvvaMiddle);
end;
procedure TFInsertControls.ToolButton13Click(Sender: TObject);
var
c: TPanel;
begin
c := TPanel.Create(nil);
c.Parent := SRichViewEdit1.ActiveEditor;
c.Name := 'Panel';
c.Caption := 'Panel';
c.Font.Name := 'Microsoft Sans Serif';
c.Color := clWhite;
c.BevelInner := bvNone;
c.BevelOuter := bvNone;
c.BorderWidth := 0;
c.BorderStyle := bsNone;
c.Ctl3D := False;
SRichViewEdit1.ActiveEditor.InsertControl('teste', c, rvvaMiddle);
end;
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Yes, TLabel was not supported in ScaleRichView, only controls inherited from TWinControl.
We made some changes to support TLabel (will be in the next update), however, there are much better alternatives:
1) TRVLabelItemInfo - not a control, it's a document item displaying text.
2) TSRVLabel - a label included in SRVControls.
These options display and scale text with higher quality than TLabel when inserted in TSRichViewEdit.
We made some changes to support TLabel (will be in the next update), however, there are much better alternatives:
1) TRVLabelItemInfo - not a control, it's a document item displaying text.
2) TSRVLabel - a label included in SRVControls.
These options display and scale text with higher quality than TLabel when inserted in TSRichViewEdit.
-
- Posts: 4
- Joined: Sat Jan 09, 2016 2:56 am
TSRVLabel works perfect
Thank you
procedure TFrameNRV.InsertLabel(rves: TCustomRichViewEdit;
sName_Prefix, sCaption: string);
var
ACtrl: TSRVLabel;
sItemNo: string;
sName: TRVAnsiString;
aAlign: TRVVAlign;
ATag: Integer;
item: TCustomRVItemInfo;
begin
ACtrl := TSRVLabel.Create(rves);
ACtrl.Parent := rves;
ACtrl.Name := 'SRVLabel1';
ACtrl.Anchors := [akLeft, akBottom];
ACtrl.Caption := sCaption;
ACtrl.AutoSize := True;
ACtrl.BackgroundColor := clWhite;
ACtrl.ForegroundColor := clBlack;
rves.InsertControl(ACtrl.Name, ACtrl, rvvaBaseline);
if rves.CurItemStyle = rvsComponent then
rves.SetCurrentItemExtraIntProperty(rvepResizable, 1, True);
rves.Reformat;
rves.SelectControl(ACtrl);
end;
procedure TFrameNRV.InsertLabel(rves: TCustomRichViewEdit;
sName_Prefix, sCaption: string);
var
ACtrl: TSRVLabel;
sItemNo: string;
sName: TRVAnsiString;
aAlign: TRVVAlign;
ATag: Integer;
item: TCustomRVItemInfo;
begin
ACtrl := TSRVLabel.Create(rves);
ACtrl.Parent := rves;
ACtrl.Name := 'SRVLabel1';
ACtrl.Anchors := [akLeft, akBottom];
ACtrl.Caption := sCaption;
ACtrl.AutoSize := True;
ACtrl.BackgroundColor := clWhite;
ACtrl.ForegroundColor := clBlack;
rves.InsertControl(ACtrl.Name, ACtrl, rvvaBaseline);
if rves.CurItemStyle = rvsComponent then
rves.SetCurrentItemExtraIntProperty(rvepResizable, 1, True);
rves.Reformat;
rves.SelectControl(ACtrl);
end;
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
You can omit Reformat, editing methods reformat the changed fragment themselves.
Also, InsertControl is a function, you can call:
Also, it's recommended to group undo for insertion and changing properties:
Also, InsertControl is a function, you can call:
Code: Select all
if rves.InsertControl(ACtrl.Name, ACtrl, rvvaBaseline) then
rves.SetCurrentItemExtraIntProperty(rvepResizable, 1, True);
Code: Select all
rves.TopLevelEditor.BeginUndoGroup(rvutInsert);
rves.TopLevelEditor.SetUndoGroupMode(True);
if rves.InsertControl(ACtrl.Name, ACtrl, rvvaBaseline) then
begin
rves.SetCurrentItemExtraIntProperty(rvepResizable, 1, True);
rves.TopLevelEditor.SelectControl(ACtrl);
end;
rves.TopLevelEditor.SetUndoGroupMode(False);