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

CPropertySheet in front of modeless child CDialog?

33 views
Skip to first unread message

Mike M

unread,
Mar 29, 2007, 3:31:03 PM3/29/07
to
I've got a CPropertySheet as my main app. From the CPropertyPages
user actions create modeless CDialogs.

I want all the dialogs and the propsheet to be able to be the
front most window if/when it is clicked on.

I've got all the dialogs working this way by making them all
children of the propsheet. They're all siblings and each of them
snaps to the foreground when clicked on.

Only thing I haven't figured out is how to get the propsheet
(CPropertySheet) to reach the foreground when clicked on. It
gains focus of course but remains "behind" any of the child
CDialogs that happen to overlap it.

I've experimented with various z-order settings to no avail.

Is there a way to accomplish this?

I'm using VS2005. I believe this same behavior applies to an
app with a CDialog as the main app so I think the fix would
apply to both.

Thanks,
Mike

AliR (VC++ MVP)

unread,
Mar 29, 2007, 4:32:17 PM3/29/07
to
The property sheet and it's child dialog all have to have the same parent?
Who is the parent of the propertysheet?

If the property sheet is the main window of your app, then you will need a
hidden main window that has the propertysheet as a child, and all the child
modeless dialog will have to have the propertysheet's parent as their
parent.

AliR.


"Mike M" <nos...@nospam.com> wrote in message
news:euh45...@enews2.newsguy.com...

Mike M

unread,
Mar 29, 2007, 6:40:32 PM3/29/07
to
AliR (VC++ MVP) wrote:
> The property sheet and it's child dialog all have to have the same parent?
> Who is the parent of the propertysheet?

It's just a CWinApp derived obj that calls DoModal on the property
sheet. Created with the wizard as a dialog app then converted to prop sheet.

> If the property sheet is the main window of your app, then you will need a
> hidden main window that has the propertysheet as a child, and all the child
> modeless dialog will have to have the propertysheet's parent as their
> parent.

Ok cool. I was thinking that but not yet sure how to go about it. But
that helps. I suppose I could make the propertysheet modeless and put
the CWinApp in a message loop?

Thanks,
Mike

AliR (VC++ MVP)

unread,
Mar 30, 2007, 10:57:05 AM3/30/07
to

"Mike M" <nos...@nospam.com> wrote in message
news:euhf9...@enews2.newsguy.com...

> AliR (VC++ MVP) wrote:
>> The property sheet and it's child dialog all have to have the same
>> parent? Who is the parent of the propertysheet?
>
> It's just a CWinApp derived obj that calls DoModal on the property
> sheet. Created with the wizard as a dialog app then converted to prop
> sheet.
>
>> If the property sheet is the main window of your app, then you will need
>> a hidden main window that has the propertysheet as a child, and all the
>> child modeless dialog will have to have the propertysheet's parent as
>> their parent.
>
> Ok cool. I was thinking that but not yet sure how to go about it. But
> that helps. I suppose I could make the propertysheet modeless and put
> the CWinApp in a message loop?
>

No, that's not what I said, I said you need a hidden window as the main
window. The property sheet can be modal if it wants to be, but it needs to
be a child of the hidden window. And the child windows of the proprty sheet
also need to have the hidden window as their parent.
I didn't say anything about making propertysheet modeless or a messsage
loop.

for simplicity I create a dlg that's hidden. You can create a CWnd if you
like.
BOOL CLSTeacherApp::InitInstance()
{
....
CHiddenDlg HiddenWnd;
HiddenWnd.Create(CHiddenDlg::IDD);

CPropertyDlg dlg(&HiddenWnd);
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
....
return FALSE;
}

Then in your propretysheet

m_ChildDlg.Create(CChildDlg::IDD,GetParent());

if you are creating it from the propetypage

ASSERT(GetParent());
m_ChildDlg.Create(CChildDlg::IDD,GetParent()->GetParent());


AliR.

Mike M

unread,
Mar 30, 2007, 3:27:43 PM3/30/07
to
Ah. (The light goes on). Thanks.

Mike M

unread,
Mar 30, 2007, 3:36:47 PM3/30/07
to
So just for my own edification: I understand the reasoning for forcing a
dialog on top of a parent window. But I'm curious as to what's going on
internally that forces it to happen? And why can't it be overridden with
z-order or something else?

Thanks,
Mike

AliR (VC++ MVP)

unread,
Mar 30, 2007, 3:40:39 PM3/30/07
to
Well I don't know what's going on internally. But I can speculate that the
mechanism that takes care of a popup child is the same as a regular
children, so if a child could go behind a parent, then you can potentially
put a Edit control behind it's parent dialog. (which of course would no be
so good)

AliR.

"Mike M" <nos...@nospam.com> wrote in message

news:eujos...@enews5.newsguy.com...

Mike M

unread,
Mar 31, 2007, 5:01:43 PM3/31/07
to
That's working for me but present one glitch;
Now I have no icon on the taskbar. Any suggestions?

Thanks,
Mike

AliR (VC++ MVP)

unread,
Apr 2, 2007, 11:05:39 AM4/2/07
to
What version of Windows. I just tested the concept under windows XP and I
had an icon for the first visible dialog.

AliR.

"Mike M" <nos...@nospam.com> wrote in message

news:eumi7...@enews4.newsguy.com...

Mike M

unread,
Apr 6, 2007, 9:36:14 PM4/6/07
to
I solved it. I was doing a Create as you suggested. THen I had a
ShowWindow(SW_HIDE) in the hidden dlgs InitDialog. Now icon on
taskbar.

So I merely commented out the Create call and everything's workin
fine.

Thanks

mjkkjk

unread,
Apr 17, 2008, 4:15:32 AM4/17/08
to
I created the propertysheet window as a child of a frame window and to show its icon I used Show Window(SW_SHOWMINIMIZED) in Initialize() of frame window's class. The code works fine on Windows2000/XP/2003 but fails on Windows Vista and 2008. The frame window gets opened along with property sheet when clicked on icon in taskbar. Any suggestions? Why this change in behavior in VISTA?
0 new messages