在OnPaint中必须调用一次BeginPaint和EndPaint,且也只能调用一次。(上)
来源:互联网 发布:淘宝斯沃琪旗舰店 编辑:程序博客网 时间:2024/05/16 10:29
基于对话框的程序(mfc默认生成),重载OnEraseBkgnd函数,其它不动,若在OnPaint函数中不调用其基类的OnPaint函数,即注释掉CDialog::OnPaint();,代码如下:
void CDDDDlg::OnPaint(){if (IsIconic()){CPaintDC dc(this); // device context for paintingSendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);// Center icon in client rectangleint cxIcon = GetSystemMetrics(SM_CXICON);int cyIcon = GetSystemMetrics(SM_CYICON);CRect rect;GetClientRect(&rect);int x = (rect.Width() - cxIcon + 1) / 2;int y = (rect.Height() - cyIcon + 1) / 2;// Draw the icondc.DrawIcon(x, y, m_hIcon);}else{//CDialog::OnPaint();}}
则执行后界面没有问题,如下图:
但是,如果将此界面隐藏后再显示,则上面的控件都不能显示了,如下图:
跟踪程序会发现,第一次生成界面时候,进入过OnCtlColor函数(TRACE("OnCtlColor\n");语句输出),
当隐藏界面再显示后,就再也没进过OnCtlColor函数。当然看不见原先界面的控件了,因为根本没有重绘出来。原因见下篇
- 在OnPaint中必须调用一次BeginPaint和EndPaint,且也只能调用一次。(上)
- 在OnPaint中必须调用一次BeginPaint和EndPaint,且也只能调用一次。(上)
- 在OnPaint中必须调用一次BeginPaint和EndPaint,且也只能调用一次。(下)
- 在OnPaint中必须调用一次BeginPaint和EndPaint,且也只能调用一次
- 在OnPaint中必须调用一次BeginPaint和EndPaint,且也只能调用一次。(下)
- 在OnPaint中必须调用一次BeginPaint和EndPaint,且也只能调用一次
- ServletRequest中getReader()和getInputStream()只能调用一次的解决办法
- rs.next() 只能调用一次
- BeginPaint() 和EndPaint() 比较
- BeginPaint和EndPaint函数
- 20120821-BeginPaint()和EndPaint()
- BeginPaint和EndPaint函数
- OkHttp中 response.body().string()只能调用一次分析~~~
- ServletRequest中getReader()和getInputStream()只能调用一次的解决办法-续网友
- 解决bootstrap-table只能被调用一次
- (16)BeginPaint和EndPaint函数
- BeginPaint和EndPaint处理WM_PAINT
- BeginPaint和EndPaint函数用法
- 《产品经理手册》 读书笔记
- 关于按钮“按下”效果的两种实现
- lancidie的博客
- ubuntu11.10下配置adsl上网
- 木木的常用软件点评(1)------系统必备软件篇
- 在OnPaint中必须调用一次BeginPaint和EndPaint,且也只能调用一次。(上)
- google ip
- hdu2222——Keywords Search//AC 自动机
- rxtx封装成bundle形式
- 如果你的键盘也没有大小写和数字指示灯
- MASM32学习日志,常用宏
- 电子时钟(51单片机定时器,1602液晶)
- python中使用mysql
- 会咬人的蚊子都是雌性的吗?