I have tried lines like:
Code: Select all
SendMessage(editor.RichEdit1.hWindow, EM_GETCHARFORMAT, SCF_SELECTION, cast(lparam, @Rformato))
RichEdit_GetCharFormat( editor.RichEdit1.hWindow, SCF_SELECTION, @Rformato )
I had checked in win32 threads related to the EM_GETCHARFORMAT message and this seems to be the right method.
Here is the code i`m using for the function: (most of it is to see where the problem is)
Code: Select all
Function Editor_BEstado_Click( ByRef sender As wfxButton, ByRef e As EventArgs ) As LRESULT
Rem >>Declarations for the format structure<<
Dim As Longint Resultado
dim as string StrdwMask
Dim as string StrdwEffects
dim as string MsgResultado
dim as CHARFORMATW Rformato
Rem >>Verifying test to make sure the text was actually selected<<
If RichEdit_GetSelText(editor.RichEdit1.hWindow) = 0 then Afxmsg("No hay texto seleccionado", "Texto seleccionado")
if RichEdit_GetSelText(editor.RichEdit1.hWindow) > 0 then Afxmsg("Texto seleccionado: " + RichEdit_GetSelText(editor.RichEdit1.hWindow), "Texto seleccionado")
Rem >>Clear and define values for Rformato<<
Rformato.cbSize = SizeOf(Rformato)
' ZeroMemory(@Rformato, SizeOf(Rformato))
RtlZeroMemory(@Rformato, SizeOf(Rformato))
Rem >>Get the format of the selected text<<
' (Here is where seems to be a problem, since EM_GETCHARFORMAT or RichEdit_GetCharFormat calls both fail to transfer the format to Rformato, using CHARFORMATW, CHARFORMAT, or CHARFORMATW2 structures)
Resultado = RichEdit_GetCharFormat(editor.RichEdit1.hWindow, SCF_SELECTION, @Rformato)
' Resultado = SendMessage(editor.RichEdit1.hWindow, EM_GETCHARFORMAT, SCF_SELECTION, cast(lparam, VarPtr(Rformato)))
Rem >>Define the monitoring message<< (Test that indicates if the RichEdit_GetCharFormat call was successful)
If Resultado = 0 Then MsgResultado = "1- RichEdit_GetCharFormat No se ejecuto correctamente"
If Resultado = 1 Then MsgResultado = "1- RichEdit_GetCharFormat se ejecuto correctamente"
If Rformato.dwEffects = CFM_BOLD Then
StrdwMask = "2- Rformato.dwMask = CFM_BOLD"
StrdwEffects = "3- Rformato.dwEffects = CFM_BOLD"
MessageBox(0, MsgResultado + !"\n" + StrdwMask + !"\n" + StrdwEffects + !"\n" + "4- Texto en negritas", "Estado", MB_OK)
elseif Rformato.dwEffects = null then
StrdwMask = "2- Rformato.dwMask = Null"
StrdwEffects = "3- Rformato.dwEffects = Null"
MessageBox(0, MsgResultado + !"\n" + StrdwMask + !"\n" + StrdwEffects + !"\n" + "4- Texto normal", "Estado", MB_OK)
end if
Function = 0
End Function
Any ideas about what's happening?