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

📄 sampledockingmain.cpp

📁 胜天进销存源码,国产优秀的进销存
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "SampleDockingMain.h"
#include "EBarsDemoRating.h"
#include "SampleDockingAbout.h"
#include "SampleDockingListBox.h"
#include "SampleDockingRadioGroup.h"
#include "SampleDockingRichText.h"
#include "SampleDockingTreeView.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "cxControls"
#pragma link "dxStatusBar"
#pragma link "dxBar"
#pragma link "dxBarExtItems"
#pragma link "dxDockControl"
#pragma link "cxGraphics"
#pragma resource "*.dfm"
TSampleDockingMainForm *SampleDockingMainForm;
//---------------------------------------------------------------------------
__fastcall TSampleDockingMainForm::TSampleDockingMainForm(TComponent* Owner)
  : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TSampleDockingMainForm::FormCreate(TObject *Sender)
{
  dmCommonData->AboutFormClass = __classid(TSampleDockingAboutForm);
}
//---------------------------------------------------------------------------
void __fastcall TSampleDockingMainForm::FormDestroy(TObject *Sender)
{
  ClearContent();
}
//---------------------------------------------------------------------------

TWinControl* __fastcall GetFocusedControl(TWinControl* AWinControl)
{
  TWinControl* Result = NULL;
  for (int i=0; i< AWinControl->ControlCount; i++)
    if (dynamic_cast<TWinControl*>(AWinControl->Controls[i])) {
      Result = GetFocusedControl(((TWinControl*)AWinControl->Controls[i]));
      if (Result != NULL) return (Result);
      if (((TWinControl*)AWinControl->Controls[i])->Focused()) {
        Result = ((TWinControl*)AWinControl->Controls[i]);
        return (Result);
      }
    }
  return (Result);  
}
//---------------------------------------------------------------------------

void __fastcall RestorePersistentInfo(TdxCustomDockControl* Sender)
{
  if (Sender->Visible && (Sender->Tag != 0)) {
    if (((PPersistInfo)Sender->Tag)->WinControl->CanFocus()) {
      ((PPersistInfo)Sender->Tag)->WinControl->SetFocus();
    }
    if (dynamic_cast<TCustomEdit*>(((PPersistInfo)Sender->Tag)->WinControl)) {
      ((TCustomEdit*)((PPersistInfo)Sender->Tag)->WinControl)->SelStart = ((PRichEditSelInfo)((PPersistInfo)Sender->Tag)->SpecInfo)->SelStart;
      ((TCustomEdit*)((PPersistInfo)Sender->Tag)->WinControl)->SelLength = ((PRichEditSelInfo)((PPersistInfo)Sender->Tag)->SpecInfo)->SelLength;
      delete (PRichEditSelInfo)((PPersistInfo)Sender->Tag)->SpecInfo;
    }
    delete (PPersistInfo)Sender->Tag;
    Sender->Tag = 0;
  }
}
//---------------------------------------------------------------------------

void __fastcall StorePersistentInfo(TdxCustomDockControl* Sender)
{
  if (Sender->Visible && (Sender->Tag == 0)) {
    TWinControl*  AWinControl = GetFocusedControl(Sender);
    if (AWinControl != NULL) {
      PPersistInfo p = new TPersistInfo;
      p->WinControl = AWinControl;
      if (dynamic_cast<TCustomEdit*>(AWinControl)) {
        PRichEditSelInfo PSelInfo = new TRichEditSelInfo;
        PSelInfo->SelStart = ((TCustomEdit*)AWinControl)->SelStart;
        PSelInfo->SelLength = ((TCustomEdit*)AWinControl)->SelLength;
        p->SpecInfo = (int)PSelInfo;
        Sender->Tag = (int)p;
      }
      Sender->Tag = (int)p;
    }
  }
}
//---------------------------------------------------------------------------

void __fastcall TSampleDockingMainForm::ClearContent()
{
  int Count = dxDockingController()->DockControlCount - 1;
  while (Count >= 0) {
    if (dynamic_cast<TdxDockPanel*>(dxDockingController()->DockControls[Count]))
      delete dxDockingController()->DockControls[Count];
    if ((dxDockingController()->DockControlCount - 1) < (Count - 1))
      Count = dxDockingController()->DockControlCount - 1; else
    Count--;
  };
  FTreeViewFrameCount = 0;
  FDockingRichTextFrameCount = 0;
  FRadioGroupFrameCount = 0;
  FListBoxFrameCount = 0;
}
//---------------------------------------------------------------------------

void __fastcall TSampleDockingMainForm::SetPanelsVisibility(bool AVisible)
{
  for(int i=0; i < dxDockingController()->DockControlCount; i++)
    if (dynamic_cast<TdxCustomDockControl*>(dxDockingController()->DockControls[i]) && (dxDockingController()->DockControls[i] != DockSite1)) {
      if ((!AVisible) && dxDockingController()->DockControls[i]->AutoHide)
        dxDockingController()->DockControls[i]->Visible = true;
      dxDockingController()->DockControls[i]->Visible = AVisible;
    }
}
//---------------------------------------------------------------------------

void __fastcall TSampleDockingMainForm::CreateScheme1()
{
  TdxDockPanel* Panel1 = new TdxDockPanel(this);
  HookupEvents(Panel1);
  Panel1->Height = 360;
  Panel1->DockTo(DockSite1, dtBottom, 0);
  CreateFrame(ListBoxFrame, Panel1);

  TdxDockPanel* Panel2 = new TdxDockPanel(this);
  HookupEvents(Panel2);
  Panel2->DockTo(Panel1, dtClient, 1);
  CreateFrame(RadioGroupFrame, Panel2);

  TdxDockPanel* Panel = new TdxDockPanel(this);
  HookupEvents(Panel);
  Panel->DockTo(Panel2->TabContainer, dtTop, 0);
  CreateFrame(TreeViewFrame, Panel);

  Panel1 = new TdxDockPanel(this);
  HookupEvents(Panel1);
  Panel1->DockTo(Panel, dtClient, 0);
  CreateFrame(RichTextFrame, Panel1);
}
//---------------------------------------------------------------------------

void __fastcall TSampleDockingMainForm::CreateScheme2()
{
  TdxDockPanel* Panel1 = new TdxDockPanel(this);
  HookupEvents(Panel1);
  Panel1->Height = 300;
  Panel1->DockTo(DockSite1, dtRight, 0);
  CreateFrame(TreeViewFrame, Panel1);

  TdxDockPanel* Panel2 = new TdxDockPanel(this);
  HookupEvents(Panel2);
  Panel2->DockTo(Panel1, dtClient, 1);
  CreateFrame(RichTextFrame, Panel2);

  TdxDockPanel* Panel = new TdxDockPanel(this);
  HookupEvents(Panel);
  Panel->DockTo(Panel1, dtLeft, 0);
  CreateFrame(RadioGroupFrame, Panel);
}
//---------------------------------------------------------------------------

void __fastcall TSampleDockingMainForm::CreateScheme3()
{
  TdxDockPanel* Panel1 = new TdxDockPanel(this);
  HookupEvents(Panel1);
  Panel1->DockTo(DockSite1, dtLeft, 0);
  Panel1->AutoHide = true;
  CreateFrame(RichTextFrame, Panel1);

  TdxDockPanel* Panel2 = new TdxDockPanel(this);
  HookupEvents(Panel2);
  Panel2->Height = 170;
  Panel2->DockTo(DockSite1, dtTop, 0);
  Panel2->AutoHide = true;
  CreateFrame(RadioGroupFrame, Panel2);

  TdxDockPanel* Panel3 = new TdxDockPanel(this);
  HookupEvents(Panel3);
  Panel3->DockTo(DockSite1, dtRight, 0);
  Panel3->AutoHide = true;
  CreateFrame(TreeViewFrame, Panel3);

  TdxDockPanel* Panel4 = new TdxDockPanel(this);
  HookupEvents(Panel4);
  Panel4->Height = 190;
  Panel4->DockTo(DockSite1, dtBottom, 0);
  Panel4->AutoHide = true;
  CreateFrame(ListBoxFrame, Panel4);
}
//---------------------------------------------------------------------------

void __fastcall TSampleDockingMainForm::CreateScheme4()
{
  TdxDockPanel* Panel1 = new TdxDockPanel(this);
  HookupEvents(Panel1);
  Panel1->MakeFloating(Left + 50, Top + 100);
  CreateFrame(TreeViewFrame, Panel1);

  TdxDockPanel* Panel2 = new TdxDockPanel(this);
  HookupEvents(Panel2);
  Panel2->DockTo(Panel1, dtClient, 0);
  CreateFrame(RichTextFrame, Panel2);
}
//---------------------------------------------------------------------------

void __fastcall TSampleDockingMainForm::CreateScheme5()
{
  TdxDockPanel* Panel1 = new TdxDockPanel(this);
  HookupEvents(Panel1);
  Panel1->Height = 350;
  Panel1->DockTo(DockSite1, dtBottom, 0);
  CreateFrame(ListBoxFrame, Panel1);

  TdxDockPanel* Panel2 = new TdxDockPanel(this);
  HookupEvents(Panel2);
  Panel2->DockTo(Panel1, dtRight, 1);
  CreateFrame(TreeViewFrame, Panel2);

  TdxDockPanel* Panel3 = new TdxDockPanel(this);
  HookupEvents(Panel3);
  Panel3->DockTo(Panel1, dtTop, 0);
  CreateFrame(RichTextFrame, Panel3);
}
//---------------------------------------------------------------------------

void __fastcall TSampleDockingMainForm::HookupEvents(TdxCustomDockControl* Sender)
{
  if (dynamic_cast<TdxDockSite*>(Sender)) {
    ((TdxDockSite*)Sender)->OnShowControl = ShowDockControl;
    ((TdxDockSite*)Sender)->OnHideControl = HideDockControl;
  }
  Sender->OnAutoHideChanged = AutoHideChanged;
  Sender->OnAutoHideChanging = AutoHideChanging;
  #if __BORLANDC__ == 0x0560
  Sender->OnContextPopup = dpContextPopup;
  #endif
  Sender->OnEndDocking = EndDock;
  Sender->OnStartDocking = StartDock;
  Sender->OnCreateTabContainer = CreateTabContainer;

⌨️ 快捷键说明

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