Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Can’t find text in a Rich Edit, using API

Can’t find text in a Rich Edit, using API

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++jsonquestionannouncement
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Aidman
    wrote on last edited by
    #1

    Hi, all :) I am experiencing a problem with the Rich Edit box (version 1.0) using regular Win32 API (no MFC). I am trying to write a function that will search through a specified range of content in the control (the text). I am using the SendMessage() function with the EM_FINDTEXTEX flag and the FINDTEXTEX structure. But the problem is that it can’t seem to find any matches. For ex. I have set the control with the text “is there any matches?” and I set the function to search for the word “any” but won’t find any thing. The function has been written to return the number of matches it finds, the following code is the function I have written. Can anyone please help me figure out the problem?

    int FindText(HWND hEdit, char *Text, CHARRANGE *Range) {
    FINDTEXTEX TextSearch;
    int MatchCount = 0;
    int MatchFound;

    TextSearch.chrg = \*Range;
    TextSearch.lpstrText = Text;
    TextSearch.chrgText.cpMin = -1;
    
    while (1) {
    	MatchFound = SendMessage(hEdit, EM\_FINDTEXTEX, FR\_WHOLEWORD, (LPARAM) &TextSearch);
    
    	if (TextSearch.chrgText.cpMin != -1) {
    		MatchCount++;
    		
    		if (MatchFound != -1) 
    			TextSearch.chrg.cpMin = MatchFound;
    		else break;
    	} else break;
    }
    
    return MatchCount;
    

    }

    Aidman » over and out We haven't inherited Earth from our parents, instead we have borrowed her from our children; an old Indian saying.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups