• Welcome to PlanetSquires Forums.
 

RichEdit_SetCharFormat (DWORD parameter)

Started by Paul Squires, March 09, 2023, 01:44:12 PM

Previous topic - Next topic

Paul Squires

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
' ========================================================================================
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

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
' ========================================================================================


Paul Squires

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))

Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca


Paul Squires

Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer