Hi,
I'm creating a form with ScaleRichView and when I save the content of my ScaleRichViewEdit, I want to protect everything in it. I make every paragraphs protected but, for all the controls I added in it the only way to "protect" them is to disable them.
The problem is, when my controls are disabled and I click on them, I get the error: 'Cannot focus a disabled or invisible window'.
I'd like to know how to prevent this as I can't set the controls property CanFocus to False at runtime. Maybe you have a better solution than to disable every controls.
Thanks,
- Charles
Can't focus a disabled window
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 26
- Joined: Mon Jul 05, 2010 7:44 pm
Hi,
this is a simple example that recreates the problem.
You just have to click on the button Add Checkbox, then Protect All.
The control will then be disabled but, if you try to click on it you'll get the error: 'Cannot focus a disabled or invisible window'.
this is a simple example that recreates the problem.
You just have to click on the button Add Checkbox, then Protect All.
The control will then be disabled but, if you try to click on it you'll get the error: 'Cannot focus a disabled or invisible window'.
Code: Select all
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, SclRView, RichView, SRVControl, SRVCheckBox, StdCtrls, RVFuncs, SclRVRuler,
RVStyle;
type
TForm1 = class(TForm)
SRichViewEdit1: TSRichViewEdit;
Button1: TButton;
RVStyle1: TRVStyle;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
c : TSRVCheckBox;
begin
c := TSRVCheckBox.Create(nil);
c.Parent := SRichViewEdit1.RichViewEdit;
c.Name := 'SRVCheckBox';
c.Caption := 'SRVCheckBox';
c.Color:=clWhite;
SRichViewEdit1.RichViewEdit.InsertControl('teste', c, rvvaMiddle);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
iNbItem, INbControl: Integer;
begin
for iNbItem := 0 to RVStyle1.TextStyles.Count - 1 do
begin
SRichViewEdit1.RichViewEdit.Style.TextStyles.Items[iNbItem].Protection := [rvprStyleProtect, rvprStyleSplitProtect, rvprModifyProtect,
rvprDeleteProtect, rvprConcateProtect, rvprRVFInsertProtect, rvprDoNotAutoSwitch, rvprParaStartProtect,
rvprSticking, rvprSticking2, rvprSticking3, rvprStickToTop, rvprStickToBottom];
end;
for iNbControl := 0 to SRichViewEdit1.RichViewEdit.ControlCount - 1 do
begin
SRichViewEdit1.RichViewEdit.Controls[iNbControl].Enabled := False;
end;
end;
end.
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: