CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  C++ Builder >  基础类

FindDialog组件求助!!!!!!

楼主dytmh(蓝色生命线)2006-03-01 11:49:17 在 C++ Builder / 基础类 提问

1。买了本垃圾教程,一到关键时侯就有印错的.  
  2。网上找了点FindDialog的看,一样的错,看来是你抄我,我抄你.  
   
  进入正题:  
   
  FoundAt=RichEdit1->FindText(FindDialog1->FindText,StartPos,ToEnd,TSearchTypes);  
   
  由于是基础教程,说也没说清.  
   
  TSearchTypes应该是查找框里要查找的词   怎么样能得到这个? 问题点数:20、回复次数:6Top

1 楼lurel(城市陌生人)回复于 2006-03-01 12:11:51 得分 0

enum   TSearchType   {   stWholeWord,   stMatchCase   };  
  其中:stWholeWord代表全文匹配,stMatchCase代表部分匹配  
   
  BCB有example如下:  
  void   __fastcall   TForm1::Button1Click(TObject   *Sender)  
   
  {  
      FindDialog1->Position   =   Point(RichEdit1->Left   +   RichEdit1->Width,   RichEdit1->Top);  
      FindDialog1->Execute();  
   
  }  
   
  void   __fastcall   TForm1::FindDialog1Find(TObject   *Sender)  
   
  {  
      int   FoundAt,   StartPos,   ToEnd;  
      //   begin   the   search   after   the   current   selection    
      //   if   there   is   one    
      //   otherwise,   begin   at   the   start   of   the   text    
      if   (RichEdit1->SelLength)  
          StartPos   =   RichEdit1->SelStart   +   RichEdit1->SelLength;  
      else  
   
          StartPos   =   0;  
   
      //   ToEnd   is   the   length   from   StartPos    
      //   to   the   end   of   the   text   in   the   rich   edit   control  
   
      ToEnd   =   RichEdit1->Text.Length()   -   StartPos;  
   
      FoundAt   =   RichEdit1->FindText(FindDialog1->FindText,   StartPos,   ToEnd,   TSearchTypes()<<   stMatchCase);  
      if   (FoundAt   !=   -1)  
      {  
          RichEdit1->SetFocus();  
          RichEdit1->SelStart   =   FoundAt;  
          RichEdit1->SelLength   =   FindDialog1->FindText.Length();  
      }  
  }Top

2 楼dytmh(蓝色生命线)回复于 2006-03-01 12:53:59 得分 0

还有没其它列子的?Top

3 楼lurel(城市陌生人)回复于 2006-03-01 13:07:10 得分 0

楼主看不明白例子吗?Top

4 楼dytmh(蓝色生命线)回复于 2006-03-01 13:28:19 得分 0

enum     TSearchType     {     stWholeWord,     stMatchCase     };     枚举  
   
  然后   怎么返回的   TSearchType     就不懂了Top

5 楼dytmh(蓝色生命线)回复于 2006-03-01 13:34:23 得分 0

TSearchTypes   st;  
  TFindDialog   *cd;  
   
  if   (cd->Options.Contains(frMatchCase))  
                  st   <<   stMatchCase;  
          if   (cd->Options.Contains(frWholeWord))  
                  st   <<   stWholeWord;  
  newpos   =   RichEdit1->FindText(cd->FindText,RichEdit1->SelStart,RichEdit1->Text.Length(),st);  
  Top

6 楼dytmh(蓝色生命线)回复于 2006-03-01 13:44:02 得分 0

void   __fastcall   TForm1::FindDialogFind(TObject   *Sender)  
  {  
          TSearchTypes   st;  
          TFindDialog   *cd;  
          int   newpos;  
   
          if   ((cd   =   dynamic_cast<TFindDialog   *>   (Sender))   ==   0)  
                  MessageBox(NULL,   "Dynamic   Cast   Failed!",   "Find/Rep",   MB_OK);  
   
          if   (cd->OptionsContains(frMatchCase))  
                  st   <<   stMatchCase;  
          if   (cd->Options.Contains(frWholeWord))  
                  st   <<   stWholeWord;  
   
          if   (RichEdit1->SelLength)  
                  RichEdit1->SelStart   +=   1;  
   
          newpos   =   RichEdit1->FindText(cd->FindText,  
                                                  RichEdit1->SelStart,  
                                                  RichEdit1->Text.Length(),  
                                                  st);  
   
          if   (newpos   !=   -1)  
          {  
                  RichEdit1->SelStart   =   newpos;  
                  RichEdit1->SelLength   =   cd->FindText.Length();  
          }  
          else  
          {  
                  MessageBox(NULL,   "End   of   document   reached.",   "Find/Rep",   MB_OK);  
                  RichEdit1->SelStart   =   0;  
          }  
  }Top

相关问题

  • 组件
  • 组件
  • 寻求组件
  • 使用组件
  • !!!!组件开发!!!!
  • 组件问题
  • Active 组件?
  • VB做组件??
  • 组件问题!
  • VB组件

关键词

  • richedit1
  • finddialog
  • tsearchtypes
  • findtext
  • selstart
  • toend
  • stmatchcase
  • stwholeword
  • startpos
  • newpos

得分解答快速导航

  • 帖主:dytmh

相关链接

  • CSDN Blog
  • 技术文档
  • 代码下载
  • 第二书店
  • 读书频道

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo