如果对话框被其它的窗体(比如MSN)覆盖,当MSN被最小化,对话框似乎不能被 
刷新,然后对CPU的占用率就很大。 
可能是哪里的问题呢? 
因为有时候又没有这种情况? 
thanks 

解决方案 »

  1.   

    看看过一会儿cpu占用率有没有降低,如果降低的话,可能是程序或系统中别的程序正在执行比较费时的操作
      

  2.   

    我用的是WIN2000,用任务管理器可以看到确实是我的程序几乎占用了所有的CPU资源。先描述一下我的程序,是一个主要的对话框,然后create了一个child dialog在它上面显示,child dialog上面有一些Edit等控件。
    我注意到如果我点击了child dialog上的edit进行输入(focus在Edit上面),那么如果有其它窗体覆盖就会不能刷新,否则都可以。
    为什么呢?和OnPaint有关?
      

  3.   

    你的主要的对话框是模态的吗?如果是模态的,仔细Debug以下你的程序,主对话框和子对话框之间是否有互相的消息循环,如果村在这样的问题,你的程序就进入了死循环,占用CPU资源100%也就可以理解了。
      

  4.   

    大的对话框是无模式的。另外DEBUG怎么跟踪来看消息循环呢?
    我随便设了一个断点,F10进去的都是vc自己的一些程序,C的还有汇编的。:(
      

  5.   

    再你认为可能会出问题的地方添加一些TRACE语句,然后不要设断点,F5去go,然后观察Debug窗口,看看那个函数中的TRACE语句被频繁调用!!也许就是造成CPU的占用率很大的根源!!good luck~~~~
      

  6.   

    上面有一些Edit的child dialog加上control parent 属性试试
      

  7.   

    谢谢大家!我几乎所有继承的消息都在进入时加了TRACE0,发现最后一次进入的是OnPaint,但OnPaint能运行返回,然后就不知道程序运行到哪里了 :(
    我在主窗口上先create了一个简单的child dialog,它上面只有一个属性页,然后我再在属性页上CREATE它的属性单,EDIT等控件都在这些做为属性单的child dialog上。我把这些child dialog的control parent 属性都改了,还是不行。
    还有什么可能性吗?怎么可以跟踪呢?
    为这个弄了一天了还没解决,头都大了
      

  8.   

    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--------------------------------------------------------------------------------
    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.
      

  9.   

    太谢谢Conry(我笨善良)了,终于搞定 :)