⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msdn2002mainunit.pas

📁 jvcl driver development envionment
💻 PAS
📖 第 1 页 / 共 2 页
字号:
    DefaultDockLayout
  else
    LoadToolFormLayout;
end;

procedure TMSDN2002.DefaultDockLayout;

  { Dock AForm on APanel, and set it to 'auto hide' }
  procedure VSNetDockForm(AForm: TForm; APanel: TJvDockVSNETPanel);
  begin
    //  AForm.Width := 180;
    AForm.Top := 10000;
    //  AForm.Visible := true;
    AForm.ManualDock(APanel,nil,APanel.Align);
    APanel.ShowDockPanel(True, AForm);
    APanel.DoHideControl(AForm);
  end;
begin
  lbDockServer1.RightDockPanel.Width := 180;
  lbDockServer1.LeftDockPanel.Width := 180;
  lbDockServer1.BottomDockPanel.Height := 100;

  VSNetDockForm(ContentsForm, lbDockServer1.RightDockPanel as TJvDockVSNETPanel);
  VSNetDockForm(FavoritesForm, lbDockServer1.RightDockPanel as TJvDockVSNETPanel);
  VSNetDockForm(IndexForm, lbDockServer1.LeftDockPanel as TJvDockVSNETPanel);
  VSNetDockForm(IndexResultForm, lbDockServer1.LeftDockPanel as TJvDockVSNETPanel);
  VSNetDockForm(SearchForm, lbDockServer1.BottomDockPanel as TJvDockVSNETPanel);
  VSNetDockForm(SearchResultForm, lbDockServer1.BottomDockPanel as TJvDockVSNETPanel);
end;

procedure TMSDN2002.LoadToolFormLayout;
begin
  {$IFDEF USEJVCL}
  JvAppStorage.Filename := ExtractFilePath(Application.ExeName) + cStorageFilename;
  JvAppStorage.Reload; // !!!
  LoadDockTreeFromAppStorage(JvAppStorage);
  {$ELSE}
  LoadDockTreeFromFile(ExtractFilePath(Application.ExeName) + cStorageFilename);
  {$ENDIF}
end;

procedure TMSDN2002.SaveToolFormLayout;
begin
  {$IFDEF USEJVCL}
  JvAppStorage.Filename := ExtractFilePath(Application.ExeName) + cStorageFilename;
  SaveDockTreeToAppStorage(JvAppStorage);
  JvAppStorage.Flush;  // !!!
  {$ELSE}
  SaveDockTreeToFile(ExtractFilePath(Application.ExeName) + cStorageFilename);
  {$ENDIF}
end;

procedure TMSDN2002.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  SaveToolFormLayout;
  FAdapter.Free;
end;

procedure TMSDN2002.FormCreate(Sender: TObject);
begin
  FAdapter := TDockFormAdapter.Create(nil);
  {$IFDEF USEJVCL}
  JvAppStorage := TJvAppIniFileStorage.Create(self);
  {$ENDIF}
  CreateVSNETPageControl;
  LoadDockInfo;
end;

procedure TMSDN2002.Help_Contents_ActionExecute(Sender: TObject);
begin
  ShowDockForm(ContentsForm);
end;

procedure TMSDN2002.Help_Index_ActionExecute(Sender: TObject);
begin
  ShowDockForm(IndexForm);
end;

procedure TMSDN2002.Help_Search_ActionExecute(Sender: TObject);
begin
  ShowDockForm(SearchForm);
end;

procedure TMSDN2002.Help_Favorites_ActionExecute(Sender: TObject);
begin
  ShowDockForm(FavoritesForm);
end;

procedure TMSDN2002.Help_Index_results_ActionExecute(
  Sender: TObject);
begin
  ShowDockForm(IndexResultForm);
end;

procedure TMSDN2002.Help_Search_results_ActionExecute(
  Sender: TObject);
begin
  ShowDockForm(SearchResultForm);
end;

procedure TMSDN2002.CreateVSNETPageControl;
var
  Page: TJvDockVSNETTabPageControl;
  Sheet: TJvDockVSNETTabSheet;

  PageFont: TFont;
begin
  Page := TJvDockVSNETTabPageControl.Create(Self);
  Page.Parent := Self;
  Page.Align := alClient;
  Page.TabPosition := tpTop;
  Page.ActiveSheetColor := clBtnface;
  Page.InactiveFont.Color := clGray;
  Page.InactiveSheetColor := VSNETPageInactiveSheetColor;
  Page.ParentFont := True;
  SetDockSite(Page, False);
  Page.SendToBack;
  Sheet := TJvDockVSNETTabSheet.Create(Page);
  Sheet.PageControl := Page;
  Sheet.Caption := 'MSDN Library Start';
  PageFont := Page.ActiveFont;
  PageFont.Name := 'Tahoma';
  PageFont.Style := [fsBold];
  Page.ActiveFont := PageFont;

  InternalWebBrowser := TWebBrowser.Create(Sheet);
  InternalWebBrowser.OnCommandStateChange := DoCommandStateChange;
  TWinControl(InternalWebBrowser).Parent := Sheet;
  InternalWebBrowser.Align := alClient;
  View_Web_Browser_Home_Action.Execute;
end;

procedure TMSDN2002.DoCommandStateChange(Sender: TObject; Command: Integer; Enable: WordBool);
begin
  if Command = CSC_NAVIGATEBACK then
    View_Web_Browser_Web_Navigate_Back_Action.Enabled := Enable
  else if Command = CSC_NAVIGATEBACK then
      View_Web_Browser_Web_Navigate_Forward_Action.Enabled := Enable;
end;

procedure TMSDN2002.File_Exit_ActionExecute(Sender: TObject);
begin
  Close;
end;

procedure TMSDN2002.PopupMenu1Popup(Sender: TObject);
begin
  if PopupMenu1.PopupComponent is TForm then
    with FAdapter do
    begin
      Form := TForm(PopupMenu1.PopupComponent);
      AutoHide_Item.Checked := IsAutoHidden;
      AutoHide_Item.Visible := CanAutoHide;
      Dockable_Item.Checked := IsDockable;
      Dockable_Item.Enabled := not IsAutoHidden;
      Float_Item.Checked := IsFloating;
      Float_Item.Enabled := not IsAutoHidden;
      Hide_Item.Enabled := not IsAutoHidden;
    end;
end;

procedure TMSDN2002.Dockable_ItemClick(Sender: TObject);
begin
  if PopupMenu1.PopupComponent is TForm then
    with FAdapter do
    begin
      Form := TForm(PopupMenu1.PopupComponent);
      IsDockable := not IsDockable;
    end;
end;

procedure TMSDN2002.Hide_ItemClick(Sender: TObject);
begin
  if PopupMenu1.PopupComponent is TForm then
    with FAdapter do
    begin
      Form := TForm(PopupMenu1.PopupComponent);
      Hide;
    end;
end;

procedure TMSDN2002.Float_ItemClick(Sender: TObject);
begin
  if PopupMenu1.PopupComponent is TForm then
    with FAdapter do
    begin
      Form := TForm(PopupMenu1.PopupComponent);
      IsFloating := not IsFloating;
    end;
end;

//=== { TDockFormAdapter } ===================================================

constructor TDockFormAdapter.Create(AForm: TCustomForm);
begin
  inherited Create;
  Form := AForm;
end;

procedure TDockFormAdapter.AutoHide;
begin
  if Form.HostDockSite is TJvDockVSNETPanel then
    TJvDockVSNETPanel(Form.HostDockSite).DoHideControl(Form);
end;

procedure TDockFormAdapter.Float;
begin
  SetIsFloating(True);
end;

function TDockFormAdapter.GetCanAutoHide: Boolean;
begin
  Result := IsAutoHidden or (DockClient.DockState <> JvDockState_Floating);
end;

function TDockFormAdapter.GetDockClient: TJvDockClient;
begin
  if FDockClient = nil then
    FDockClient := FindDockClient(Form);
  Result := FDockClient;
end;

function TDockFormAdapter.GetIsAutoHidden: Boolean;
var
  HostDockSite: TWinControl;
begin
  HostDockSite := Form.HostDockSite;
  while (HostDockSite <> nil) and
    (HostDockSite.Parent <> nil) and
    (HostDockSite.Parent.HostDockSite <> nil) do
    HostDockSite := HostDockSite.Parent.HostDockSite;
  Result := HostDockSite is TJvDockVSPopupPanel;
end;

function TDockFormAdapter.GetIsDockable: Boolean;
begin
  Result := not IsAutoHidden and not IsTabbedDocument and DockClient.EnableDock;
end;

function TDockFormAdapter.GetIsFloating: Boolean;
begin
  Result := not IsAutoHidden and not IsTabbedDocument and not DockClient.EnableDock;
end;

procedure TDockFormAdapter.Hide;
begin
  HideDockForm(Form);
  // or call DockClient.HideParentForm;
end;

procedure TDockFormAdapter.SetForm(AForm: TCustomForm);
begin
  if AForm <> FForm then
  begin
    FDockClient := nil;
    FForm := AForm;
  end;
end;

procedure TDockFormAdapter.SetIsAutoHidden(const Value: Boolean);
begin
  if Value then
    AutoHide
  else
    UnAutoHide;
end;

procedure TDockFormAdapter.SetIsDockable(const Value: Boolean);
begin
  if not IsAutoHidden then
  begin
    if Value then
    begin
      if IsTabbedDocument then
        IsTabbedDocument := False;

      DockClient.EnableDock := True;
    end
    else
    begin
      if not IsFloating then
        IsTabbedDocument := True;
    end;
  end;
end;

procedure TDockFormAdapter.SetIsFloating(const Value: Boolean);
begin
  if not IsAutoHidden then
  begin
    if Value then
    begin
      if IsTabbedDocument then
        IsTabbedDocument := False;

      DockClient.RestoreChild;
      DockClient.EnableDock := False;
    end
    else
    begin
      if not IsDockable then
        IsTabbedDocument := True;
    end;
  end;
end;

procedure TDockFormAdapter.Show;
begin
  ShowDockForm(Form);
  // or call DockClient.ShowParentForm;
end;

procedure TDockFormAdapter.UnAutoHide;
begin
  UnAutoHideDockForm(Form);
end;

function TDockFormAdapter.GetIsTabbedDocument: Boolean;
begin
  { Not implemented }
  Result := False;
end;

procedure TDockFormAdapter.SetIsTabbedDocument(const Value: Boolean);
begin
  { Not implemented }
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -