PlanetSquires Forums

Support Forums => WinFBX - Windows Framework for FreeBASIC => Topic started by: Paul Squires on March 09, 2023, 01:44:12 PM

Title: RichEdit_SetCharFormat (DWORD parameter)
Post by: Paul Squires on March 09, 2023, 01:44:12 PM
Hi José,

Looks like you may have missed changing the DWORD in the following function in AfxRichEdit.inc

Might want to change it to "BYVAL lpcf AS CHARFORMATW PTR" and then "cast(LPARAM, lpcf)" for the LPARAM in the in the SendMessage.

' ========================================================================================
' Sets character formatting in a rich edit control.
' ========================================================================================
PRIVATE FUNCTION RichEdit_SetCharFormat (BYVAL hRichEdit AS HWND, BYVAL chfmt AS DWORD, BYVAL pchfmt AS DWORD) AS LONG
   FUNCTION = SendMessageW(hRichEdit, EM_SETCHARFORMAT, chfmt, pchfmt)
END FUNCTION
' ========================================================================================
Title: Re: RichEdit_SetCharFormat (DWORD parameter)
Post by: José Roca on March 09, 2023, 04:19:31 PM
Right you are. I have modified it to:

' ========================================================================================
' Sets character formatting in a rich edit control.
' ========================================================================================
PRIVATE FUNCTION RichEdit_SetCharFormat (BYVAL hRichEdit AS HWND, BYVAL chfmt AS DWORD, BYVAL lpcf AS CHARFORMATW PTR) AS LONG
   FUNCTION = SendMessageW(hRichEdit, EM_SETCHARFORMAT, chfmt, lpcf)
END FUNCTION
' ========================================================================================

Title: Re: RichEdit_SetCharFormat (DWORD parameter)
Post by: Paul Squires on March 18, 2023, 06:29:24 AM
Thanks José,

When I used your new files and compiled the WinFBE Editor source code, this RichEdit_SetCharFormat function throws a "pointer passed as scalar" warning, so you might want to update the code to do the cast.

FUNCTION = SendMessageW(hRichEdit, EM_SETCHARFORMAT, chfmt, Cast(LPARAM, lpcf))

Title: Re: RichEdit_SetCharFormat (DWORD parameter)
Post by: José Roca on March 18, 2023, 11:14:39 AM
Done.
Title: Re: RichEdit_SetCharFormat (DWORD parameter)
Post by: Paul Squires on March 18, 2023, 12:34:46 PM
Thanks José appreciate it