为什么我的对话框有时候会占用完所有的CPU资源呢? 如果对话框被其它的窗体(比如MSN)覆盖,当MSN被最小化,对话框似乎不能被 刷新,然后对CPU的占用率就很大。 可能是哪里的问题呢? 因为有时候又没有这种情况? thanks 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 看看过一会儿cpu占用率有没有降低,如果降低的话,可能是程序或系统中别的程序正在执行比较费时的操作 我用的是WIN2000,用任务管理器可以看到确实是我的程序几乎占用了所有的CPU资源。先描述一下我的程序,是一个主要的对话框,然后create了一个child dialog在它上面显示,child dialog上面有一些Edit等控件。我注意到如果我点击了child dialog上的edit进行输入(focus在Edit上面),那么如果有其它窗体覆盖就会不能刷新,否则都可以。为什么呢?和OnPaint有关? 你的主要的对话框是模态的吗?如果是模态的,仔细Debug以下你的程序,主对话框和子对话框之间是否有互相的消息循环,如果村在这样的问题,你的程序就进入了死循环,占用CPU资源100%也就可以理解了。 大的对话框是无模式的。另外DEBUG怎么跟踪来看消息循环呢?我随便设了一个断点,F10进去的都是vc自己的一些程序,C的还有汇编的。:( 再你认为可能会出问题的地方添加一些TRACE语句,然后不要设断点,F5去go,然后观察Debug窗口,看看那个函数中的TRACE语句被频繁调用!!也许就是造成CPU的占用率很大的根源!!good luck~~~~ 上面有一些Edit的child dialog加上control parent 属性试试 谢谢大家!我几乎所有继承的消息都在进入时加了TRACE0,发现最后一次进入的是OnPaint,但OnPaint能运行返回,然后就不知道程序运行到哪里了 :(我在主窗口上先create了一个简单的child dialog,它上面只有一个属性页,然后我再在属性页上CREATE它的属性单,EDIT等控件都在这些做为属性单的child dialog上。我把这些child dialog的control parent 属性都改了,还是不行。还有什么可能性吗?怎么可以跟踪呢?为这个弄了一天了还没解决,头都大了 PRB: Child CPropertySheet Hangs If Focus Is Switched --------------------------------------------------------------------------------The information in this article applies to:The Microsoft Foundation Class, version 1.0 Microsoft Visual C++, 32-bit Editions, version 4.0a--------------------------------------------------------------------------------SYMPTOMSIf a modeless CPropertySheet is a child of a CDialog or another CPropertySheet, the program will hang in the following situations: The focus is switched back to a PropertyPage that previously had the focus. The focus is placed on a control on a PropertyPage, and then the focus is switched to another window (for example, Program Manager). The focus is on a control on a PropertyPage and the PropertySheet is closed. The program hangs because the child CPropertySheet continuously receives a WM_GETDLGCODE message. CAUSEBy default, CPropertyPages have a WS_EX_CONTROLPARENT style. However, CPropertySheets do not have this style. This style allows a user to press the TAB key to move from a control inside the page to one in the sheet. When the focus is switched from the CPropertyPage, code that handles default command buttons loops through all the controls in the pages and the sheet. Cycling through controls is done using GetNextDlgTabItem(). The loop cycles through controls in the page in the child CPropertySheet and finds its way to controls in the parent page or parent dialog. At this point, GetNextDlgTabItem() is not able to find controls inside the child CPropertySheet because it doesn't have a WS_EX_CONTROLPARENT style. The loop never ends because it never finds the original control that had the focus. RESOLUTIONOverride OnInitDialog() for the child CPropertySheet, and add the WS_EX_CONTROLPARENT style. STATUSThis is a problem with the implementation of the Property Sheet common control, and not MFC's CPropertySheet wrapper. MORE INFORMATIONSample Code // CMySheet is derived from CPropertySheet BOOL CMySheet::OnInitDialog() { ModifyStyleEx (0, WS_EX_CONTROLPARENT); return CPropertySheet::OnInitDialog(); } /* Compile options needed: default */ Additional query words: WS_CHILD Property Sheet lock freeze page modal Keywords : kbMFC kbPropSheet KbUIDesign kbVC kbGrpMFCATL Version : WINDOWS:1.0; winnt:4.0a Platform : WINDOWS winnt Issue type : kbprb Technology : kbvc Last Reviewed: March 13, 2000© 2000 Microsoft Corporation. All rights reserved. Terms of Use. --------------------------------------------------------------------------------Send feedback to MSDN.Look here for MSDN Online resources. 太谢谢Conry(我笨善良)了,终于搞定 :) 用Direct3D画三维图形如何转换坐标? 如何获取局域网内活动主机的IP地址,MAC地址,用户名等信息??? 贴自己写的-我的跳槽经历-深圳(去年的真实经历)-COFFEE的味道 如何在VC6下实现对mysql数据文件的导出与备份????? **************菜鸟问题继续 ************ 紧急求救! 我想将一个字符串(用户密码)加密,有没有好的算法,请大家指教 俺的断点有问题呀! 创建一个新线程时为什么有错误 请教如何在CMDIFrameWnd 中打开windows form的子窗体? ADO执行存储过程,却捕捉不到存储过程错误(例外)??? 拖拽问题
我注意到如果我点击了child dialog上的edit进行输入(focus在Edit上面),那么如果有其它窗体覆盖就会不能刷新,否则都可以。
为什么呢?和OnPaint有关?
我随便设了一个断点,F10进去的都是vc自己的一些程序,C的还有汇编的。:(
我在主窗口上先create了一个简单的child dialog,它上面只有一个属性页,然后我再在属性页上CREATE它的属性单,EDIT等控件都在这些做为属性单的child dialog上。我把这些child dialog的control parent 属性都改了,还是不行。
还有什么可能性吗?怎么可以跟踪呢?
为这个弄了一天了还没解决,头都大了
The information in this article applies to:The Microsoft Foundation Class, version 1.0
Microsoft Visual C++, 32-bit Editions, version 4.0a--------------------------------------------------------------------------------
SYMPTOMS
If a modeless CPropertySheet is a child of a CDialog or another CPropertySheet, the program will hang in the following situations: The focus is switched back to a PropertyPage that previously had the focus.
The focus is placed on a control on a PropertyPage, and then the focus is switched to another window (for example, Program Manager).
The focus is on a control on a PropertyPage and the PropertySheet is closed.
The program hangs because the child CPropertySheet continuously receives a WM_GETDLGCODE message. CAUSE
By default, CPropertyPages have a WS_EX_CONTROLPARENT style. However, CPropertySheets do not have this style. This style allows a user to press the TAB key to move from a control inside the page to one in the sheet. When the focus is switched from the CPropertyPage, code that handles default command buttons loops through all the controls in the pages and the sheet. Cycling through controls is done using GetNextDlgTabItem(). The loop cycles through controls in the page in the child CPropertySheet and finds its way to controls in the parent page or parent dialog. At this point, GetNextDlgTabItem() is not able to find controls inside the child CPropertySheet because it doesn't have a WS_EX_CONTROLPARENT style. The loop never ends because it never finds the original control that had the focus. RESOLUTION
Override OnInitDialog() for the child CPropertySheet, and add the WS_EX_CONTROLPARENT style. STATUS
This is a problem with the implementation of the Property Sheet common control, and not MFC's CPropertySheet wrapper. MORE INFORMATIONSample Code // CMySheet is derived from CPropertySheet
BOOL CMySheet::OnInitDialog()
{
ModifyStyleEx (0, WS_EX_CONTROLPARENT);
return CPropertySheet::OnInitDialog();
} /* Compile options needed: default
*/ Additional query words: WS_CHILD Property Sheet lock freeze page modal Keywords : kbMFC kbPropSheet KbUIDesign kbVC kbGrpMFCATL
Version : WINDOWS:1.0; winnt:4.0a
Platform : WINDOWS winnt
Issue type : kbprb
Technology : kbvc
Last Reviewed: March 13, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.
--------------------------------------------------------------------------------
Send feedback to MSDN.Look here for MSDN Online resources.