Unit1.cpp
上传用户:daoqigc
上传日期:2021-04-20
资源大小:2795k
文件大小:4k
源码类别:

RichEdit

开发平台:

Delphi

  1. /*==============================================================================}
  2. { This demo shows how checkpoints can generate events when they become visible }
  3. {------------------------------------------------------------------------------}
  4. { Properties set:                                                              }
  5. {  RichView1->CPEventKind = cpeAsSectionStart                                  }
  6. {  RichView2->CPEventKind = cpeWhenVisible                                     }
  7. {  rvoShowCheckpoints included in Options of both RichViews                    }
  8. {------------------------------------------------------------------------------}
  9. { Key properties, events and methods:                                          }
  10. { - CPEventKind                                                                }
  11. { - OnCheckpointVisible                                                        }
  12. { - AddNamedCheckpointEx                                                       }
  13. {=============================================================================*/
  14. #include <vclvcl.h>
  15. #pragma hdrstop
  16. #include "Unit1.h"
  17. //---------------------------------------------------------------------------
  18. #pragma link "RichView"
  19. #pragma link "RVScroll"
  20. #pragma link "RVStyle"
  21. #pragma resource "*.dfm"
  22. TForm1 *Form1;
  23. //---------------------------------------------------------------------------
  24. __fastcall TForm1::TForm1(TComponent* Owner)
  25.     : TForm(Owner)
  26. {
  27. }
  28. //---------------------------------------------------------------------------
  29. void __fastcall TForm1::FormCreate(TObject *Sender)
  30. {
  31.   int i,j;
  32.   // 1. Filling in left RichView
  33.   for (i=1; i<4; i++)
  34.   {
  35.     RichView1->AddNamedCheckpointEx(AnsiString("Chapter ")+IntToStr(i),True);
  36.     RichView1->AddFmt("Chapter %d", ARRAYOFCONST((i)), 1,1);
  37.     for (j=0; j<30; j++)
  38.       RichView1->AddNL("Bla - bla - bla - bla - bla - bla.",0,0);
  39.   }
  40.   RichView1->Format();
  41.   // 2. Filling in right RichView
  42.   for (i=1; i<4; i++)
  43.   {
  44.     RichView2->AddNamedCheckpointEx(AnsiString("Figure ")+IntToStr(i),True);
  45.     TIcon* ico = new TIcon;
  46.     ico->Assign(Image1->Picture->Graphic);
  47.     RichView2->AddPictureEx("", ico, 1, rvvaBaseline);
  48.     RichView2->AddFmt("Figure %d", ARRAYOFCONST((i)), 3,1);
  49.     for (j=0; j<30; j++)
  50.       RichView2->AddNL("Bla - bla - bla - bla - bla - bla.",0,0);
  51.   }
  52.   RichView2->Format();
  53.   /*
  54.     Comments:
  55.     1.
  56.     In this demo we use AddNamedCheckpointEx method.
  57.     It has second parameter - RaiseEvent: Boolean.
  58.     If set to True, RichView will generate event when this checkpoint
  59.     becomes visible
  60.     2.
  61.     Checkpoints with RaiseEvent=True can be displayed with different color
  62.     than other checkpoints.
  63.     Color of "normal" checkpoints: RVStyle->CheckpointColor;
  64.     Color of "RaiseEvent" checkpoints: RVStyle->CheckpointEvColor
  65.   */
  66. }
  67. //---------------------------------------------------------------------------
  68. void __fastcall TForm1::RichView1CheckpointVisible(TCustomRichView *Sender,
  69.     TCheckpointData CheckpointData)
  70. {
  71.   AnsiString Name;
  72.   int        Tag;
  73.   bool       RE;
  74.   if (CheckpointData)
  75.   {
  76.     RichView1->GetCheckpointInfo(CheckpointData, Tag, Name, RE);
  77.     lblChapter->Caption = Name;
  78.   }
  79. }
  80. //---------------------------------------------------------------------------
  81. void __fastcall TForm1::RichView2CheckpointVisible(TCustomRichView *Sender,
  82.     TCheckpointData CheckpointData)
  83. {
  84.   AnsiString Name;
  85.   int        Tag;
  86.   bool       RE;
  87.   if (CheckpointData)
  88.   {
  89.     RichView2->GetCheckpointInfo(CheckpointData, Tag, Name, RE);
  90.     lblFigure->Caption = Name;
  91.   }
  92.   else
  93.     lblFigure->Caption = "(none)";
  94. }
  95. //---------------------------------------------------------------------------