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

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




> >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.


.



Relevant Pages

  • Re: How can I use C# GUI component in my MFC application.
    ... Here's some stuff I had written on this topic for my book (Extending MFC ... Using a .NET control in an MFC dialog ... we have seen how Windows Forms makes GUI development slightly easier ... BOOL Create(CWnd* pWnd, int x, int y, int cx, int cy); ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Repost for MS: UnsafeNativeMethods.CallWindowProc NullReferenc
    ... The error message that led me to my solution was "Cannot call Dispose while ... Using the .NET Reflector to look at the Control ... NativeWindow has a pointer to a previous window and a pointer to a next ... hWnd, int msg, int wparam, int lparam) + 0x30 bytes ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Question about printing
    ... int nXDest, // x-coord of destination upper-left corner ... > control and graphics can not be drawed with this class. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Possible to pass strings back to ASP from ActriveX?
    ... afx_msg int AboutBox; ... helpstring("AxTemplateTest1 ActiveX Control module"), ... // Primary dispatch interface for CAxTemplateTest1Ctrl ... helpstring("Dispatch interface for AxTemplateTest1 Control")] ...
    (microsoft.public.windowsce.embedded)
  • Re: Possible to pass strings back to ASP from ActriveX?
    ... afx_msg int AboutBox; ... helpstring("AxTemplateTest1 ActiveX Control module"), ... // Primary dispatch interface for CAxTemplateTest1Ctrl ... helpstring("Dispatch interface for AxTemplateTest1 Control")] ...
    (microsoft.public.windowsce.embedded)