PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: FINDTEXT structure  (Read 206 times)

jermy

  • Junior Member
  • **
  • Posts: 60
FINDTEXT structure
« 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
Logged

Josť Roca

  • Guru Member
  • *****
  • Posts: 3282
Re: FINDTEXT structure
« Reply #1 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

jermy

  • Junior Member
  • **
  • Posts: 60
Re: FINDTEXT structure
« Reply #2 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
Logged

veltesian

  • Little Newbie
  • *
  • Posts: 47
Re: FINDTEXT structure
« Reply #3 on: August 15, 2020, 09:35:34 AM »

hello jermy ... so how does that richedit findtext code work ? its got me curious....
Logged