|
-
Aug 7th, 2001, 01:14 PM
#1
Thread Starter
PowerPoster
change the background of richedit control
Is there anyway to change the background of richedit control to a bitmap or a picture? I can't seem to find any message for changing the background to a picture but will it just change the background if I use its DC and draw the Bitmap onto it (like drawing the bitmap on window)
-
Aug 7th, 2001, 02:41 PM
#2
No, there isn't any built in method. I would just go with drawing the bitmap onto the window, or inserting an OLE object of the picture.
-
Aug 7th, 2001, 04:04 PM
#3
Thread Starter
PowerPoster
But somehow this code is not working:
Code:
hdc = BeginPaint(rtfhwnd, &ps);
memhdc = CreateCompatibleDC(hdc);
SelectObject(memhdc, hbitmap);
GetObject(hbitmap, sizeof(bm), &bm);
BitBlt(hdc, 0,0, bm.bmWidth, bm.bmHeight, memhdc, 0,0,SRCCOPY);
DeleteDC(memhdc);
EndPaint(rtfhwnd, &ps);
NOTE: It works for the main window when I put it under the windows' WM_PAINT Message.
So I think that I need to put it under the WM_PAINT Message of richedit control. And I think that I need to Subclass the richedit control in order to receive the WM_PAINT message..right? If yes, then can you please show me how to subclass the richedit control and will it send me WM_PAINT, and will I be able to paint the background using the above code if I subclass it?
Please
-
Aug 8th, 2001, 11:12 AM
#4
Add these 2 as global variables:
Code:
LRESULT CALLBACK RichEditProc(HWND, UINT, WPARAM, LPARAM);
WNDPROC wOldProc;
Add this to the WM_CREATE event.
Code:
wOldProc = (WNDPROC)SetWindowLong(hEdit, GWL_WNDPROC, (LONG) &RichEditProc);
Add this to the WM_CLOSE event.
Code:
SetWindowLong(hEdit, GWL_WNDPROC, (LONG)&wOldProc);
This will be your callback for the richedit control.
Code:
LRESULT CALLBACK RichEditProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_PAINT:
// Add code here;
default:
return CallWindowProc(wOldProc, hWnd, uMsg, wParam, lParam);
}
}
-
Aug 8th, 2001, 12:08 PM
#5
Thread Starter
PowerPoster
It tried that but it does not paint anything on the richedit box
It also gives me an access voilation error message when I try to set its procedure to default at the WM_CLOSE message
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|