对话框窗口不刷新,不进入OnPaint(不进WM_PAINT)

6 篇文章 0 订阅

MFC对话框程序,不知道改了什么对话框总是不刷新,后来用spy++查看,能看到窗口。
首先考虑的是,不小心加了layeredout属性,后来查看没有。
再次考虑到是不是wm_paint消息被过滤了,在PreTranslateMessage里面下断点发现是可以收到WM_PAINT消息的,后来调试跟进,发现

代码堆栈
PreTranslateMessage最后返回TRUE导致没有进入if代码块,当然不会刷新了。所以应该为如下代码:

BOOL CMFCTryDemoDlg::PreTranslateMessage(MSG* pMsg)
{
    // TODO: 在此添加专用代码和/或调用基类
    if(pMsg->message == WM_USER+100)
    {

    }
    else
        return CDialog::PreTranslateMessage(pMsg);
}

=================================================

倒是不用看msdn,不过还是看了下:

要查看本文的译文,请勾选“翻译”复选框。也可将鼠标指针移到文本上,在弹出窗口中显示译文。
翻译 英语
CWnd::PreTranslateMessage

其他版本

Used by class CWinApp to translate window messages before they are dispatched to the TranslateMessage and DispatchMessage Windows functions.
语法

  virtual BOOL PreTranslateMessage(

MSG* pMsg
);
参数
pMsg
Points to a MSG structure that contains the message to process.
返回值
Nonzero if the message was translated and should not be dispatched; 0 if the message was not translated and should be dispatched.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值