It looks like you're new here. If you want to get involved, click one of these buttons!
I am having a problem with hiding showing and hiding Tool panels.
I create user documents as tabbed docs at run time. There are 2 different document types, an editor and a viewer.
When the viewer is in focus, I want a specific Tool panel to appear and that tool panel to hide when the user selects a different editor tab.
My code hides the viewer's tool panel when it closes and un-hides it when it is opened and this works fine. However if I choose an editor tab without closing the Viewer tab, the Viewer tool panel remains. When I return to the Viewer Tab the Viewer tool panel is then hidden.
In debug stepping through the code it works as expected, its only when I run it direct that things get out of order which indicates to me that there is a race issue somewhere.
Below is the code I am using on entering, leaving and Closing the page.
procedure tfmPDFPage.DocEnter(Sender: TObject); // Code called on entering the Viewer Tab.
begin
fmIDEMain.ActivePDF := Self;
if PageID <> fmPdfExplorer.ActivePDFID then begin
gtPDFViewer1.Active := false;
fmPDFExplorer.gtPDFOutlineViewer1.Active := true; // The viewers Tool panel
gtPDFViewer1.Active := true;
fmPDFExplorer.RefreshExplorer(Self);
fmPDFExplorer.ActivePDFID := PageID;
end;
// Show the PDF Explorer
fmIDEMain.dpPDFExplorer.PanelVisible := true; // Here we make the Viewer Tool panel visible
end;
procedure TfmPDFPage.DocExit(Sender: TObject); // Code is called on leaving the viewer tab.
begin
fmPDFExplorer.gtPDFOutlineViewer1.Active := false;
fmIDEMain.dpPDFExplorer.PanelVisible := false;
end;
procedure tfmPDFPage.DocClose(Sender: TObject; // Code called on closing the Viewer Tab.
Var Action: TLMDockPanelCloseAction);
Var dz,tz, prevz: TLMDDockZone;
dp: TLMDDockPanel;
i: Integer;
begin
fmIDEMain.ActivePDF := nil; //Select the previous tab
if Assigned(ActivePanel) then begin
dp := ActivePanel;
dz := dp.zone;
if Assigned(dz) then begin
i := dz.Index;
tz := dz.parent;
if Assigned(tz) and (i > 0) then begin
prevz := tz[i - 1];
tz.SelectedPage := prevz;
tz.SelectedPage.Panel.Show;
ActivePanel := tz.SelectedPage.Panel;
end
else ActivePanel := nil;
end;
end;
Action := caFree;
end;
Comments