[Lazarus] How to set focus in an Edit in multiple TabSheet?
Bart
bartjunk64 at gmail.com
Mon Dec 12 11:23:35 CET 2011
On 12/11/11, silvioprog <silvioprog at gmail.com> wrote:
> I tried to run this code, but I have not found the function
> GetCurrentEditor.
This code just finds the active tabsheet, then finds an instance of
TEditor on it.
It'rather trivial.
function TEditorPageControl.GetCurrentEditor: TEditor;
var
Pg: TTabSheet;
begin
Result := nil;
//ActivePageIndex = -1 when you remove the last (as in no more pages
available) page
//PageCount will still be 1 at this time
if (PageCount > 0) and (ActivePageIndex >= 0) then
begin
Pg := Pages[ActivePageIndex];
Result := EditorAtPage(Pg);
end;
end;
And now you want to know the implementation of EditorAtPage()
function TEditorPageControl.EditorAtPage(const APage: TTabSheet): TEditor;
var
cc: Integer;
begin
Result := nil;
if not Assigned(APage) then Exit;
for cc := 0 to APage.ComponentCount - 1 do
begin
if APage.Components[cc] is TEditor then
begin
Result := TEditor(APage.Components[cc]);
Exit;
end;
end;
end;
>
> This code works with a PageControl over another PageControl?
>
I never have had that (a PageControl inside anothe PageControl is what
you mean by that?).
Bart
More information about the Lazarus
mailing list