question

ZoltnHegeds-7054 avatar image
0 Votes"
ZoltnHegeds-7054 asked JeanineZhang-MSFT answered

Setting background color of CScrollView

My English is not perfect, sorry.

I am using Visual C++ 2019 16.9.2 Community, and MFC.
I have an MDI program:

class CIDEView: public CScrollView

At OnEraseBkgnd, I called FillOutSideRect. This paints not the whole window, only what is out of the content to scroll: top lelt corner remains white. So, in OnDraw, I must paint this. This is time: painted with white, after it, painted with dark blue (0x800000). I want to spare the time. How can I set the (default) background color of the window? I analyzed CREATESTRUCT, but I did not find this. Thank you.

c++
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JeanineZhang-MSFT avatar image
1 Vote"
JeanineZhang-MSFT answered

Hi,

At OnEraseBkgnd, I called FillOutSideRect. This paints not the whole window, only what is out of the content to scroll

If you want to set background color of CScrollView, you need to redraw CScrollView. You could draw the background in its OnEraseBkgnd, and you should return TRUE from that to suppress the default erase and then draw the background as part of OnDraw.

For more details I suggest you could refer to the Doc: CWnd :: OnEraseBkgnd

Best Regards,

Jeanine



If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.