我已经在对话框类中添加了一个OnPaint()函数,但是在dlg.DoModal()之后它没有被调用 [英] I have added an OnPaint() function to my dialog class but its not getting called after dlg.DoModal()

查看:154
本文介绍了我已经在对话框类中添加了一个OnPaint()函数,但是在dlg.DoModal()之后它没有被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助我了解如何为从CDialog派生的对话框类重写OnPaint().

Can anyone please help me understand how to override OnPaint() for a dialog class derived from CDialog.

这是代码:

ColorImageDlg *pDlg = NULL;
pDlg = new ColorImageDlg;
pDlg->DoModal();
delete pDlg;

我覆盖了OnInitDialog(),并且它被调用了. 但是在覆盖OnPaint()时并没有被调用.

I'm overriding OnInitDialog() and it's getting called. But while overriding OnPaint() it is not getting called.

有人可以帮我修复它吗?

Can any one please help me fixing it?

推荐答案

首先在堆上创建对话框实例的目的是什么?您可以轻松做到:

First of all what is the point of creating the instance of the dialog on heap? You can simply do:

ColorImageDlg dlg;
dlg.DoModal(); 

您需要像这样修改您的消息映射:

You need to modify your message map like this:

BEGIN_MESSAGE_MAP(ColorImageDlg, CDialog)
    ON_WM_PAINT()
END_MESSAGE_MAP()

使用 VS类向导来避免此类问题.

这篇关于我已经在对话框类中添加了一个OnPaint()函数,但是在dlg.DoModal()之后它没有被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆