Results 1 to 5 of 5

Thread: change the background of richedit control

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    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)
    Baaaaaaaaah

  2. #2
    Megatron
    Guest
    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.

  3. #3

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    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
    Baaaaaaaaah

  4. #4
    Megatron
    Guest
    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);
    	}
    }

  5. #5

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    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
    Baaaaaaaaah

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width