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. Oracle日期范围

    一.SQL语句: select to_date(to_char(to_date('2017-10-01', 'yyyy-mm-dd') + rownum - 1, 'yyyy-mm-dd'), 'yy ...

  2. GridView中数据行的操作

    一个是直接动态绑定gridview 用3楼的办法就可以了 int j=1;//j的数值表示你要取的那一列的索引,要取第二列,j就设为1for (int i = 0; i < this.GridV ...

  3. ASP.NET Core分布式项目实战

    ASP.NET Core开发者成长路线图 asp.net core 官方文档 https://docs.microsoft.com/zh-cn/aspnet/core/getting-started/ ...

  4. MFC——4个基本类中的成员函数介绍

    09121852 杜军 机械设计及理论 1. CMainFrame ActivateFrame使框架对用户可视并可用 CalcWindowRect每当主框架窗口的客户区尺寸发生变化或控制条的位置发生变 ...

  5. LeetCode: 389 Find the Difference(easy)

    题目: Given two strings s and t which consist of only lowercase letters. String t is generated by rand ...

  6. LeetCode: 669 Trim a Binary Search Tree(easy)

    题目: Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so th ...

  7. SCUT - 205 - 饲养牛 - 最大流

    https://scut.online/p/205 连着做所以一开始就觉得是网络流. 这种至多分配几次的很有网络流的特征. 一开始想从食物和饮料流向牛,但是怎么搞都不对. 其实可以从s流向食物,食物流 ...

  8. Search in a Binary Search Tree

    Given the root node of a binary search tree (BST) and a value. You need to find the node in the BST ...

  9. ue4 motage

    Montage是什么 一个(可以自由拼接动画的)动画剪辑,通过slot,在任意时候由玩家主动向动画系统push自己制作的动画剪辑 Montage用途 上图是一个近身攻击动画,含有 3 个片段 [开始. ...

  10. jsp学习与提高(二)——JSP 隐式对象、表单处理及过滤器

    1.JSP 隐式对象 JSP隐式对象是JSP容器为每个页面提供的Java对象,开发者可以直接使用它们而不用显式声明.JSP隐式对象也被称为预定义变量. JSP所支持的九大隐式对象: 对象 描述 req ...