Demo1Frm.cpp
上传用户:daoqigc
上传日期:2021-04-20
资源大小:2795k
文件大小:3k
- //---------------------------------------------------------------------------
- #include <vclvcl.h>
- #pragma hdrstop
- #include "Demo1Frm.h"
- #include "MainFrm.h"
- //---------------------------------------------------------------------------
- #pragma link "RichView"
- #pragma link "RVScroll"
- #pragma resource "*.dfm"
- TfrmDemo1 *frmDemo1;
- //---------------------------------------------------------------------------
- __fastcall TfrmDemo1::TfrmDemo1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmDemo1::FormCreate(TObject *Sender)
- {
- TSearchRec SearchRec;
- lst->Items->BeginUpdate();
- rv->AddNL("When you scroll this document to some file, corresponded item in "
- "the left list box is highlighted.",sncomHeading,0);
- rv->AddNL("Double-click on the listbox to scroll the document to the file.",
- sncomHeading,0);
- rv->AddNL("Right-click to show/hide 'checkpoints'.",
- sncomHeading,0);
- if (FindFirst(ExtractFilePath(Application->ExeName)+"*.cpp",
- 0,SearchRec) == 0)
- do
- {
- lst->Items->Add(SearchRec.Name);
- // Marking next added item with checkpoint
- rv->AddNamedCheckpointEx(SearchRec.Name, True);
- // Adding name of file
- rv->AddNL(SearchRec.Name,sncomKeyword,3);
- // Adding text from file.
- // Last parameter = True, so all text will be loaded as one
- // paragraph, and displayed in the single frame
- rv->LoadText(ExtractFilePath(Application->ExeName)+SearchRec.Name, sncomNormal, 2, true);
- } while (FindNext(SearchRec)==0);
- FindClose(SearchRec);
- lst->Items->EndUpdate();
- rv->Format();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmDemo1::rvCheckpointVisible(TCustomRichView *Sender,
- TCheckpointData CheckpointData)
- {
- if (!CheckpointData)
- lst->ItemIndex = -1;
- else
- lst->ItemIndex = rv->GetCheckpointNo(CheckpointData);
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmDemo1::lstDblClick(TObject *Sender)
- {
- if (lst->ItemIndex!=-1)
- rv->ScrollTo(rv->GetCheckpointY(lst->ItemIndex));
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmDemo1::FormKeyDown(TObject *Sender, WORD &Key,
- TShiftState Shift)
- {
- if (Key==VK_ESCAPE)
- Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmDemo1::pmPopup(TObject *Sender)
- {
- mitShowCP->Checked = rv->Options.Contains(rvoShowCheckpoints);
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmDemo1::mitShowCPClick(TObject *Sender)
- {
- if (rv->Options.Contains(rvoShowCheckpoints))
- rv->Options >> rvoShowCheckpoints;
- else
- rv->Options << rvoShowCheckpoints;
- rv->Invalidate();
- }
- //---------------------------------------------------------------------------