DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 8 of 8

Thread: Dialog opens properly in winxp, but Freezes in win98se

  1. #1
    Join Date
    May 2004
    Posts
    70

    Dialog opens properly in winxp, but Freezes in win98se

    "MyDlg" is a dialog class derived from CDialog
    "pg_price" is a derived CPropertyPage

    on pressing a button pg_price(derived from CPropertyPage), domodal is called
    Code:
    void pg_price::OnBUTTON() 
    {
    	MyDlg MyDlg_obj;
    	MyDlg_obj.DoModal();
    }

    OnInitDialog of MyDlg (derived from CDialog):
    Code:
    BOOL MyDlg::OnInitDialog() 
    {
    	CDialog::OnInitDialog();
    	return TRUE;  // return TRUE unless you set the focus to a control
    	              // EXCEPTION: OCX Property Pages should return FALSE
    }
    now, the problem is that on winxp there isnt any problem. MyDlg_obj.DoModal(); displays the resource of MyDlg

    but on win98se, the whole application hangs and become non-responsive upon clicking the button
    MyDlg never appeared

    so i ran a debugger and found out that the application has no problem running up to "BOOL MyDlg::OnInitDialog()" and returns it without any problem. I hit "f5" again and the application hangs. no assert/buffer overflow problems error messages were given, the whole application simply hangs there. i believe that's because the user interface thread got into something it cant get out of

    doing a "step over" on the debugger in win98se i got the following


    doing a "step over on debugger in winxp



    i really got no idea how this happened
    how is it possible that this app works well on winxp but not win98se?
    i need that application on win98se platform

    using vc++6.0 SP6
    win98se/winxp

    please assist
    Last edited by hanhao; 07-10-2005 at 01:17 AM.

  2. #2
    Join Date
    Dec 2003
    Posts
    3,366
    Build it on 98 and it will probably work on both platforms. The two are totally different -- newer os have large parts of NT (way different from 98) in them -- and there are a number of compatibility problems. They are small aggravating problems that 'almost work' making it frustrating to fix while giving the illusion that its going to work 'any day now'.

  3. #3
    Join Date
    May 2004
    Posts
    70
    Quote Originally Posted by jonnin
    Build it on 98 and it will probably work on both platforms. The two are totally different -- newer os have large parts of NT (way different from 98) in them -- and there are a number of compatibility problems. They are small aggravating problems that 'almost work' making it frustrating to fix while giving the illusion that its going to work 'any day now'.
    ok,
    but is there a better solution other than rebuild the whole prog?

    i suspect it's the button on CPropertySheet that's causing the problem
    CPropertySheet will freeze when it runs a DoModal command?

  4. #4
    Join Date
    Dec 2003
    Posts
    3,366
    I dont know why it would, but if you know exactly where the problem is you can try to work around it. Domodal does make whatever is done modally sieze control of the app (you cant go back to other window until that one closes) try a different type of creation?

  5. #5
    Join Date
    May 2004
    Posts
    70
    after some research, i discovered that because the button was located on a CPropertySheet and the domodal is launch from it
    this CPropertySheet is one of the pages in the tabs area
    this tab area is on my main dialog

    anyone have problems doing domodal on CPropertySheet ?
    how to solve this problem?

  6. #6
    Join Date
    May 2004
    Posts
    70
    after some research, i discovered that because the button was located on a CPropertySheet and the domodal is launch from it
    this CPropertySheet is one of the pages in the tabs area
    this tab area is on my main dialog

    anyone have problems doing domodal on CPropertySheet ?
    how to solve this problem?

  7. #7
    Join Date
    May 2004
    Posts
    70
    ok i did my homework
    for the record, if any of u guys encounter this problem again, here's the solution

    CAUSE:
    due to some glitch in CPropertyPage, the user interface thread will go into an infinite loop when a control on the propertypage has keyboard focus and the application loses focus
    eg. switching application, creating a dialog

    SOLUTION:
    u gotta shift focus away to something else when you detect the above even

    Code:
    void CDlg::OnActivate(UINT nState,CWnd* pWndOther, BOOL bMinimized)
    {
    	if(nState == WA_INACTIVE)
    	{
    		::SetFocus(CDlg::m_hWndTop);
    	}
    	CDialog::OnActivate( nState, pWndOther, bMinimized);
    
    }
    in your message map:

    Code:
    	ON_WM_ACTIVATE()
    hence the moment your program loses focus, it immediately shifts focus to the topmost window of your program instead of staying onto the control

    however i believe that winxp has fixed the problem already

  8. #8
    Join Date
    Mar 2006
    Posts
    1
    Actually, I've encountered this problem and I wanted to share the extended information so that others that encounter similar problem knwo the cause.

    My symptoms were a dialog with a tab control containing control having the focus woudl freeze the application when the application lost the focus.

    The application would use 100% of the CPU. Using the break command in VC would show that the app was processing WM_GETDLGCODE.

    According to microsoft (see, for example, KB261192), this is actually related to the fact that the child dialog contained in the tab control has the WS_EX_CONTROLPARENT extended flag set and the way Windows traverses the list of dialog controls.

    So, while the solution proposed works, it could still fail if the same bug is triggered from another condition. What I do is to remove the flag after the dialog has been added to the tab control, like this:

    // tab is the dialog added to the tab control, not the tab control.
    // This is done after Create() ing the dialog.
    ::SetWindowLong( tab.m_hWnd, GWL_EXSTYLE, ::GetWindowLong( tab.m_hWnd, GWL_EXSTYLE ) & ~WS_EX_CONTROLPARENT );

    i.e.: it removes the style.

    I decided to post this because I lost time looking around the net and didn't find a nice result right away. Hope it helps someone someday.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center