News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

How to use "CN_TEXTCHANGED" on richedit(X64)

Started by six_L, August 24, 2022, 01:23:05 AM

Previous topic - Next topic

six_L

Hi,all
_NMHDR STRUCT
hwndFrom QWORD ?
idFrom DWORD ?
code DWORD ?
_NMHDR ENDS

CHANGENOTIFY STRUCT
dwChangeType DWORD ?
pvCookieData QWORD ?
CHANGENOTIFY ENDS

EN_SELCHANGE equ < 00702h>

EM_SETEVENTMASK equ < WM_USER + 69>
ENM_CHANGE equ < 000000001h>
ENM_SELCHANGE equ < 000080000h>

CN_GENERIC EQU <0 > ; Nothing special happened
CN_TEXTCHANGED EQU <1 > ; the text changed
CN_NEWUNDO EQU <2 > ; A new undo action was added
CN_NEWREDO EQU <4 > ; A new redo action was added

szDllEdit db "RichEd20.dll",0
szClassEdit db "RichEdit20A",0

.if eax==WM_INITDIALOG

invoke CreateWindowEx,WS_EX_CLIENTEDGE,offset szClassEdit,NULL,\
ES_LEFT + ES_AUTOHSCROLL + WS_VISIBLE + WS_CHILD,8,223,267,21,\
hWnd,IDC_EDIT2,hInstance,NULL
mov hEdit2,rax
invoke  CreateFont,8,0,0,0,0,FALSE,FALSE,FALSE, \
DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, \
DEFAULT_QUALITY,FIXED_PITCH, CStr("MS Sans Serif")
mov hFont, rax
invoke SendMessage,hEdit2,WM_SETFONT,rax, 0
invoke CloseHandle,hFont
invoke SendMessage,hEdit2,EM_SETEVENTMASK,0,ENM_CHANGE + ENM_SELCHANGE

.elseif eax==WM_NOTIFY
mov @rbx,rbx
mov rbx,lParam
mov eax, (_NMHDR PTR [rbx]).code

mov ecx, (_NMHDR PTR [rbx]).idFrom
mov rdx, (_NMHDR PTR [rbx]).hwndFrom
mov rbx,@rbx

invoke LoadLibrary,CStr("RichEd20.dll")
mov hRichEdit,rax
invoke DialogBoxParam,hInstance,IDD_DIALOG,0,addr DlgProc,0
invoke FreeLibrary,hRichEdit
...
Say you, Say me, Say the codes together for ever.

jj2007

CASE WM_COMMAND ; specific WM_COMMAND messages (trackpopup menus?)
movzx eax, word ptr wParam+2
switch eax ; the WM_COMMAND message
case EN_CHANGE
... do what it needs to react to changed text ...

six_L

#2
Hi,jj2007
thanks your help.

According to MSDN description:
QuoteEN_CHANGE (rich edit) notification code

Notifies a windowless rich edit control's host window that a change has occurred.
A rich edit control sends this notification code in the form of a WM_NOTIFY message.

    penChangeNotify = (CHANGENOTIFY *) lParam;
i tested the following codes, it can't work.
.if eax==WM_INITDIALOG

invoke CreateWindowEx,WS_EX_CLIENTEDGE,CStr("RichEdit20A"),NULL,\
ES_LEFT + ES_AUTOHSCROLL + WS_VISIBLE + WS_CHILD,8,23,267,21,\
hWnd,IDC_RICHEDIT,hInstance,NULL
mov hRichEdit,rax

invoke  CreateFont,8,0,0,0,0,FALSE,FALSE,FALSE, \
DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, \
DEFAULT_QUALITY,FIXED_PITCH, CStr("MS Sans Serif")
mov hFont, rax
invoke SendMessage,hRichEdit,WM_SETFONT,rax, 0
invoke CloseHandle,hFont
invoke SendMessage,hRichEdit,EM_SETEVENTMASK,0,ENM_CHANGE


.elseif eax==WM_NOTIFY
mov rax,wParam
.if ax == EN_CHANGE
mov r8,lParam
mov ecx, (CHANGENOTIFY PTR [r8]).dwChangeType
.if ecx==CN_TEXTCHANGED
...
.elseif ecx==CN_NEWREDO
...
.elseif ecx==CN_NEWUNDO
...
.endif
.endif

.elseif eax==WM_COMMAND
mov rax,wParam
.if ax == EN_CHANGE
mov r8,lParam
mov ecx, (CHANGENOTIFY PTR [r8]).dwChangeType
.if ecx==CN_TEXTCHANGED
...
.elseif ecx==CN_NEWREDO
...
.elseif ecx==CN_NEWUNDO
...
.endif
.endif

i searched the github.com, found the most valuable code. but i don't know how translate it into ASM.
virtual HRESULT TxNotify(DWORD iNotify, void *pv)
{
switch (iNotify)
{
case EN_CHANGE:
{
if (!pv) break;
CHANGENOTIFY * penChangeNotify = (CHANGENOTIFY*)pv;
if (penChangeNotify->dwChangeType != CN_TEXTCHANGED)
break;
if (m_bSetText)
break;

GETTEXTLENGTHEX textLenEx;
textLenEx.flags = GTL_DEFAULT;
textLenEx.codepage = 1200;
LRESULT lResult;
GetTextServices()->TxSendMessage(EM_GETTEXTLENGTHEX, (WPARAM)&textLenEx, 0, &lResult);
m_pOwner->SendNotify(UINOTIFY_EN_CHANGE, (WPARAM)lResult);
return S_OK;
}
break;
}
return __super::TxNotify(iNotify, pv);
}

Say you, Say me, Say the codes together for ever.