[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

using  CRichEditCtrl::FindText  ..

Posted on 2002-03-20
7
Medium Priority
?
1,183 Views
Last Modified: 2013-11-20
hi all!

I have build my own Find/Replace dialog ( derived from CDialog class) to search into a CRichEditCtrl .
now, everything is working just fine except 1 thing: how can implement "direction up" option ?? I mean to search from the current position to the beginning of the document ?? .. FindText method can't do it ..

10x
0
Comment
Question by:dragosh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 3

Expert Comment

by:GGRUNDY
ID: 6884241
The documentation on CRichEditCtrl::FindText says

Call this function to find text within the rich edit control. You can search either up or down by setting the proper range parameters in theCHARRANGE structure within the FINDTEXTEX structure.

I assume this means you just reverse the values of
cpMin & cpMax to search up.

Cheers

0
 
LVL 3

Author Comment

by:dragosh
ID: 6884922
hi ggrundy

i've try that and it doesn't help ... in this way I set the range of text where to search , but NOT the "direction up" .. if I set cpMin = 0 and cMax let's say 1000 (current position) and click Find next I get the first match from the beginning of the document, not first match from current position ..

any ideas ??

10x
0
 
LVL 3

Expert Comment

by:GGRUNDY
ID: 6884943
Are you saying that you have tried

cpMin = nCurrentPosition;
cpMax = 0;

and it doesn't work???
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Author Comment

by:dragosh
ID: 6884952
hi ggrundy

yes: it returns -1 ..
0
 
LVL 3

Accepted Solution

by:
GGRUNDY earned 150 total points
ID: 6885387
Here's an answer (AND IT's NOT PRETTY). :-(

The following code...
================================================
int n;
m_edit.SetWindowText("When your mom is mad with your dad, don't let her brush your hair.");
FINDTEXT range = {{0,0},"your"};
m_edit.SetSel(-1,-1);
m_edit.GetSel(range.chrg);
range.chrg.cpMax=0;
while((n = m_edit.SendMessage(EM_FINDTEXT, 0, (LPARAM)&range))!=-1){
  TRACE("text found at %d\n",n);
  range.chrg.cpMin = n;
  }
===================================================
Produces the following output...
text found at 56
text found at 26
text found at 5
===================================================
Indicating that indeed you can search backwards by swapping the cpMin & cpMax values around, BUT....

a) you can't use -1 to indicate the end of the file; and
b) you can't use version 1.0 of the rich edit control.
Because I created my Rich Edit control using the dialog resource editor I had to subsequently manually edit my .rc file as text and change
this line
CONTROL  "",IDC_RICHEDIT,"RichEdit" ,ES_MULTILINE | WS_BORDER | WS_TABSTOP,39,26,116,83

to this
CONTROL "",IDC_RICHEDIT1,"RichEdit20A" ,ES_MULTILINE | WS_BORDER |WS_TABSTOP,39,26,116,83

in order to be using version 2 of the rich text control.
(Hint use Spy++ to check the class of your rich text window).

Cheers Greg




"RichEdit20A"
0
 
LVL 3

Author Comment

by:dragosh
ID: 6885534
sorry about rejecting your answer ..

it works only with version 2 of rich text control ?
0
 
LVL 3

Author Comment

by:dragosh
ID: 6885574
hi again

in MSDN says about this .. in Rich Edit 2.0 or later - FR_DOWN etc.

i'am using CRichEditCtrl 1.0 , so that's way it doesn't work... i'll cosider to use 2.0

10x for your tips
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question