MFC Redrawwindow如何只重绘部分区域

wxf54318 2014-08-08 09:24:16
我在对话框程序中放了一个PICTURE控件,
在对话框的onpaint中加入如下代码
pWnd = GetDlgItem(IDC_PIC)
Client dc(pWnd);
.dc.Eillipse(..)画圆
我想在圆里画一些矩形色块,可是只能显示一个,之前的都被擦除了,而且好像整个对话框都被刷新了,
不是只刷新PICTURE控件请问
各位大人如何实现啊,最好能提供点例程。

我想实现下面这个效果

...全文
438 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
wxf54318 2014-08-18
  • 打赏
  • 举报
回复
还是没有解决,我用redrawwindow(&rect,NULL,erase|update|invalide);以前画的还是被擦除了
wxf54318 2014-08-14
  • 打赏
  • 举报
回复
大神,能给段示例程序吗
赵4老师 2014-08-13
  • 打赏
  • 举报
回复
CWnd::InvalidateRect void InvalidateRect( LPCRECT lpRect, BOOL bErase = TRUE ); Parameters lpRect Points to a CRect object or a RECT structure that contains the rectangle (in client coordinates) to be added to the update region. If lpRect is NULL, the entire client area is added to the region. bErase Specifies whether the background within the update region is to be erased. Remarks Invalidates the client area within the given rectangle by adding that rectangle to the CWnd update region. The invalidated rectangle, along with all other areas in the update region, is marked for painting when the next WM_PAINT message is sent. The invalidated areas accumulate in the update region until the region is processed when the next WM_PAINT call occurs, or until the region is validated by the ValidateRect or ValidateRgn member function. The bErase parameter specifies whether the background within the update area is to be erased when the update region is processed. If bErase is TRUE, the background is erased when the BeginPaint member function is called; if bErase is FALSE, the background remains unchanged. If bErase is TRUE for any part of the update region, the background in the entire region is erased, not just in the given part. Windows sends a WM_PAINT message whenever the CWnd update region is not empty and there are no other messages in the application queue for that window. CWnd Overview | Class Members | Hierarchy Chart See Also CWnd::BeginPaint, CWnd::ValidateRect, CWnd::ValidateRgn,::InvalidateRect
wxf54318 2014-08-13
  • 打赏
  • 举报
回复
引用 5 楼 tixisong 的回复:
自己要把绘制的东西保存起来,然后在onpaint里一起再重绘
这样是可以实现的,我以前就是这样实现的,但是能不能不擦除以前的,只绘制现在要绘制的部分
tixisong 2014-08-13
  • 打赏
  • 举报
回复
自己要把绘制的东西保存起来,然后在onpaint里一起再重绘
wxf54318 2014-08-13
  • 打赏
  • 举报
回复
还是没有解决,,用了redrawwindow指定rect和rgn都无效,肯能是我用的不对,请各位大神指教,最好上段代码
wxf54318 2014-08-11
  • 打赏
  • 举报
回复
引用 2 楼 Bokutake 的回复:
建议你派生一个CStatic(Picture控件其实是带有SS_BITMAP风格的CStatic)。 重写OnEraseBkgnd(CDC* pDC);函数,return FALSE;它就不会用背景色重绘了。 不过建议你最好还是先绘制到一个CMemDC里(VS2008SP1以后的版本都有),可以减轻闪烁。
请问有没有更简单的方法,我不是让它每次都不擦除,而是我可以控制什么地方擦除
辰岡墨竹 2014-08-09
  • 打赏
  • 举报
回复
建议你派生一个CStatic(Picture控件其实是带有SS_BITMAP风格的CStatic)。 重写OnEraseBkgnd(CDC* pDC);函数,return FALSE;它就不会用背景色重绘了。 不过建议你最好还是先绘制到一个CMemDC里(VS2008SP1以后的版本都有),可以减轻闪烁。
wxf54318 2014-08-09
  • 打赏
  • 举报
回复
请各位大虾指导下怎么设置重绘区域,是用RGN吗

24,860

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧