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();

MFC CDialog/CDialogEx DoModal ALT的更多相关文章

  1. MFC Initinstance中DoModal()返回-1

    新建一个基于对话框的MFC应用程序,在App的Initinstance中调用对话框DoModal()来显示对话框,这是框架的内容,应用程序框架生成的全部是正常的. 当把我对话框的资源文件提取到一个资源 ...

  2. MFC无法使用CDialogEx类

    在stdafx.h中添加以下代码: #include <afxcontrolbars.h>

  3. CDialog与CDialogEx的区别联系

    CDialogEx是VS2003之后出现的,VC++6.0没有.CDialogEx = CDialog ExtendExtend的意思是扩展,即扩展的CDialog! 这个类是CDialog的扩展类, ...

  4. DoModal时带出次级窗口闪现

    最近在做MFC 界面开发. 在一个CDialog窗口DoModal模态显示时, 会将次级窗口带出闪现(比如将一个窗口active, 然后点击我现在程序需要弹框的按钮,弹出弹出正常,但原来active的 ...

  5. MFC笔记5

    1.MessageBox()             引用自(http://www.douban.com/note/40199603/) 一 函数原型及参数 function MessageBox(h ...

  6. VC++ CArchive及简单的文件操作方法

    CArchive 方法用于存取文件 我向你推荐的是使用CArchive,它的使用方法简单且功能十分强大.首先还是用CFile声明一个对象,然后用这个对象的指针做参数声明一个CArchive对象,你就可 ...

  7. VC的文件操作

    各种关于文件的操作在程序设计中是十分常见,如果能对其各种操作都了如指掌,就可以根据实际情况找到最佳的解决方案,从而在较短的时间内编写出高效的代码,因而熟练的掌握文件操作是十分重要的.本文将对Visua ...

  8. CFile、CStdioFile、FILE和其他文件操作(转+总结)

    CFile.CStdioFile.FILE和其他文件操作(转+总结) 2010-04-10 20:36:33|  分类: VC++|举报|字号 订阅     下载LOFTER我的照片书  |     ...

  9. VC++文件操作之最全篇

    一.剖析VC中的文件操作 各种关于文件的操作在程序设计中是十分常见,如果能对其各种操作都了如指掌,就可以根据实际情况找到最佳的解决方案,从而在较短的时间内编写出高效的代码,因而熟练的掌握文件操作是十分 ...

随机推荐

  1. MQTT 客户端源码分析

    参看:逍遥子_mosquitto源码分析系列 参看:MQTT libmosquitto源码分析 参看:Mosquitto学习笔记 一.目录结构 首先我们还是来看一下 mosquitto-1.4.14 ...

  2. android和iOS平台的崩溃捕获和收集

    转自:http://www.cnblogs.com/lancidie/archive/2013/04/13/3019349.html 通过崩溃捕获和收集,可以收集到已发布应用(游戏)的异常,以便开发人 ...

  3. linux cpu内存利用率获取

    有了这么好的工具,我们还需要自己造轮子么? 两种情况,如果有复杂的监控需求,而且愿意花时间学习,我们可以使用nmon:但如果监控需求特殊比如说还要监控单个进程的情况,这时候就需要自己动手实现了.自己动 ...

  4. jQuery contextMenu使用

    地址:jQuery contextMenu 需要以下文件: jquery.contextMenu.css jquery.min.css jquery.contextMenu.js jquery.ui. ...

  5. sql web Admin 源码.net 升级

    http://www.cnblogs.com/foundation/archive/2008/10/07/1305297.html

  6. iview之select选择框选中内容后有空格的问题

    导致原因: option组件格式化造成的.此处</Option>在另一行,只要和输出内容一行,就不会有空格了. <Select :label-in-value="true& ...

  7. wpf Datagrid 的全选

    在我的一个datagrid的一列中需要全选框,所以我在样式中是这样写的: <DataGridTemplateColumn.Header> <CheckBox> <i:In ...

  8. 1、scala安装和基本语法

    一.安装Scala 1.安装 因为Scala是基于Java虚拟机,也就是JVM的一门编程语言. 所有Scala的代码,都需要经过编译为字节码,然后交由Java虚拟机来运行. 所以Scala和Java是 ...

  9. vmware中centos6.5无法启动拷贝出里面的资料的方法

    先说一下我的环境:windows7-x64位机器下安装的vmware虚拟机,里面安装的是centos6.5-x64位的系统. 系统崩溃的原因:从cenos拖拽一个文件到win7下,结果就卡死了.整个系 ...

  10. Google Analytics添加到网站

    把Google Analytics添加到网站的具体方式 https://developers.google.com/analytics/devguides/collection/analyticsjs ...