PlanetSquires Forums

Support Forums => PlanetSquires Software => Topic started by: jermy on August 14, 2020, 08:08:18 AM

Title: FINDTEXT structure
Post by: jermy on August 14, 2020, 08:08:18 AM
Dear people,

How do I get FINDTEXT structure working?
I have no idea how to declare it with freebasic.


#include Once "Afx/AfxRichEdit.inc"
#include Once "win/richedit.bi"

Function frmMain_Button1_Click( ByRef sender As wfxButton, ByRef e As EventArgs ) As LRESULT

? RichEdit_FindText( frmMain.RichEdit1.hWindow, FR_WHOLEWORD,

    Function = 0
End Function

''' ========================================================================================
''' Finds text within a rich edit control.
''' ========================================================================================
''PRIVATE FUNCTION RichEdit_FindText (BYVAL hRichEdit AS HWND, BYVAL fOptions AS DWORD, BYVAL lpft AS FINDTEXTW PTR) AS LONG
''   FUNCTION = SendMessageW(hRichEdit, EM_FINDTEXTW, fOptions, cast(LPARAM, lpft))
''END FUNCTION
''' ========================================================================================



Thanks in advance for your help
Title: Re: FINDTEXT structure
Post by: José Roca on August 14, 2020, 12:10:15 PM

DIM ftw AS FINDTEXTW
ftw.chrg.cpMin = 0
ftw.chrg.CpMax = -1
DIM wszText AS WSTRING * 260 = "<text to find>"
ftw.lpstrText = VARPTR(wszText)
? RichEdit_FindText(frmMain.RichEdit1.hWindow, FR_WHOLEWORD, @ftw)


FINDTEXTEXW structure
See: https://docs.microsoft.com/en-us/windows/win32/api/richedit/ns-richedit-findtextexw

CHARRANGE structure
See: https://docs.microsoft.com/en-us/windows/win32/api/richedit/ns-richedit-charrange
Title: Re: FINDTEXT structure
Post by: jermy on August 15, 2020, 05:14:33 AM
A small change to the code so that we leave a working example.
I forgot FR_DOWN message.


Function frmMain_Button2_Click( ByRef sender As wfxButton, ByRef e As EventArgs ) As LRESULT

DIM ftw AS FINDTEXTW
    ftw.chrg.cpMin = 0
    ftw.chrg.CpMax = -1
   
DIM wszText AS WSTRING * 260 = "<text to find>"
    ftw.lpstrText = VARPTR(wszText)
   
? RichEdit_FindText(frmMain.RichEdit1.hWindow, FR_DOWN or FR_WHOLEWORD, @ftw)

    Function = 0
End Function
Title: Re: FINDTEXT structure
Post by: veltesian on August 15, 2020, 10:05:34 AM
hello jermy ... so how does that richedit findtext code work ? its got me curious....