How to do Z-axis ordering on elements in a Dialog Box?

As you may know from my previous threads, my program is reading in data
from many files and I have a progress bar to display this.  Once each
file is loaded the progress bar is incremented and the name of the file
is displayed in a text control in the middle of the progress bar.  The
only problem I'm having is that the progress bar is being displayed on
top of the text, so at the moment, I'm having the text below the
progress bar, which takes up more space and isn't at pretty.  Soooo ...
how do you implement Z-axis ordering?  Thanks!

0
cyde (46)
8/10/2005 4:54:24 PM
vc.mfc 33608 articles. 0 followers. Follow

8 Replies
541 Views

Similar Articles

[PageSpeed] 35

You can use SetWindowPos to change the zorder.

m_Static.SetWindowPos(&m_Progress,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);

But I think you would be happier if you make the static control a child of
the progress bar.

m_Static.Create(text,style,rect,&m_Progress,ID);

AliR.


"Cyde Weys" <cyde@umd.edu> wrote in message
news:1123692864.684380.183080@f14g2000cwb.googlegroups.com...
> As you may know from my previous threads, my program is reading in data
> from many files and I have a progress bar to display this.  Once each
> file is loaded the progress bar is incremented and the name of the file
> is displayed in a text control in the middle of the progress bar.  The
> only problem I'm having is that the progress bar is being displayed on
> top of the text, so at the moment, I'm having the text below the
> progress bar, which takes up more space and isn't at pretty.  Soooo ...
> how do you implement Z-axis ordering?  Thanks!
>


0
AliR3470 (3235)
8/10/2005 4:59:22 PM
First of all, thanks for the help.

AliR wrote:
> "Cyde Weys" <cyde@umd.edu> wrote in message
> news:1123692864.684380.183080@f14g2000cwb.googlegroups.com...
> > As you may know from my previous threads, my program is reading in data
> > from many files and I have a progress bar to display this.  Once each
> > file is loaded the progress bar is incremented and the name of the file
> > is displayed in a text control in the middle of the progress bar.  The
> > only problem I'm having is that the progress bar is being displayed on
> > top of the text, so at the moment, I'm having the text below the
> > progress bar, which takes up more space and isn't at pretty.  Soooo ...
> > how do you implement Z-axis ordering?  Thanks!
>
> You can use SetWindowPos to change the zorder.
>
> m_Static.SetWindowPos(&m_Progress,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
>
> But I think you would be happier if you make the static control a child of
> the progress bar.
>
> m_Static.Create(text,style,rect,&m_Progress,ID);


>From the MFC documentation:
BOOL SetWindowPos(
   const CWnd* pWndInsertAfter,
   int x,
   int y,
   int cx,
   int cy,
   UINT nFlags
);

The first parameter would be &wndTop and the last would be
SWP_NOMOVE|SWP_NOSIZE, BUT ...

What do I do for x, y, cx, and cy?  I could take these directly from
Coil.rc but this isn't the elegant way to do it because if I wanted to
relocate this in the future I'd have to change these values in multiple
locations.

Also, the problem with the solutions you're giving me is that they're
all programmatic.  Why in the hell isn't there a way in the resource
editor to right-click on a dialog element and be able to choose Z-axis
options like in PowerPoint?  For God's sakes I can't even see the
static text in the resource editor because it's hidden behind the damn
progress bar!

Also, what is the effect of making the static text a child of the
progress bar?  That looks to me like it's entirely programmatic, i.e.
the static text won't even show up in the resource editor?

0
cyde (46)
8/10/2005 5:18:01 PM
Also, how do I center the "Loading Files" progress bar dialog so that
it is in the center of the main window?  Right now it is somewhere to
the upper left, which doesn't look so pretty.

0
cyde (46)
8/10/2005 5:31:19 PM
> >From the MFC documentation:
> BOOL SetWindowPos(
>    const CWnd* pWndInsertAfter,
>    int x,
>    int y,
>    int cx,
>    int cy,
>    UINT nFlags
> );
>
> The first parameter would be &wndTop and the last would be
> SWP_NOMOVE|SWP_NOSIZE, BUT ...
>
> What do I do for x, y, cx, and cy?  I could take these directly from
> Coil.rc but this isn't the elegant way to do it because if I wanted to
> relocate this in the future I'd have to change these values in multiple
> locations.

The first prarameter wouldn't be &wndTop the first parameter would be the
progress bar, that is what you are trying to place the static control after
(though it won't hurt to be &wndTop).  And as far as x, y, cx, and cy goes
you set them to 0 and specify the SWP_NOMOVE and SWP_NOSIZE and SetWindowPos
will ignore the x, y ,cx, and cy parameters. (Read the docs for
SetWindowPos, sometimes you have to read the SDK docs on functions to get
the real story)

>
> Also, the problem with the solutions you're giving me is that they're
> all programmatic.  Why in the hell isn't there a way in the resource
> editor to right-click on a dialog element and be able to choose Z-axis
> options like in PowerPoint?  For God's sakes I can't even see the
> static text in the resource editor because it's hidden behind the damn
> progress bar!

There is a way you can do it in the resouce editor, and that is by setting
the controls tab order. Press ctrl+D


>
> Also, what is the effect of making the static text a child of the
> progress bar?  That looks to me like it's entirely programmatic, i.e.
> the static text won't even show up in the resource editor?
>

But none of these approaches will give you a sound solution.  The effect of
making the static a child of the progress is the same as making a static a
child of a dialog, the static will never ever be displayed below the dialog!
so by setting the static's parent to the progress, it garauntees that the
static will be on top of the progress. By the way you can call
m_Static.SetParent(m_Progress); to do this when things are begin created
through a dialog template.

Now as far as centering things, the dialog editor will give you two means of
centering things one is Center In Dialog under the format menu, or the
toolbar. This will center any selected control in the dialog template.  The
other is simply Align -Centers, again under the format menu.  This will
center two or more control in relation to each other.  The control that has
the solid resize bars, stays in it's place and the other control will move
to center themselves in relation to that control.
By the way don't forget to set the text alignment property of the static
control to Center.

And also if you end up going with the approach of setting the parent of the
static to the progress then you can simply call m_Static.CenterWindow and it
will center itself within the progrss control.


AliR.


0
AliR3470 (3235)
8/10/2005 7:28:35 PM
Cyde if I may make a suggestion, you really need to by a Visual C++
programming book.

AliR.

"Cyde Weys" <cyde@umd.edu> wrote in message
news:1123695079.457972.242400@g49g2000cwa.googlegroups.com...
> Also, how do I center the "Loading Files" progress bar dialog so that
> it is in the center of the main window?  Right now it is somewhere to
> the upper left, which doesn't look so pretty.
>
>


0
AliR3470 (3235)
8/10/2005 7:35:43 PM
AliR wrote:
> Cyde Weys wrote:
> > Also, the problem with the solutions you're giving me is that they're
> > all programmatic.  Why in the hell isn't there a way in the resource
> > editor to right-click on a dialog element and be able to choose Z-axis
> > options like in PowerPoint?  For God's sakes I can't even see the
> > static text in the resource editor because it's hidden behind the damn
> > progress bar!
>
> There is a way you can do it in the resouce editor, and that is by setting
> the controls tab order. Press ctrl+D

Tried that, didn't work, oh well.

> >
> > Also, what is the effect of making the static text a child of the
> > progress bar?  That looks to me like it's entirely programmatic, i.e.
> > the static text won't even show up in the resource editor?
> >
>
> But none of these approaches will give you a sound solution.  The effect of
> making the static a child of the progress is the same as making a static a
> child of a dialog, the static will never ever be displayed below the dialog!
> so by setting the static's parent to the progress, it garauntees that the
> static will be on top of the progress. By the way you can call
> m_Static.SetParent(m_Progress); to do this when things are begin created
> through a dialog template.

I ended up setting the Static as a child of the ProgressBar and it's
working, with one caveat.  I have the style of the Static set to
"Transparent", but that really just means its background is being set
to the background color of the dialog.  You can see the problem ...
when the progress bar is near empty, it looks fine, but once the
progress bar gets towards full the text is in a little gray box
sticking out like a sore thumb in front of the progress bar.  Is there
a way to make it TRULY transparent so that it will be just the text
with no background?

> Now as far as centering things, the dialog editor will give you two means of
> centering things one is Center In Dialog under the format menu, or the
> toolbar. This will center any selected control in the dialog template.  The
> other is simply Align -Centers, again under the format menu.  This will
> center two or more control in relation to each other.  The control that has
> the solid resize bars, stays in it's place and the other control will move
> to center themselves in relation to that control.
> By the way don't forget to set the text alignment property of the static
> control to Center.

I was referring to centering the entire Progress Bar dialog inside of
the main program's window.  Right now I have Position->Center:TRUE, but
that's centering it over the entire monitor screen, not just the frame
of the application window.

By the way, thanks a lot for your help!

0
cyde (46)
8/10/2005 9:04:43 PM
> I ended up setting the Static as a child of the ProgressBar and it's
> working, with one caveat.  I have the style of the Static set to
> "Transparent", but that really just means its background is being set
> to the background color of the dialog.  You can see the problem ...
> when the progress bar is near empty, it looks fine, but once the
> progress bar gets towards full the text is in a little gray box
> sticking out like a sore thumb in front of the progress bar.  Is there
> a way to make it TRULY transparent so that it will be just the text
> with no background?

I am glad things are woking better for you. If you want a true transparent
static control see my article on Transparent Static

http://www.codeproject.com/staticctrl/TransparentStaticCtrl.asp


> I was referring to centering the entire Progress Bar dialog inside of
> the main program's window.  Right now I have Position->Center:TRUE, but
> that's centering it over the entire monitor screen, not just the frame
> of the application window.
>
> By the way, thanks a lot for your help!
>

Well you can do the same thing with that call CenterWindow() on the Dialog
box.

AliR.


0
AliR3470 (3235)
8/10/2005 10:23:54 PM
AliR wrote:

> I am glad things are woking better for you. If you want a true transparent
> static control see my article on Transparent Static
>
> http://www.codeproject.com/staticctrl/TransparentStaticCtrl.asp

Thank you sooooooo much.  That did the trick perfectly.  I now have a
fully working, aesthetic progress bar with text on it.  I'm wondering
why MFC doesn't have true Transparency in it ... you shouldn't have to
go to third-party classes to get a basic feature working!

> > I was referring to centering the entire Progress Bar dialog inside of
> > the main program's window.  Right now I have Position->Center:TRUE, but
> > that's centering it over the entire monitor screen, not just the frame
> > of the application window.
> >
> > By the way, thanks a lot for your help!
> >
>
> Well you can do the same thing with that call CenterWindow() on the Dialog
> box.

Got that working too.

0
cyde (46)
8/11/2005 3:06:48 PM
Reply:

Similar Artilces:

Purchase Order Suggestion/Question
I would love to see the following option: When I generate Purchase Orders automatically, I take a look at the quantity of product that is generated for the order and decide if I want to place an order or not. If I do decide to place an order, I would like to be able to have the Purchase Order also order everything else that is below the reorder level, but not at the reorder point. Since I'm already placing an order with the vendor, it just makes sense to "top off" everything. The only way I can think to do that now is to make my reorder point quantity one less than my ...

Exporting Partial Purchase Orders from Microsoft RMS to Quickbooks
When you select to export a Quickbooks file in RMS- in SOM Post Closed Batches- it allows you to check a box that states- Include Purchase Orders. I have tested this and I can see that Purchase Orders can be imported into Quickbooks Accounting. However, I cant test or verify that Partial Purchase Orders will be sent over as well. Has anyone tested this? Can anyone verify if Partial Purchase Orders can be sent to Quickbooks via the closing of the batch? Thanks...Andrea No, Partial POs are not posted to QB. Only completed/closed POs. This is at least part of the reason that RMS will ...

Combo Box Null
I want the user to get an error message if they do not choose a value in a combo box. Here's my code, cmbSubGrp is the name of my combo box. What am doing wrong? Dim Itm As Variant If cmbSubGrp.Value = Null Then Itm = MsgBox("You must select a" & _ " Receiving Group!", 0, "No Selection Made") Exit Sub End If "djf" <djf@discussions.microsoft.com> wrote in message news:F6D3F273-FCB9-4B09-88F3-B033575B1F8A@microsoft.com... >I want the user to get an error message if they do not choose a value in...

Outlook 2003 - Pop3 Mode
Outlook 2003 - Pop3 Mode - Manage Multiple Domains in single box/PST. I have moved from an Exchange Server to a standalone Outlook 2003 system. On the exchange server I was able to manage multiple domains and the emails associated with them. I would like to do the same with just the Outlook client in Pop3 mode. I have multiple domain emails forwarding to a single Pop3 mailbox as my ISP. In order to setup the correct "Reply To" field in Outlook I can set up multiple accounts to send out on (by selecting from the drop-down Accounts list). However... The problem is with asso...

Auto-Fit Text Box as Default
In Publisher, can 1 setup "Best-Fit" in textbox auto-fill as default?? As it stands now, I have to go in and change it "per" document, but would like to have this always on for all my new docs Thank you H wood I don't know a way that you can do that. I am confused by the statement that you have to change it "per" document since it is a change that is made per textbox. The problem with making text boxes best fit by default is that they can't be linked to by other text boxes. -- Computing should be about insight, not numbers or flash. "Hwood&...

Creating MFC child dialogs and windows in DLL.
Hi, I need to write some kind of plug-in, which are implemented as separate dll's. I already wrote a few plugins for this program using MFC and it worked ok, but now I need to create some GUI inside a plugin. I have an interface like that class IModule { public: virtual void ShowConfDialog( HWND hwndParent ) = 0; virtual HWND CreatePanel( HWND hwndParent ) =0; // create child window, position and size will be // controlled by a parent window. } But when creating a child windows in MFC I nee...

Is there a trick to making tooltips work in a modal dialog?
Is there a trick to making tooltips work in a modal dialog? It's just a property you set. >-----Original Message----- >Is there a trick to making tooltips work in a modal dialog? > > > > >. > Nothing special. Take a look at example Supertip: http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b188317 You should also check out codeguru and codeproject for samples. -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "Mostly" <Mostly@Work.com> wrote in message news:be5ibd$9gr$1@ctb-nnrp2.saix.net... > Is there a trick to making tooltip...

Drag and Drop target in group box
I've derived from CEdit to make an edit control that can act as an OLE drop target. The control works fine except when placed inside of a group box. In that case, the group box must come AFTER the edit control in the tab order, or else the drop target nature of the edit control is suppressed. Can anyone explain to me why the tab order matters? Thanks, Mark Urish >I've derived from CEdit to make an edit control that can act as an OLE drop >target. The control works fine except when placed inside of a group box. In >that case, the group box must come AFTER the edit cont...

Menu placement in Dialog
Hi people I want to place the menu on to a desired location in my dialog based application.By defualt if we add a menu resource to a dialog it is placed on the top left corner of the dialog.Is there any way to place it in any position in a dialog based application?? Thanking you in anticipation Tauseef tauseef_hasan@yahoo.com (Tauseef) wrote in message news:<d51f87f6.0405250205.80110d3@posting.google.com>... > Hi people > I want to place the menu on to a desired location > in my dialog based application.By defualt if we > add a menu resource to a dialog it is placed on th...

Color Selector Dialog
I am interested in developing an application, which requires a color selector dialog (perhaps a Color wheel )through which the user can select any System Color.? How is the MFC way of implementing this..? Thanks in Advance!! >I am interested in developing an application, which requires a color selector >dialog (perhaps a Color wheel )through which the user can select any System >Color.? >How is the MFC way of implementing this..? Have you tried MFC's CColorDialog? Dave Also, the new Feature Pack has a color picker button control: http://msdn.microsoft.com/en-us/libra...

MFC Dialog based application with a notification icon
Hi, I would like to create a MFC dialog based application with a notification tray icon next to the clock in the taskbar. I have been able to set the notification tray icon using the Shell_NotifyIcon API. Also, when I run the application, I don't want the dialog to be display first. I want the icon in the notification area to come first and when the user double clicks on the icon in the notification area, I would like to display the dialog. What should I modify in the InitIntance of the CWinApp class to change the default behavior (i.e. dlg.DoModal()) to achieve this? Thanks Asho...

Need a report to print fields in Excel in a certain order
I've got a client that needs the data we collect to show up in a certain order in an excel speadsheet. Instead of my having to rewrite and reorganized the form that the data is collected I'd like to know if there's a way for me to export the data in the order they want to see it. Can this be done using the report tab from access? and if it can how do I go about to do it? Just to let you know I'm not that experienced in programming and stuff so I'll need step by step directions. Thanks for your help in advance. Ace MJ Waldor -- Your One Stop Public Reco...

Format Picture Dialog Box Placement
PowerPoint 2003 on XP. Since a recent rebuild, evey time I press Format Picture/Object the dialog box appears over to the left of my screen and will not remember where I move it to like it used to. Is it possible to reset this so it does remember where I need the dialog box to appear? Is this a registry edit? Many thanks DeanH ...

box border shadow problem in Excel 2007, is it fixed in Excel 2010?
Does anyone know if Excel 2010 fixes the problem with border shadows that Excel 2007 had? It worked fine in 2003 and previous versions but for some reason when you create a box around some data and add a shadow, it doesn't really work properly and even drops the shadow at the top and left in a transparent box whereas it should only drop shadows on bottom and right side. ...

Query Source for Text Box
Hi, I'm trying to set the value of a text cell as the sum of the values in one table with conditions based on returned values from linked tables: =DSum("V","T1","(SELECT Sum(Value) AS V FROM CostTypeLook INNER JOIN (CCLook INNER JOIN CostBase ON (CCLook.[Cost Centre] = CostBase.[Cost Centre]) AND (CCLook.Co = CostBase.Co)) ON (CostTypeLook.Account = CostBase.Account) AND (CostTypeLook.Co = CostBase.Co) WHERE CostTypeLook.[Cost Type]=10 AND CCLook.Flag='NP') AS T1") But of course it isn't working which is why I'm having to ask...

Add consecutive dates w/ command button & parameter boxes
Hi, I have an unbound form [Frm Volunteer Opportunities] with a sub form [SubFrm Vol Opportunities]. The subform has the fields [Event ID] and [Event Date]. My unbound form has a command button on it. Basically, what I’m trying to do is have Access automatically create 31 new records in [SubFrm Vol Opportunities] whenever I click the button. I want each new record to be dated 5/1/2010, 5/2/2010, 5/3/2010, and so on starting and ending with the dates that I provide in pop-up parameter boxes. Unfortunately, I don't know code although I can probably figure out where to ...

Bug in creating new item in Purchase order module?
I noticed that items created in the purchase order module do not seem to be properly configured with their supplier. While the item window correctly displays the supplier, an items report that includes the supplier field does not include the new items with the designated supplier. On the other hand, any items created through the items menu appear correctly in the reports. Similarly, when barcode labels that include supplier name as one of the fields are printed, the supplier name appears for those items not created in the PO module. Those items created in the PO module do not display...

Check Box with a Bitmap
Hello everybody, I've got the following question: I would like to use a check box with the BS_AUTOCHECK,BS_PUSHLIKE style. Furthermore I want to display a bitmap (bitmap1) on top of this check box - button. When I push the button it should show me another bitmap (bitmap2). Pushing again should show me the first one again... -> use as a toogle. But I can't get it to work. Trying with 2 strings -> no problem. With SetBitmap() and 2 bitmaps -> no failure, but also no bitmaps displayed. Somebody an idea? It would help if you gave it the BS_BITMAP style. "Paul C." &...

Where is the split box in Excel 2007?
Hi, I feel really dumb having to ask this question, but I don't see the split boxes on the scroll bars anymore - do they exist in Excel 2007? According to Help they do. I've looked at Excel Options, but can't find where this would be an option that has to be turned on. Anyone know the answer?? Thanks! Okay - just found a "Split" button on the Ribbon. Sure would be nice if Help said that the feature now has to be turned on through the Ribbon first. I knew I hated to ask this question. Thanks! "Tammy" wrote: > Hi, > > I feel really dumb having...

How to correctly scale X-Axis in Charts?
I posted this in Excel Charting, too, but I reckon it gets far fewer readers... I have the following data to plot: 01/31/95 0.29623 12/29/95 0.19822 12/31/96 0.13931 12/31/97 0.33036 12/31/98 0.082194 12/31/99 0.23669 12/29/00 -0.25575 12/31/01 0.023404 12/31/02 -0.11949 12/31/03 -0.018228 12/31/04 0.12326 with the dates being the actual dates I wish to plot on my x-axis in a regular Excel line chart. As you can see, they are irregular dates. Regardless of how I try (with ensuring the Minor Unit is on Days and the Major on months), I can't seem to get the right combination to have Exc...

Transferring Dialog/resources/files from one project to another.
Hi, I am in the process of writing an MFC dialog app. I would like to use a couple of dialogs that i created in another VC++ 6.0 MFC Dialog project. I am having difficulty copying these from one project to another. I have tried to copy the .rc file and resource.h file into my application but i am finding this does not import the dialogs that i want. Does anyone know how to do this? Regards Macca U�ytkownik "Macca" <Macca@discussions.microsoft.com> napisa� w wiadomo�ci news:F799F0BB-B9D9-4267-9F14-0B9EC8DFA860@microsoft.com... > Hi, > > I am in the process of...

I need a logoff script (with conditions and cancellation dialog box)
Platform: Windows XP SP3, domain workstation. I need a script that: 1. Checks the username of the logged on user. - If the user is one of two specific users, it logs them off immediately. - If the user is not one of two specific users, proceed to step 2. 2. Display a dialog box with a timer ticking down the seconds from 20 minutes. Also in the dialog box, show the caption, "Unless the countdown is cancelled, the user will be automatically logged off." At the bottom of the dialog box, show a button that reads "Cancel Logoff". - If the button is clicked, the ...

Reopen a closed Manufacturing Order?
An MO was closed before labor was entered. Can we reopen the MO to add the labor? -- Amy Sorry, no...short of restoring the db from backup. -- Richard L. Whaley Author / Consultant / MVP 2006-2008 Documentation for Software Users Get our Free Tips and Tricks Newsletter and check out our books at http://www.AccoladePublications.com "Amy" wrote: > An MO was closed before labor was entered. Can we reopen the MO to add the > labor? > -- > Amy ...

Dynamic chart and shrinking text boxes
Good afternoon all, I have a dynamic chart, that records the amount of forms processed eac week. Every Friday, I coallate the statistics for the past week, an input them in, and the chart then grows by one week. Perfectly norma stuff, documented regularly. What I need to know, is, if it is possible to link outside objects t parts of the chart. Example. During 02/01/04 and 23/01/04 we were down 1 FTE (full tim equivalent), and I have a text box between those dates indicating this The problem is, when I add on a new week (for example, Week Endin 06/02/04) all the dates shift backwards, and I ...

Negative On Order quantity
What would cause the On Order quantity to go negative for an item? How can we get it back to the true quantity (i.e., what has been ordered via POs, but hasn't been received yet)? I tried running the Purchasing reconcile for the vendor and the Inventory reconcile for the item, but it had no effect. -- Bud Cool, Accounting System Manager HDA, Inc. Hazelwood, MO GP 9.0, SP2 I ran the Inventory reconcile routine in our test company and it did, in fact, correct the On Order quantity. But, my original question still stands - how can On Order go negative?? -- Bud Cool, Accounting Syst...