PlanetSquires Forums

Support Forums => WinFBE - Code Editor and Visual Designer => Topic started by: jermy on August 14, 2020, 07:38:18 AM

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

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

Code: [Select]
#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, 11:40:15 AM
Code: [Select]
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, 04:44:33 AM
A small change to the code so that we leave a working example.
I forgot FR_DOWN message.

Code: [Select]
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, 09:35:34 AM
hello jermy ... so how does that richedit findtext code work ? its got me curious....