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

RichEdit

开发平台:

Delphi

  1. //---------------------------------------------------------------------------
  2. #include <vclvcl.h>
  3. #pragma hdrstop
  4. #include "MainFrm.h"
  5. #include "Demo7Frm.h"
  6. //---------------------------------------------------------------------------
  7. #pragma link "RVEdit"
  8. #pragma link "RichView"
  9. #pragma link "RVScroll"
  10. #pragma resource "*.dfm"
  11. TfrmDemo7 *frmDemo7;
  12. //---------------------------------------------------------------------------
  13. __fastcall TfrmDemo7::TfrmDemo7(TComponent* Owner)
  14.     : TForm(Owner)
  15. {
  16. }
  17. //---------------------------------------------------------------------------
  18. void __fastcall TfrmDemo7::FormCreate(TObject *Sender)
  19. {
  20.   rve->Clear();
  21.   rve->LoadText(ExtractFilePath(Application->ExeName)+"MainFrm.cpp",0,0, false);
  22.   rve->Format();
  23. }
  24. //---------------------------------------------------------------------------
  25. void __fastcall TfrmDemo7::FormKeyDown(TObject *Sender, WORD &Key,
  26.     TShiftState Shift)
  27. {
  28.   if (Key==VK_ESCAPE)
  29.     Close();    
  30. }
  31. //---------------------------------------------------------------------------
  32. void __fastcall TfrmDemo7::btnMarkClick(TObject *Sender)
  33. {
  34.   rve->SetSelectionBounds(0,rve->GetOffsBeforeItem(0),0,rve->GetOffsBeforeItem(0));
  35.   while (rve->SearchText(txt->Text, TRVESearchOptions()<<rvseoDown))
  36.     rve->ApplyTextStyle(sncomMarked);
  37. // Note: every call of ApplyTextStyle reformats affected paragraphs
  38. }
  39. //---------------------------------------------------------------------------
  40. void __fastcall TfrmDemo7::btnUnmarkClick(TObject *Sender)
  41. {
  42.   rve->SelectAll();
  43.   rve->ApplyTextStyle(sncomNormal);
  44.   rve->Deselect();
  45.   rve->Refresh();
  46. }
  47. //---------------------------------------------------------------------------