You use the CallWindowProc function to call the old window procedure. This function should usually be called instead of DefWindowProc. The first argument, lpPrevWndFunc, should be the value returned by SetWindowLongPtr. Your window procedure should look something like this:
LRESULT CALLBACK WndProc( ... )
// do your stuff here...
return CallWindowProc(oldWindowProc, hwnd, uMsg, lParam, wParam);
Ok, now i got another problem.
The thing you told anonytmouse works.
But now i must use WM_PAINT message. If i do things there, then other WM_PAINT isn't executed.
Where can i find the source of handling WM_PAINT for a RichEdit. I'm just gonna copy the source,
and modify it a little bit... ( So that i Select my HBRUSH )
, WM_ERASEBKGND works only when i select text in RichEdit. And still The BkMode is set to OPAQUE,
that's why i'm going to play with WM_PAINT.
I don't wanna search all the windows headers. Does someone knows where the WM_PAINT message
for RichEdit is defined?
I have somekind of thing that points to WndProc, but i don't know how could that be helpfull...
Windows is not open-source. The code for WM_PAINT for a rich-edit is not available. You can try calling the old window procedure before or after your extra processing but I'm not optimistic this will work. Even if you get it working on your platform, you should consider that the rich-edit implementation may be different on other platforms.
I did a search and apparently rich-edit versions 2 and greater (make sure you are loading the correct DLL) support the WS_EX_TRANSPARENT extended style. You would use this style and display your background image in a control behind the rich-edit control.
There is also windowless rich-edit controls, although this would be far more complex to use.
Heres how my code looks like right now:
- First i tryed to put WS_EX_TRANSPARENT, with other styles (WS_BORDER | WS_VSCROLL), but then i got
CreateWindowEx(WS_EX_TRANSPARENT, RICHEDIT_CLASS, NULL,
WS_CHILD | ES_MULTILINE | WS_BORDER | WS_VSCROLL,
10, 10, 500, 400,
hWindow, (HMENU)(400), hinstance, NULL);
RichEdit, which displays my text with "*", like a password field.
- Then i moved the style above, like you can see in the code. Now it looked like it worked. But heres
I put my drawing in WM_ERASEBKGND ( a single BitBlt ) In my window there is nothing but RichEdit.
Problems that occured:
- only current line of text is visible when i type text
- the background isn't updated when i type so i got |||||| on the buffer ( | - typing cursor )
- the background is updated only when i select text. and only current line. - wierd
- The arrows of my scrollbar aren't displayed.
- when i select text the text goes behind my bitmap, this works if i select multiple rows.
It seems that i will never finish this...
also i did this
You will need to subclass the WM_CHAR message of the rich-edit and invalidate the parent window so that the background is repainted each time a character is received. There is an example here:
Making a RichEdit see through
I quit this. It isn't worth all the trouble. I could easyer create my own RichEdit...
Thanks for help everyone, especialy anonytmouse & Ken Fitlike.