Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Application Hangs when going through CPropertySheet OnInitDialog for XP sp3 and Vista

189 views
Skip to first unread message

gag

unread,
Feb 7, 2009, 1:44:04 AM2/7/09
to
Hi all,

We have an application that hangs for some users who are running XP sp
3 and Vista. The application is a MFC dialog with a CPropertySheet
which contains two CPropertyPages on the dialog. It looks like the
application goes into the CPropertySheet OnInitDialog and never
returns. When I look in the task manager it shows that it is still
running.

This hang only happens for some users. For those users I have had them
start up in safe mode and the app will successfully launch. It seems
like there maybe some conflict with another app that is running.

The real hassle is that I cannot recreate it at work or at home to try
to work on it.

Does anyone have any suggestions? I am running out of things to try.

Any help would be greatly appreciated.

Thank you in advance!

Greg

David Lowndes

unread,
Feb 7, 2009, 5:23:54 AM2/7/09
to
>The real hassle is that I cannot recreate it at work or at home to try
>to work on it.

Greg,

It sounds like you'll be reliant on your users who can reproduce it -
give them a version with some additional diagnostic code in it, or try
to get them to run whatever tools you need - for instance Spy++ might
be useful in showing if your application is repeatedly looping on any
Windows messages.

Dave

gag

unread,
Feb 7, 2009, 3:41:23 PM2/7/09
to

Hi Dave,

I have sent one person a build with some message boxes. The last one I
get is just before the call to CPropertySheet::OnInitDialog. It really
difficult working with the end users. They are insurance agents and
don't want to spend the time. What I would like to do is to some how
get them to create a image that I can run on my VM ware. It's just
getting someone to agree to it that is the problem.

Thanks,

Greg

David Lowndes

unread,
Feb 7, 2009, 7:43:45 PM2/7/09
to
>I have sent one person a build with some message boxes. The last one I
>get is just before the call to CPropertySheet::OnInitDialog.

Does the sheet/pages ever get WM_INITDIALOG - do you have any events
recorded from inside that handler?

If you can get a user to run Spy++ it may help to get a log of
messages from that.

>It really difficult working with the end users.

It always is - can you bribe them with a freebie? :)

Dave

RainMan

unread,
Feb 10, 2009, 12:06:01 AM2/10/09
to
OS does not really matter. Modify property sheet extended style adding
WS_EX_CONTROLPARENT.
If not set property sheet has a problem restoring control’s focus after
focus was switched from a property page to another window or control.
Property page ends up in an endless loop once it hits property sheet. It
cannot find any control since default property sheet style does not have
WS_EX_CONTROLPARENT style.

WS_EX_CONTROLPARENT will cause property sheet to be treated as another
control when embedded in another window and allow for tabbing through
property sheet controls and property pages without any problem.

--
RainMan

RainMan

unread,
Feb 10, 2009, 12:07:01 AM2/10/09
to
OS does not really matter. Modify property sheet extended style adding
WS_EX_CONTROLPARENT.
If not set property sheet has a problem restoring control’s focus after
focus was switched from a property page to another window or control.
Property page ends up in an endless loop once it hits property sheet. It
cannot find any control since default property sheet style does not have
WS_EX_CONTROLPARENT style.

WS_EX_CONTROLPARENT will cause property sheet to be treated as another
control when embedded in another window and allow for tabbing through
property sheet controls and property pages without any problem.

--
RainMan

gag

unread,
Feb 11, 2009, 10:55:00 AM2/11/09
to
> > Greg- Hide quoted text -
>
> - Show quoted text -

We are setting this styel already. I read that setting the
WS_EX_CONTROLPARENT before the CPropertySheet::onInitDialog call could
cause this problem. I also read that setting it after the onInitDialog
could also cause the endless loop. I have tried both and do not know
where to go from here.

ZaZy

unread,
Feb 27, 2009, 7:06:13 AM2/27/09
to
gag ha scritto:

Dave, just try this:

BOOL CMyPropertySheet::PreTranslateMessage(MSG* pMsg)
{
if( pMsg->message == WM_GETDLGCODE)
{
CPropertySheet::PreTranslateMessage(pMsg);
return FALSE;
}

return CPropertySheet::PreTranslateMessage(pMsg);
}

And remember that the MyPropertySheet instance should not be child of a
control.
This simply tells to do not dispatch that damned message and SHOULD (in
my casa HAS) solve the problem.
Try and please let us know!

ZaZy

gag

unread,
Feb 27, 2009, 10:52:06 AM2/27/09
to
> ZaZy- Hide quoted text -

>
> - Show quoted text -

Still having the problem. The property sheet is not a child of any
control. It is put onto CDialog object. I use the following code.

m_appPropSheet.AddPage(m_saleIllustrationPropPage);

m_appPropSheet.AddPage(m_multiLifeIllustrationPropPage);

m_appPropSheet.EnableStackedTabs( FALSE );

m_appPropSheet.Create(this, WS_CHILD | WS_VISIBLE , 0);

m_appPropSheet.ModifyStyleEx (0, WS_EX_CONTROLPARENT);

m_appPropSheet.ModifyStyle( 0, WS_TABSTOP);

m_appPropSheet.SetWindowPos(NULL, 0, 0, 0, 0,

SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);

Is this code causing the problem?

I am really stuck on this and our clients are getting impatient

Thanks,

Greg

ZaZy

unread,
Feb 27, 2009, 4:40:17 PM2/27/09
to

Hi greg,

Your code appears get no problems other than the fact that the
ModifyStyleEx is not in the oninit of the derived class.
I suppose that m_appPropSheet is of type CMyPropertySheet in suggesting
you these add (i include also the pretranslatemessage that had been
already posted)

void CMyPropertySheet::OnKillFocus(CWnd* pNewWnd)
{
// This takes focus away from the propertysheet (this is one of the
causes of loop)
AfxGetApp()->GetMainWnd()->SetFocus();

CPropertySheet::OnKillFocus(pNewWnd);
}

BOOL CMyPropertySheet::OnInitDialog()
{
CPropertySheet::OnInitDialog();
ModifyStyleEx(0, WS_EX_CONTROLPARENT);
return TRUE;
}

BOOL CMyPropertySheet::PreTranslateMessage(MSG* pMsg)
{
if( pMsg->message == WM_GETDLGCODE)
{
CPropertySheet::PreTranslateMessage(pMsg);
return FALSE;
}
return CPropertySheet::PreTranslateMessage(pMsg);
}

Another try you can do is to move the ModifyStyleEx contained in the
OnInitDialog BEFORE the CPropertySheet::OnInitDialog.
This solved all my PropertySheets problems.
Hoping this helps.
Let us know

gag

unread,
Mar 5, 2009, 1:15:16 PM3/5/09
to
> Let us know- Hide quoted text -

>
> - Show quoted text -

In the code we have tried moving the ModifyStyleEx (0,
WS_EX_CONTROLPARENT); call before the CPropertySheet::onInitDialog
call and when we create the property sheet,
Create(this, WS_CHILD | WS_VISIBLE | WS_TABSTOP, WS_EX_CONTROLPARENT);

None of these changes have worked.

Thanks,

Greg

ZaZy

unread,
Mar 5, 2009, 1:56:23 PM3/5/09
to

If you can provide an "extract" of the code that generates the dialog so
that it could be better analized i can give it a look also with spy++
(Win XP SP3 & much virtual machines). Also a list of running processes
on the machine that are having trouble is a good help.

gag

unread,
Mar 6, 2009, 9:55:26 AM3/6/09
to
> on the machine that are having trouble is a good help.- Hide quoted text -

>
> - Show quoted text -

Hi All,

I found the problem. It had nothing to do with the property sheet
initialization. We were making a couple of sendMessage calls with user
defined messages. We were using the HWND_BROADCAST parameter instead
of the handle to our top level window. I think since the message was
broadcast to every top level window, it was being caught be some other
app. I changed it to call PostMessage and used the handle to our top
level window and now it works just fine.

Thank you all for your help!

Greg

0 new messages