gpi Тогда так
PPersistInfo = ^TPersistInfo;
TRichEditSelInfo = record
SelStart: Integer;
SelLength: Integer;
end;
PRichEditSelInfo =^ TRichEditSelInfo;
TPersistInfo = record
WinControl: TWinControl;
SpecInfo: Integer;
function GetFocusedControl(AWinControl:
TWinControl): TWinControl;
var
i: Integer;
begin
Result := nil;
for i:=0 to AWinControl.ControlCount - 1 do
if AWinControl.Controls[i] is TWinControl then
begin
Result := GetFocusedControl(TWinControl(AWinControl.Controls[i]));
if Result <> nil then Exit;
if TWinControl(AWinControl.Controls[i]).Focused then
begin
Result := TWinControl(AWinControl.Controls[i]);
Exit;
end;
end;
end;
procedure StorePersistentInfo(Sender: TcxGrid);
var
AWinControl: TWinControl;
p: PPersistInfo;
PSelInfo: PRichEditSelInfo;
begin
AWinControl := GetFocusedControl(Sender);
if AWinControl <> nil then
begin
New(p);
p^.WinControl := AWinControl;
if AWinControl is TCustomEdit then
begin
New(PSelInfo);
PSelInfo^.SelStart := TCustomEdit(AWinControl).SelStart; <-------
PSelInfo^.SelLength := TCustomEdit(AWinControl).SelLength; <-------
p^.SpecInfo := Integer(PSelInfo);
end;
end;
end;
PPersistInfo = ^TPersistInfo;
TRichEditSelInfo = record
SelStart: Integer;
SelLength: Integer;
end;
PRichEditSelInfo =^ TRichEditSelInfo;
TPersistInfo = record
WinControl: TWinControl;
SpecInfo: Integer;
function GetFocusedControl(AWinControl:
TWinControl): TWinControl;
var
i: Integer;
begin
Result := nil;
for i:=0 to AWinControl.ControlCount - 1 do
if AWinControl.Controls[i] is TWinControl then
begin
Result := GetFocusedControl(TWinControl(AWinControl.Controls[i]));
if Result <> nil then Exit;
if TWinControl(AWinControl.Controls[i]).Focused then
begin
Result := TWinControl(AWinControl.Controls[i]);
Exit;
end;
end;
end;
procedure StorePersistentInfo(Sender: TcxGrid);
var
AWinControl: TWinControl;
p: PPersistInfo;
PSelInfo: PRichEditSelInfo;
begin
AWinControl := GetFocusedControl(Sender);
if AWinControl <> nil then
begin
New(p);
p^.WinControl := AWinControl;
if AWinControl is TCustomEdit then
begin
New(PSelInfo);
PSelInfo^.SelStart := TCustomEdit(AWinControl).SelStart; <-------
PSelInfo^.SelLength := TCustomEdit(AWinControl).SelLength; <-------
p^.SpecInfo := Integer(PSelInfo);
end;
end;
end;