Theos PowerBasic Museum 2017

Webmaster: José Roca (PBWIN 10+/PBCC 6+) (SDK Forum) => Discussion => Topic started by: Gerald Clark on February 17, 2012, 04:10:14 PM

Title: Rich Edit Control
Post by: Gerald Clark on February 17, 2012, 04:10:14 PM
Greetings All,

I'm frustrated with this control. I just can't get this thing to find text even though I see the text I'm searching for in the text area. It's just not doing what I think the docs are saying it does. Here is the code. Maybe someone with more experience concerning windows can see the obvious error. (It always seems to be obvious when you finally see the mistake.)

Sub Find_RtfText(byval hRichEdit as dword, byval sTxt as string)

    LOCAL ftxt AS FINDTEXTEXA
    local lResult&

'Notes   
'    FINDTEXTEXA Fields
'        CHARRANGE chrg;      -- range to search (The range includes everything if cpMin is 0 and cpMax is -1.)
'        LPSTR lpstrText;     -- null-terminated string to find
'        CHARRANGE chrgText;  -- range in which text is found (If the search operation finds a match, the chrgText member of the FINDTEXTEX
                               'structure returns the range of characters that contain the matching text.   
   
    ftxt.chrg.cpMin = 0
    ftxt.chrg.cpMax = -1   
    ftxt.lpstrText = strPTR(sTxt)
   
    '---The return value specifies the zero-based character index of the character nearest the specified point.
    'lResult = RichEdit_FindTextEx( hRichEdit, %FR_MATCHDIAC, ftxt)  '---This doesn't work 
   
   
    SendMessage(hRichEdit, %EM_FINDTEXTEX, %FR_MATCHDIAC, VARPTR(ftxt)) '---This doesn't work   
   
    msgbox "ftxt.chrgText.cpMin = " + str$(ftxt.chrgText.cpMin) + " ftxt.chrgText.cpMax = " + Str$(ftxt.chrgText.cpMax)

   '---cpMin and cpMax are both -1 even though the search string text is in the control

End Sub


I searched the forums but couldn't find the answer. I tried many different things but it just doesn't work. Any help will be appreciated.

Best Regards...
Title: Re: Rich Edit Control
Post by: Gerald Clark on February 17, 2012, 06:55:33 PM
Hi Jim,

Thanks for the input. Yes, I'm aware of the thread. I started it. I guess same people uses both forums. Guess I only need to post it on one or the other.

Best Regards