News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

RichEdit Notify Q

Started by DC, February 27, 2006, 04:26:52 AM

Previous topic - Next topic

DC

this is the best I can find to do and again my code does notta:
    ...
    .elseif uMsg == WM_NOTIFY
        mov     edi, lParam
        mov     eax, hEdit
        .if [edi].MSGFILTER.nmhdr.hwndFrom == eax
            dxbp    ;   MessageBox MACRO
        .endif
    ...

I can't get any Notifications from my Rich Edit... it's working right... just no Notifies come through in my WndProc.
it was created this way:
        invoke  CreateWindowEx, 0, addr RichEditClass, 0, WS_VISIBLE or WS_CHILDWINDOW or WS_CLIPSIBLINGS or \
                ES_SUNKEN or ES_MULTILINE or WS_VSCROLL or ES_NOHIDESEL or WS_HSCROLL or WS_BORDER, \
                203, 0, rct.right, rct.bottom, hWnd, 0, hInstance, NULL

I've tried this from Icz's tut too:
.elseif uMsg==WM_NOTIFY
push esi
mov esi,lParam
assume esi:ptr NMHDR
.if [esi].code==EN_MSGFILTER
assume esi:ptr MSGFILTER
.if [esi].msg==WM_RBUTTONDOWN

nothing works... what am I doing wrong?
thanx,
DC
this isn't daja vu, I'm just learning it for the 37th time
http://www.bmath.net

Mark Jones

Hmm, interesting DC. In my Lib Search tool it processes feedback from ListView double-clicks in a very similar fashion:


    .elseif uMsg==WM_NOTIFY                         ; listview feedback
        push edi
        mov edi,lParam
        assume edi:ptr NMHDR
        mov eax,[edi].hwndFrom
        .if eax==hLV                                ; is it the listview?
            .if [edi].code==NM_DBLCLK               ; was item double-clicked?


Looking at EN_MSGFILTER in the Win32.help file it says that wParam = the edit control ID and lParam = pointer to a MSGFILTER structure. It also says "If the parent window modifies this structure and returns a nonzero value, the modified message is processed instead of the original one." That's good to know. Your latter example looks correct to me... could you stick a NOP or INT 3 in there and debug it? I like to add a NOP and load it in OllyDbg and press Ctrl+F, NOP, Enter, F2, F9. :U
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

DC

I DL'd OlyDB...
whew... got some learnin' to do...
I tried what you said... I don't know what I was lookin' for, but I don't think it happened.
I put my check for notify's right after the 'uMsg == WM_Create'...
    .elseif uMsg == WM_NOTIFY
        mov     edi, lParam
        mov     eax, hEdit
        .if [edi].NMHDR.hwndFrom == eax

shouldn't this get all notifies from the edit control?
this isn't daja vu, I'm just learning it for the 37th time
http://www.bmath.net

DC

well I got some odd results...
.if [edi].MSGFILTER.msg
gave me results for clicking in the TreeView but not the RichEdit...
are the messages getting switched?
is there a way to channel them?
help!
this isn't daja vu, I'm just learning it for the 37th time
http://www.bmath.net

Mark Jones

Hi DC, could you post the entire code please? (Or mail it to me or one of us) so we can reproduce the problem exactly? That would be a great help.

OllyDbg might seem a little intimidating at first, sorry to "unload" all that on you at once. :wink If you're interested here's a quick-start way to debug an app:

0. Recompile the code with a NOP right after the ".if [edi].MSGFILTER.msg", then load it with Olly.
1. Ctrl+F means "search for opcode." You want to search for the NOP you inserted earlier.
2. The disassembly listing should advance to a line with a NOP instruction in it.
3. Pressing F2 sets the offset (say 0040018F) as a breakpoint. The offset turns red to indicate this.
4. Pressing F9 runs the code. You'll need to click on your app window and try the control.
5. OllyDbg should popup when code execution reaches the breakpoint, then you can look at the registers and "see" what is going on there.
6. Press F8 to "single-step over" subroutines or F7 to "step into" subs. You can watch the registers & flags change as each instruction is executed. This can be immesurably helpful when tracing down obscure issues. Plus it's cool to see how the machine really works inside... even if it is a little complicated at first. :toothy

Hope that is helpful. :)
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

DC

including project... it's as a WinASM project with the trouble spot marked like this:
;===================================HERE
        szText  szMes, "EN_MSGFILTER"
        szText  szCap, "NMHDR"
        .if [edi].NMHDR.code == EN_MSGFILTER
            invoke  MessageBox, NULL, addr szMes, addr szCap, MB_OK
;===================================HERE

thanx for the tips, I did get OlyDB to mark the NOP and run but it never came to it. I have a MessageBox here that should do the same - kinda -
I will try learning OlyDB, thanx again,
DC

[attachment deleted by admin]
this isn't daja vu, I'm just learning it for the 37th time
http://www.bmath.net

zooba

Rich Edit Control Event Mask Flags

Quote from: MSDNThe default event mask is ENM_NONE in which case no notification messages are sent to the parent window. You can retrieve and set the event mask for a rich edit control by using the EM_GETEVENTMASK and EM_SETEVENTMASK messages.

Hope that helps :U

Zooba

Mark Jones

That pretty much sums it up. :)

My WinASM keeps crashing. Had that problem before, I remember now why I switched to RadASM. :toothy
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

DC

thanx guys,
I guess I should've seen that...
I'm learning where and when to look for details like this...
thanx for bearing with me, I appreciate all your help and patients.
DC
this isn't daja vu, I'm just learning it for the 37th time
http://www.bmath.net