modeless dialog boxes and z order

My dialog based app creates several modeless dialogs.  I want the window with 
focus to always be on top.  So I want the modeless dialogs on top when 
activated.  I want the main window on top when it is activated (click on it). 
 I know this is contrary to standard behavior.   I also know I may end up 
with hidden windows and have a plan.  At this point however I cannot find a 
way for a modeless dialog to be below the window that created it.

I have tried many different calls to SetWindowPos but somehow either MFC or 
Windows overrides these.

Any help greatly appreciated. 
-- 
Charlie
0
8/22/2007 11:58:02 PM
vc.mfc 33608 articles. 0 followers. Follow

8 Replies
1026 Views

Similar Articles

[PageSpeed] 26

This is contrary to how dialogs work.  Modeless dialogs are normally on top of their
parent.  You can make the desktop window their parent, and this leads to other serious
consequences, 

It is Windows handling the issue.  SetWindowPos can adjust the relative positions of the
dialogs with respect to each other's Z-order, but they will necessarily be on top of their
parent, because that's how dialogs are implemented.  By the way, did you check the result
of SetWindowPos to see if it actually worked?
					joe

On Wed, 22 Aug 2007 16:58:02 -0700, CharlieB <CharlieB@newsgroups.nospam> wrote:

>My dialog based app creates several modeless dialogs.  I want the window with 
>focus to always be on top.  So I want the modeless dialogs on top when 
>activated.  I want the main window on top when it is activated (click on it). 
> I know this is contrary to standard behavior.   I also know I may end up 
>with hidden windows and have a plan.  At this point however I cannot find a 
>way for a modeless dialog to be below the window that created it.
>
>I have tried many different calls to SetWindowPos but somehow either MFC or 
>Windows overrides these.
>
>Any help greatly appreciated. 
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
8/23/2007 12:27:08 AM
By the way, the way I handled this was simply to minimize the modeless dialogs, which
works very well.
				joe

On Wed, 22 Aug 2007 16:58:02 -0700, CharlieB <CharlieB@newsgroups.nospam> wrote:

>My dialog based app creates several modeless dialogs.  I want the window with 
>focus to always be on top.  So I want the modeless dialogs on top when 
>activated.  I want the main window on top when it is activated (click on it). 
> I know this is contrary to standard behavior.   I also know I may end up 
>with hidden windows and have a plan.  At this point however I cannot find a 
>way for a modeless dialog to be below the window that created it.
>
>I have tried many different calls to SetWindowPos but somehow either MFC or 
>Windows overrides these.
>
>Any help greatly appreciated. 
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
8/23/2007 12:27:35 AM
I am not a big fan of making the desktop the parent of a child window, but 
that is what you will have to do when you create your child dialogs.

The other solution that Joe didn't talk about is having a hidden main 
window/dialog that is the parent of all the other visible window/dialogs in 
your application.

AliR.

"CharlieB" <CharlieB@newsgroups.nospam> wrote in message 
news:A01E0742-A183-4FD7-B1DF-9356461FF299@microsoft.com...
> My dialog based app creates several modeless dialogs.  I want the window 
> with
> focus to always be on top.  So I want the modeless dialogs on top when
> activated.  I want the main window on top when it is activated (click on 
> it).
> I know this is contrary to standard behavior.   I also know I may end up
> with hidden windows and have a plan.  At this point however I cannot find 
> a
> way for a modeless dialog to be below the window that created it.
>
> I have tried many different calls to SetWindowPos but somehow either MFC 
> or
> Windows overrides these.
>
> Any help greatly appreciated.
> -- 
> Charlie 

0
AliR3470 (3236)
8/23/2007 3:24:17 AM
Could you explain what other problem you refer to should the desktop be the 
parent?  I saw a similar solution on another service and the poster had asked 
if this approach was ok.  What bad things happen if you make the desktop the 
parent?
-- 
Charlie


"Joseph M. Newcomer" wrote:

> This is contrary to how dialogs work.  Modeless dialogs are normally on top of their
> parent.  You can make the desktop window their parent, and this leads to other serious
> consequences, 
> 
> It is Windows handling the issue.  SetWindowPos can adjust the relative positions of the
> dialogs with respect to each other's Z-order, but they will necessarily be on top of their
> parent, because that's how dialogs are implemented.  By the way, did you check the result
> of SetWindowPos to see if it actually worked?
> 					joe
> 
> On Wed, 22 Aug 2007 16:58:02 -0700, CharlieB <CharlieB@newsgroups.nospam> wrote:
> 
> >My dialog based app creates several modeless dialogs.  I want the window with 
> >focus to always be on top.  So I want the modeless dialogs on top when 
> >activated.  I want the main window on top when it is activated (click on it). 
> > I know this is contrary to standard behavior.   I also know I may end up 
> >with hidden windows and have a plan.  At this point however I cannot find a 
> >way for a modeless dialog to be below the window that created it.
> >
> >I have tried many different calls to SetWindowPos but somehow either MFC or 
> >Windows overrides these.
> >
> >Any help greatly appreciated. 
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm
> 
0
8/23/2007 6:00:01 AM
"CharlieB" <CharlieB@newsgroups.nospam> wrote in message 
news:A01E0742-A183-4FD7-B1DF-9356461FF299@microsoft.com...

> My dialog based app creates several modeless dialogs.  I want the window 
> with
> focus to always be on top.  So I want the modeless dialogs on top when
> activated.  I want the main window on top when it is activated (click on 
> it).
> I know this is contrary to standard behavior.

So, when you are entering stuff into your main window, your modeless 
dialogues are quite possibly going to be completely hidden behind it, making 
it impossible to click on one to reactivate it.

Solution: a toolbar button to reactivate each modeless dialogue.

No we have go that far, why not just hide the modeless dialogue when your 
main window has the focus and show it with the toolbar button you needed 
anyway?   Then your program can conform to the usual paradigm that dialogues 
are descendants of application windows and children are always on top of 
parents (or hidden).

Dave
-- 
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm

0
dave9996 (486)
8/23/2007 10:51:04 AM
Hi Dave,

I also like this approach (using a toolbar or other button to re-show the 
window).  You don't really need to destroy the dialog, you can simply hide 
it or just bring it to the top again when the button is pressed so the user 
can see it.

This might be an application for a tabbed dialog or property sheet as well. 
Unless there is some reason for the dialogs to float around (like the user 
wants to place them on the screen) tabs make it really easy to switch 
between screens.  Of course, with tabs only one shows at a time, but you 
don't have to wonder where the others went.

I also like the "Office" approach where they create a separate "window" for 
each open document so you can just click on the task bar button (or from the 
list that pops up from the grouped button) to get back to the document.

OP could also have a Wiindow menu that the user could use to pop up the 
windows again.  If the window is already open then just pop it to the front. 
If it is not open, then open it and pop it to the front.

Tom

"David Webber" <dave@musical-dot-demon-dot-co.uk> wrote in message 
news:%23LdmUOX5HHA.748@TK2MSFTNGP04.phx.gbl...
>
> "CharlieB" <CharlieB@newsgroups.nospam> wrote in message 
> news:A01E0742-A183-4FD7-B1DF-9356461FF299@microsoft.com...
>
>> My dialog based app creates several modeless dialogs.  I want the window 
>> with
>> focus to always be on top.  So I want the modeless dialogs on top when
>> activated.  I want the main window on top when it is activated (click on 
>> it).
>> I know this is contrary to standard behavior.
>
> So, when you are entering stuff into your main window, your modeless 
> dialogues are quite possibly going to be completely hidden behind it, 
> making it impossible to click on one to reactivate it.
>
> Solution: a toolbar button to reactivate each modeless dialogue.
>
> No we have go that far, why not just hide the modeless dialogue when your 
> main window has the focus and show it with the toolbar button you needed 
> anyway?   Then your program can conform to the usual paradigm that 
> dialogues are descendants of application windows and children are always 
> on top of parents (or hidden).
>
> Dave
> -- 
> David Webber
> Author of 'Mozart the Music Processor'
> http://www.mozart.co.uk
> For discussion/support see
> http://www.mozart.co.uk/mzusers/mailinglist.htm
> 


0
tserface (3861)
8/23/2007 1:23:37 PM
I have written a couple of apps that use the desktop as parent for modeless 
sub-dialogs so they can be moved behind the main, and have not *discovered* 
any show-stoppers (yet).  That's not to say there are none, but if there are 
any no one's seen them after several years of regular use.

Each of the modeless child-of-the-desktop dialogs automatically has its own 
icon on the taskbar.  If they are completely hidden by the main (or any 
other) dialog, clicking that taskbar icon brings it to the top of the pile 
again.  In addition, the app is written so that the same action that opens 
the modeless dialog in the first place (a button on the main dialog or one of 
the sub-dialogs, or a menu selection) will simply bring it to the top if it 
is already open.  Easy.

I am working with laptop systems where screen real estate is scarce and 
valuable; being able to shuffle the main and sub dialogs as needed at any 
given moment makes the user's life much easier.  I realize that this is a 
work-around (a.k.a. "kludge"), but it works, does what I need it to do, and, 
to my knowledge, hasn't produced any undesirable side effects in years of 
operation.  I use them myself, and the other users have no qualms about 
letting me know about deficiencies in the programs!  YMMV.

"Tom Serface" wrote:

> Hi Dave,
> 
> I also like this approach (using a toolbar or other button to re-show the 
> window).  You don't really need to destroy the dialog, you can simply hide 
> it or just bring it to the top again when the button is pressed so the user 
> can see it.
> 
> This might be an application for a tabbed dialog or property sheet as well. 
> Unless there is some reason for the dialogs to float around (like the user 
> wants to place them on the screen) tabs make it really easy to switch 
> between screens.  Of course, with tabs only one shows at a time, but you 
> don't have to wonder where the others went.
> 
> I also like the "Office" approach where they create a separate "window" for 
> each open document so you can just click on the task bar button (or from the 
> list that pops up from the grouped button) to get back to the document.
> 
> OP could also have a Wiindow menu that the user could use to pop up the 
> windows again.  If the window is already open then just pop it to the front. 
> If it is not open, then open it and pop it to the front.
> 
> Tom
> 
> "David Webber" <dave@musical-dot-demon-dot-co.uk> wrote in message 
> news:%23LdmUOX5HHA.748@TK2MSFTNGP04.phx.gbl...
> >
> > "CharlieB" <CharlieB@newsgroups.nospam> wrote in message 
> > news:A01E0742-A183-4FD7-B1DF-9356461FF299@microsoft.com...
> >
> >> My dialog based app creates several modeless dialogs.  I want the window 
> >> with
> >> focus to always be on top.  So I want the modeless dialogs on top when
> >> activated.  I want the main window on top when it is activated (click on 
> >> it).
> >> I know this is contrary to standard behavior.
> >
> > So, when you are entering stuff into your main window, your modeless 
> > dialogues are quite possibly going to be completely hidden behind it, 
> > making it impossible to click on one to reactivate it.
> >
> > Solution: a toolbar button to reactivate each modeless dialogue.
> >
> > No we have go that far, why not just hide the modeless dialogue when your 
> > main window has the focus and show it with the toolbar button you needed 
> > anyway?   Then your program can conform to the usual paradigm that 
> > dialogues are descendants of application windows and children are always 
> > on top of parents (or hidden).
> >
> > Dave
> > -- 
> > David Webber
> > Author of 'Mozart the Music Processor'
> > http://www.mozart.co.uk
> > For discussion/support see
> > http://www.mozart.co.uk/mzusers/mailinglist.htm
> > 
> 
> 
> 
0
Okie (47)
8/23/2007 4:44:02 PM
Mostly the problem deals with what the parent is.  Dialogs that have the desktop as parent
can be hidden by ANY other app, not just yours; therefore, they can be hard to find, which
is very awkward for the end user.  I have found the resulting confusion difficult for end
users to deal with, which is why I abandoned this by 1992.  

Note that you can also use the concept of "multiple top-level windows" in some cases to
get this effect, although the old VB interface worked this way, and was ultimately
abandoned as a fundamentally screwed-up interface; it works well only when all the
top-level windows are essentially identical.

I found the "minimize" approach to work much better when I need modeless dialogs.
					joe

On Wed, 22 Aug 2007 23:00:01 -0700, CharlieB <CharlieB@newsgroups.nospam> wrote:

>Could you explain what other problem you refer to should the desktop be the 
>parent?  I saw a similar solution on another service and the poster had asked 
>if this approach was ok.  What bad things happen if you make the desktop the 
>parent?
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
11/19/2007 7:23:47 PM
Reply:

Similar Artilces:

tab order (VC6)
I'm trying to use tab order at design time to show one component above the other. I have two labels and two picture controls. I'm using only standard VC6 controls. First picture shows above label, but I can't force second picture to show above label. :( Please, help. In my experience, tab order does not alter drawing order. I've usually worked around this by drawing the background image on the dialog box itself by overriding CMyDialog::OnPaint() - it's possible to use a hidden static control to make the size and location accessible in the resource editor: ...

Address Book Sort Order
How can i change the sort order of the address book in Outlook XP? Go to Tools > E-mail accounts > View or change existing directories or address books > Outlook Address Book > Change. > Set your sort order there -- Russ Valentine [MVP-Outlook] "DLeslie" <dleslie@antiochnetwork.org> wrote in message news:02f101c3d614$a1031690$a101280a@phx.gbl... > How can i change the sort order of the address book in > Outlook XP? ...

Combo box to find records
Hi, need help with what I am sure is a simple problem. I have a form and wish to find records using a combo box. Which I know how to do. The problem is it takes me to "one" record. I would like to select, for example, employee name: John Smith and it return all records for John Smith while filtering out all other records. I would be thankful for any help. Thanks, Michael On Wed, 30 Jan 2008 20:24:04 -0800, Michaelchessking <Michaelchessking@discussions.microsoft.com> wrote: >Hi, need help with what I am sure is a simple problem. > >I have a form and wis...

CScrollBar box flicker problem
I put CScrollBar in CDialog and thumb button flickering all the time. Somone can help me? Tnx ...

How do to enter data in a combo box on a worksheet?
Use the dropdown arrow? Shereen wrote: -- Dave Peterson ...

Disable 'Macro' dialog box...
Thanks Geoff, for the info on how to protect the VBA code. Have one further question; Now that the workbook and code is protected, I have sub routines that are run from command buttons. However, it is still possible to push ALT-F8 to list my routines, then click on a routine, then choose 'Run'... Is there a way to disable this option, so that users can not view or run the list of available routines (I need them to run the routines, only from the command buttons). Ruskin You can do what you want by making each macro a Private macro. This will preclude that macro from appearing...

Excel should allow auto shape boxes to be fixed to points on the g
I have constructed a graph that has data added to it daily. On the graph I have used several auto shape boxes to highlight key data milestones. Problem is every time I add new data the auto shape boxes move and have to be manually adjusted to repoint them to the relevant data point. Is there any way they can be fixed to the relevant data points on the graph so that they remain fixed to that point and therefore don't move/shift when new data is added? ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for ...

Combo Box Moves
I have 4 activeX control combo boxes on an Excel sheet (2 on the left and 2 in the middle) and if I print the sheet the 2 boxes thatbare in the middle move over to the left hand side. I have gone into the properties menu and they show as locked but it does not make any difference. Also when I print the sheet the 2 boxes on the left which were made the same size as the underlying cells print out smaller than the underlying cells. Can anyone help please? Hi John, See MSKB Article # 838910 (Controls move to the left of the worksheet in Microsoft Excel 2002) http://support.micr...

After Add Record, Put Cursor in specific Text Box
Hi, I had the wizard set up a button to add record (it puts in the code below in the On Click property of the button). I'd then like to have the focus go to text box [ProjectType]. I don't know how to do that. TIA :) Private Sub cmdAddRecord_Click() On Error GoTo Err_cmdAddRecord_Click DoCmd.GoToRecord , , acNewRec Exit_cmdAddRecord_Click: Exit Sub Err_cmdAddRecord_Click: MsgBox Err.Description Resume Exit_cmdAddRecord_Click End Sub Private Sub cmdAddRecord_Click() On Error GoTo Err_cmdAddRecord_Click If Me.Dirty Then Me.Dirty = False If ...

Closing a child Dialog when the Mouse button is clicked outside the Parent Dialog
Hai I Have a Parent Dialog and a ChildDialog associated with that and when the mouse is clciked outside the Parent Dialog the child window has to be closed and the parent dialog has to minimized to the taskbar please let me know how to handle this situation Thanks and Regards sures h Are you referring to a dialogs that have Parent/Child relation? The reason I ask is because this is rather unusual. Modeless dialogs are used as children of the frame window as form view. Are you writing something similar to this? "Suresh" wrot...

Dialog statusbar
I have a dialog form that I added a statusbar with five panes. Now, I created it specifically for a certain size form and when I resize the form, the statusbar is no longer the way I designed it. Is there a way to create the statusbar based on the form's size? I tried using rect.width()/5 but it did not really seem to do anything. Roger I always advocate using SDI application with CFormView derived view instead dialog based application. It looks like a dialog based application but all goodies like handling commands and resizing control bars is for free, since framework takes c...

Strange tabbed dialog message pump issue
I am running into a nasty issue that I don't quite understand. My application has a tabbed dialog type control (Stingray Tab-Wnd control) contained in a CFormView object. Within some of the tabs are CDialog-derived windows containing a grid control. I initialize all tab windows when the form view opens. The grid control also has an OnInitialUpdate method that gets called. When a tab is clicked, if it's the first time, a call is made to the tab to fill the grid. After the CFormView initialization is complete I active the first tab programatically and it fills it's gri...

Purchase Order Form
Where do you add a new PO Form that you manually created so that when you go to print a PO you can choose it instead of "Blank Form" or "Other Form"? ...

Public Function to display in text box
Have public function (loaded in the global module) that produces a variable as a double. That all works fine as evidenced by the debug.print method in the immediate window. I desire to have the current value of the variable displayed in a text box. I created a callback function (loaded in global module) that looks like: Public Function GetCurrentWork_GPCI() As Double Dim CurrentWork_GPCI As Double GetCurrentWork_GPCI = CurrentWork_GPCI End Function I can't figure out how to make it display; I've currently got the control source property ...

have to manually add the supplier tax rate to the purchase order
"If you create a purchase order in Microsoft Retail Management System Headquarters by using the "Style 340: PO Planner" worksheet, the program does not automatically populate the supplier tax rate information when the purchase order is downloaded to the store. Therefore, you will have to manually add the supplier tax rate to the purchase order." In the Store Operation Manager PO window's , It will be interesting to have a button that calculate taxes like if the PO was done with Store Operation Manager instead of doing the above process ---------------- This post...

Can I arrange items on my clipboard in a specific order?
Is it possible to change the arrangement of items in my clipboard to a certain order to make it more usable for me? Thanks! ...

IE 8 displays nothing for a page with a high-order Unicode character
Below is a minimal file that IE fails to display: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <body> <p>Big Unicode &#65185;<br />0 items</p> </body> </html> If I change the "0 items" to start with something non-numerical, such as "A items" it displays OK. Similarly, changing the high value Unicode char to something much lower and it al...

Form design to add data to 3 tables in "Order Entry" style db
Sorry if this is a duplicate. I thought I posted it yesterday but couldn't find it today... I need help figuring out the best way to design a form for data entry in the "Order Entry" style, adding data to three related tables. For clarity I have eliminated several fields. Here are the three tables, plus the fourth that is a reference table: tblCustomers: CustID (pk), CustName tblOrders: OrderID (pk), OrderDate, CustID (fk) tblOrderProd: OrderProdID (pk), OrderID (fk), ProdID (fk) tblProducts: ProdID (pk), ProdName Each Customer is associated with one or mo...

Ship-to address on Purchase Orders
Hello, I'm using Great Plains 8.0 and having trouble figuring out the assignment of ship-to address when using a different address for each line-item. Everything works fine if I have a ship-to address for each line item but I get a blank ship-to when the line-item does not have a ship-to address. I found an article in the KB, #909722, that addresses this but I have tried putting addresses in both locations that they specify but I still get a blank if the line-item does not have a ship-to. Any help would be greatly appreciated. Thank you I recall this issue from some time back. I...

Check Box Sizing
Hi, When using check boxes, no matter how much I resize the area, the actual check box itself never gets larger (only the area for a description does). Is there any way to increase the size of the check box so that a larger check mark appears on the worksheet? Thanks, Brad. Brad, If you select "move and size with cell" (on the properties tab) then you can resize the checkbox by increasing the column width and/or row height. Give my regards to Boston. HTH, Bernie MS Excel MVP "beantownbrad" <beantownbrad@discussions.microsoft.com> wrote in message news:C63B5725-...

Excel 2007 Sort-How to Retain Sort Order
In earlier versions of Excel, if you had a worksheet that you sorted, then the sort columns and order (ascending/descending) was retained, so that if you added data and wanted to sort it, you simply told Excel to re-do the same sort. But in Excel 2007, the sort instructions are not retained, so that I have to recreate the entire sort instructions from scratch every time that I need to sort the worksheet. How do I get Excel to retain the sort instructions for a worksheet so that I can re-sort the worksheet without having to laboriously re-create the sort instructions every time that I ...

file dialog #2
When I open a file dialog, it always defaults to My Documents. Is there a mthod of API call that I can use to make a file dialog default to the application's working directory, or some other specified directory? Thanks. >When I open a file dialog, it always defaults to My Documents. Is there a >mthod of API call that I can use to make a file dialog default to the >application's working directory, or some other specified directory? Yes, you can alter the initial directory. The rules are explained in the description of the lpstrInitialDir member of the OPENFILENAME struct...

Quickbooks Purchase Order Integration
How is this working for everyone? When RMS posts the purchase orders over to Quickbooks, does it include the PO# as a reference so they can pay against it? Any tricks to making this work smoothly? ...

Total in order
Does anybody has a problem with total in order? Sometimes it's not correct. I can't find situation why it happened but it is really nosy. I tried following query: SELECT * FROM SOP10100 WHERE SUBTOTAL <> REMSUBTO and SELECT * FROM SOP30200 WHERE SUBTOTAL <> REMSUBTO and I've got a lot of them In field REMSUBTO by some reason correct value, but in SUBTOTAL not. Very strange. I have a small customization how to calculate, but it is only working if you press button. But I have a lot of invoices without this customization with wrong total. Any ideas. Thanks Vitali...

Text Box Updating
I am having trouble getting a text box to auto fill from a choice made from a combo box. Combo Box Name is Address_21 Text Box Name is City_1 My code is as follows: 'Auto Fill CES Spec Written Office Private Sub Address_21_Change() Select Case Address_21 Case ""2306 Long Green Court" City_1 = "Valrico" Case ""3440 Oakcliff Road" City_1 = "Atlanta" Case "7015 East 14th Aveneue" City_1 = "Tampa" Case "1800 Taylor Drive" City_1...