i was working on a project a little while back trying to syncronize two richedit controls. my goal was to syncronize every possible way that the controls could be vertically scrolled. now i have been able to do this for the most part except one problem. when i drag and drop the thumb in the scrollbar im not able to process it right. here is the code and hopefully someone can help solve my problem:

*to test it, load the same file into both controls and they need to be long enough to make the vertical scrollbars display*

*also most richedit notification messages can be processed by subclassing. there are some messages that you can have processed by your window procedure but you must set the correct parameters when you send the EM_SETEVENTMASK message*
Posted on 2002-02-25 11:59:31 by smurf
You can use this in addition to what you already had:

NewRichEditProc PROC xRichEdit:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD

invoke CallWindowProc,OldRichEditProc,xRichEdit,uMsg,wParam,lParam
mov edx, hRichEdit
mov ecx, uMsg
.IF xRichEdit==edx && (ecx==WM_HSCROLL || ecx==WM_VSCROLL)
push eax

invoke SendMessage,edx, EM_GETSCROLLPOS,0,addr vPos
invoke SendMessage,hRichEdit1,EM_SETSCROLLPOS,0,addr vPos
pop eax
NewRichEditProc endp

Posted on 2002-02-25 12:16:14 by Thomas
thomas i had tried virtually the same code as you have posted. my problem was that i was putting the callwindowproc right after i processed the wm_vscroll notification message.

my method some what works but the syncronization is off. i was wondering why your method works and mine doesnt. i have always subclassed the same why as i have described above.

im definetly going to read up some more on subclassing so i dont run into a problem like this again.
Posted on 2002-02-25 13:24:46 by smurf
Are you sure you did it exactly the same way I did? I don't actually *handle* any messages for the richedit, I let the old wndproc do that. I only use it as notification. As soon as WM_H/VSCROLL is handled by the rich edit, I update the second richedit.
However that doesn't handle some scroll functions most mice have so your code is still necessary.

Posted on 2002-02-25 13:30:57 by Thomas
just to show you what i had:
NewRichEditProc PROC xRichEdit:DWORD,uMsg:DWORD,wParam:DWORD, lParam:DWORD

invoke SendMessage,hRichEdit, EM_GETSCROLLPOS, 0, addr vPos
invoke SendMessage,hRichEdit1,EM_SETSCROLLPOS, 0, addr vPos

invoke CallWindowProc,OldRichEditProc,xRichEdit, uMsg, wParam, lParam
NewRichEditProc endp

thank you very much for the help.:alright:
Posted on 2002-02-25 13:53:20 by smurf
This is an interesting problem. How might I do several sincronized columns next to the text in a riched, without writing a custom control? I need to do this for my assembler.
Posted on 2002-02-25 14:05:30 by bitRAKE
"Your Assembler"? What assembler is this? :)
Posted on 2002-02-25 14:07:45 by stryker
I've been working on a modern assembler for some time -
in fact it's my main project. It assembles as you type,
and should provide information like a debugger: register/flag
states, instruction pairing, cache usage, instruction latency,
etc... It's a long way off still, but I have a dream...
Posted on 2002-02-25 14:22:11 by bitRAKE
ooo, sounds like BASIC. I'm sure this is your "generalized" assembler that can assemble across different processor architecture. Cool :cool: Code On With The Power Of the MACROS :) Nice Idea though, never thought of that one.
Posted on 2002-02-25 14:25:05 by stryker
BitRAKE: What kind of columns? You mean for showing the number of clocks an instruction takes etc? What controls do you want to use?
Posted on 2002-02-25 14:25:16 by Thomas
The columns only need to line up to the text in the riched,
they don't need to be editable. I would like to provide colored
flags to mark not-so-good code sequences, code flow, etc...

Posted on 2002-02-25 14:37:05 by bitRAKE
If you can get the lineheight in the richedit and use the same in the other controls, you should be able to use the same scroll values for the rich edit and the other controls.
You probably need this anyway because otherwise the comments wouldn't be aligned with the code properly..
Maybe you'll need some hittest and posfromchar functions/messages to scroll synchronously.

Posted on 2002-02-25 14:41:40 by Thomas
Thanks, Thomas. Sounds a little tricky? :eek:
Posted on 2002-02-25 14:52:25 by bitRAKE
It depends on the controls you are using. If you can get the height of one line in a richedit, you can set the item height of a combobox to the same height with CB_SETITEMHEIGHT.. There are probably similair messages for other controls.

Posted on 2002-02-25 14:59:01 by Thomas