Howdy, guys. I hope someone can help me with this problem. I have subclassed a rich edit control (v 1) in order to fiddle with the way it paints on WM_PAINT. However, something is going awry when I try to coax the edit control to paint into a memory DC instead of its normal one. Sniffing around the net turned up many examples of subclassing other common controls and taking over the paint message, but the method they all use involves doing this: invoke DefWindowProc,hwndEdit,WM_PAINT,memDC,0 The above doesn't work at all in my code. I did manage to get it work partially by using WM_PRINT and changing lParam from zero to PRF_CLIENT. Then the code painted . . . in an area about the size of a postage stamp, leaving the rest of the edit control's client area a pristine and frustrating white. Also, the caret is gone. I switched to richedit20 in hopes that it was a quirk in the first version; now the caret is visible, but the stamp-sized area that was getting painted has disappeared. Let's see, what other details can I give you? The small area that did paint using richedit32 (v1) was in the upper left hand corner of the control. I have checked to be sure the proper dimensions are passed to bitblt (they are). The relevant source code is pasted in below. The 'wcall' scattered through the code you can read as 'invoke'. It's just a macro. (edits done while fooling around with the code formatting; sorry about that). Thanks, bitnaut Source to the subclass proc:

EditWndProc proc hEdit:DWORD, uMsg:DWORD, wParam:DWORD,  lParam:DWORD
   .if uMsg==WM_ERASEBKGND
      return 1
   .elseif uMsg == WM_PAINT
      wcall BeginPaint,hEdit,offset ps
      mov reDC,eax

      wcall CreateCompatibleDC,reDC
      mov memDC,eax

      wcall CreateCompatibleBitmap, reDC,ps.rcPaint.right, ps.rcPaint.bottom
      mov htempBMP,eax

      wcall SelectObject,memDC,htempBMP
      mov hOldBMP,eax

      wcall FillRect,memDC,offset ps.rcPaint,REBACKCOLOR
;        debugmsg "right=%d bottom=%d", ;ps.rcPaint.right,ps.rcPaint.bottom


      wcall BitBlt, reDC, 0, 0,ps.rcPaint.right,ps.rcPaint.bottom, memDC,0,0,SRCCOPY

      wcall SelectObject,memDC,hOldBMP
      wcall DeleteObject,htempBMP
      wcall DeleteDC,memDC

      wcall EndPaint,hEdit,offset ps


   wcall CallWindowProc,OldWndProc,hEdit,uMsg,wParam,lParam
EditWndProc endp
This message was edited by bitnaut, on 2/1/2001 11:24:13 PM
Posted on 2001-01-31 11:12:00 by bitnaut
I found the solution. Put a call to the OldWndProc after EndPaint in the WM_PAINT handler to let the RE control do whatever else it needs to do. The client area has been validated already, so it doesn't try to overwrite my custom paint job, but it does take care of whatever was getting out of whack before. Also, I changed the returnzero statement (macro) to 'ret' to let the oldWndProc eax value get returned. Thanks anyway, guys. bitnaut This message was edited by bitnaut, on 2/3/2001 9:47:29 PM
Posted on 2001-02-03 21:46:00 by bitnaut
Duh. I only just noticed that if I had deleted the stupid 'returnzero' in the first place, everything would have worked without any extra call to oldWndProc. Finally through, bitnaut
Posted on 2001-02-03 21:52:00 by bitnaut