zoukankan      html  css  js  c++  java
  • MFC CDialog/CDialogEx DoModal ALT

    Questions:

    I'm using MFC CDialog/CDialogEx to show a modal dialog with DoModal.
    usually it works without problems, but sometimes, the dialog wont show up until I press ALT key.

    the scenarios is, I have a timer in the parent window, and doing some work in the OnTimer function, if the work takes too much time, say, longer than the timer interval, then DoModal wont show the dialog window, until ALT key pressed.

    I've traced the problem into CWnd::RunModalLoop() function in wincore.cpp
    apparently it can only call ShowWindow() when the message loop is empty,
    or, a message 0x118 (WM_SYSTIMER) or WM_SYSKEYDOWN (ALT key) is received.
    since my parent window is always busy processing WM_TIMER message, the message queue will never be empty, it will never call ShowWindow() to display the dialog window, until I press ALT key.

    I think is behaviour is unexpected.

    Answers:

    Hello,

    Thanks again for the report. We have investigated this issue and we feel that it is by design. All time-consuming operations should be placed in separate (working) threads and then pass progress info to the main GUI thread. This MSDN topic has more information: 
    http://msdn.microsoft.com/en-us/library/windows/desktop/dd744765(v=vs.85).aspx

    I hope this helps.

    Pat Brenner
    Visual C++ Libraries Development

    Solutions:

    call CWnd::PostMessage(0x118) before DoModal();

  • 相关阅读:
    calcite 概念和架构
    在vscode中快速生成vue模板
    curl发送post请求
    【vue】chrome已安装Vue Devtools在控制台却无显示
    java(第一天)
    小游戏之莫交叉
    再谈成麻结账程序2.0
    成麻结账程序
    倍福Twincat2 常用快捷键及部分注意事项
    IP地址,子网掩码、默认网关,DNS服务器之间的联系与区别
  • 原文地址:https://www.cnblogs.com/xingrun/p/3577401.html
Copyright © 2011-2022 走看看