Controls in a property sheet, outside property pages 
Author Message
 Controls in a property sheet, outside property pages

I'm trying to build a property sheet, and I'm baffled by one thing:
how to create controls (e.g., OK and Cancel buttons) that are in the
property sheet, but outside the property pages.

I'm following example 12A in "Inside Visual C++" by David Kruglinski.
The example shows such buttons, but I can't figure out where they come
from.

It seems to me that there are two possibilities. First, they're added
at run time. But I can't find code to do that in the example. Second,
they're part of a dialog template used to create the property sheet
itself. But Kruglinski's outline says "Use ClassWizard to generate a
single class derived from CPropertySheet" -- with no mention of a
template. Nor can I find a reference to a template in the code.

What am I missing here?
- -
Jonathan Sachs
Sand River Software, Inc.



Wed, 14 Jun 2000 03:00:00 GMT  
 Controls in a property sheet, outside property pages

I think I now understand the problem better. It's different, and
worse, than I thought.

I approached this project thinking of a "property sheet" as a control
which one adds to a dialog box; then one adds pages to the property
sheet and defines controls in them. When I found no "property sheet"
control in the editor's palette I read some documentation and thought
I had to make just a small adjustment in my mental model: in MFC
terminology the dialog box containing the pages was the "property
sheet," and the pages were defined as separate dialog boxes. Then I
was puzzled by the instructions for putting it all together, which
seemed to ignore the (to me) obvious necessity of identifying the
property sheet template one had defined, since it contained the
controls.

When I couldn't find a solution to the problem as I conceived it I
resorted to VB for Applications as a design tool so that I could
define my user interface while I worked out the technical issues with
MFC. My misunderstanding was reinforced by the fact that in VBA
property sheets work almost exactly as I expected.

Now it appears to me that in MFC the architecture is completely
different: the dialog editor can't be used to define a property sheet
at all, because a property sheet has no template. MFC simply makes the
property sheet big enough to hold the property pages that are added to
it at run time. The position of the property page stack is fixed. So
are the positions and functions of the OK, Cancel, and Apply buttons.

This is a little staggering to me, since I'm used to thinking of MFC
as The Answer whenever VB[A] doesn't allow me to do what I need. Now,
right at the start of my first real MFC project, I've hit something
basic to my design that VBA makes easy and MFC makes very difficult.

It seems that to make the property sheet look the way I want I'll need
to hide the three standard buttons, resize the property sheet,
reposition the property pages, and add the other controls I need --
all at run time.

But wait, it gets worse. My application requires *two* stacks of
property pages in the same dialog box (actually, in the same
CFormView, as this is to be my app's main window). As I add them, how
can I tell the property sheet which ones belong together? Well, maybe
by repositioning each page to the coordinates of one or the other page
stack.

But the property sheet's methods seem to assume that the pages form a
single stack. I keep reading stuff like: "Property sheet pages are not
physically created until they are activated by the person using the
property sheet." So if MFC thinks page A is "on top" it will create
page A when it creates the property sheet, ignoring the fact that page
A is on top of one page stack, and page X is on top of the other
stack. What can I do about that? Well, maybe I can force MFC to create
both pages by selecting each in turn in OnInit.

But what will happen when MFC thinks that one stack's top page is "the
one on top" and the user does something to a control in the other
stack's top page? Or when the other stack's top page is covered, then
uncovered, and has to be repainted? And so on.

Each of these potential problems could turn out to be benign or
solvable, but there are so many potential causes of trouble that I
have grave doubts that my user interface can be implemented with
CPropertyPage at all.

I'm kind of at a loss right now. Should I resort to VB for the user
interface part of my app? Or look for tricks that will make
CPropertySheet work for me? Or try to splice together two property
sheets and some dialog boxes so that to the user they look like a
single (nonmodal) box? Or write my own custom version of
CPropertySheet that supports multiple page stacks? Or try to find a
custom version of  CPropertySheet that somebody else has already
written?

Suggestions are welcome.
- -
Jonathan Sachs
Sand River Software, Inc.



Thu, 15 Jun 2000 03:00:00 GMT  
 Controls in a property sheet, outside property pages

Whoa, Whoa, Whoa.
Think for a second... MFC vs. VB???!!!!
There is no competition.  Sure, MFC is a bit tough for VB users because
it isn't visual.  Even if it says Visual C++, it just isn't!!
That's the way C/C++ was made to be and it will always be that way.

I would suggest the following: READ UP MORE ON PROPERTY SHEETS!!
Directly from the VC++ 5.0 Help is this:

"By default, a property sheet allocates window area for the property
pages, the tab index, and the OK, Cancel, and Apply buttons. (A modeless
property sheet does not have the OK, Cancel, and Apply buttons.) You can
add other controls to the property sheet. For example, you can add a
preview window to the right of the property page area to show the user
what the current settings would look like if applied to an external
object."

To get to this page, do the following (remember, you must have created a
CPropertySheet object and added CPropertyPage objects to it for this to
work):

1. Click the Search Help Icon to the left of the Contents drop-down box.
2. Type the following: "Property Sheets" with the trailing 's' or else
you'll be taken somewhere else
3. Double-click what should be the 3rd option (depending on how your
topics list box is sorted - mine is by title, the default way) under the
Title display called "Property Sheet Topics".
4. Click the 9th link where all the links are called "How to add
controls to a property sheet (as opposed to a property page)"

Read up on this stuff a little more carefully - remember: it can be
done.

--

*********************************************
**       From the Mind of Shaheen          **

**    ------------------------------       **
** You can never take life too seriously.  **
**    You'll never get out of it alive.    **
*********************************************



Thu, 15 Jun 2000 03:00:00 GMT  
 Controls in a property sheet, outside property pages

I appreciate the time you've taken to offer a suggestion, but I think
you've forgotten how unhelpful Microsoft's documentation is to those
who, unlike you, need information about concepts rather than details
about implementation.

You told me to read the documentation and gave step by step
instructions for reaching it, with the caution: "remember, you must
have created a CPropertySheet object and added CPropertyPage objects
to it for this to work."

But the documentation I *have* found appears to say that it is
impossible to add a property page to a property sheet except in the
IDE -- and certainly gives me no clue how to do so.

In other words, I'm stuck in the catch-22 that afflicts most beginning
users of MFC: the help is meaningless, or is not even accessible,
unless I already know what I'm trying to find out.

If you can suggest a source of information that does not have that
weakness, I'll be grateful.
- -
Jonathan Sachs
Sand River Software, Inc.
To email me, replace the 'x' with an 'a'.



Fri, 16 Jun 2000 03:00:00 GMT  
 Controls in a property sheet, outside property pages

Jonathan,

I don't have an answer to all your questions, but I've recently found
that you can embed a property sheet into a dialog.

Have a look at the SNAPVW sample - it uses a modeless property sheet
as the main view in an MDI application, but the same technique lets
you embed a modeless property sheet (only the tabs & pages show)
inside a dialog box. I use a dummy hidden control in the dialog to get
a design-time position for the property sheet and position the sheet
at run-time over this dummy hidden control.

I'm only starting on this myself, so I can't say much more than it
appears to do the sort of thing you describe (that's so easy to do in
VB). As I've not got any further than that myself, I can't say if
there are any gotcha's to this method.

Dave
----
Address is altered to discourage junk mail.
Remove ".---" for the real address.



Fri, 16 Jun 2000 03:00:00 GMT  
 Controls in a property sheet, outside property pages

The first version of this reply (now cancelled) contained a one-word
typo that reversed the meaning of a critical phrase. My apologies for
any confusion this caused.

I appreciate the time you've taken to offer a suggestion, but I think
you've forgotten how unhelpful Microsoft's documentation is to those
who, unlike you, need information about concepts rather than details
about implementation.

You told me to read the documentation and gave step by step
instructions for reaching it, with the caution: "remember, you must
have created a CPropertySheet object and added CPropertyPage objects
to it for this to work."

But the documentation I *have* found appears to say that it is
impossible to add a property page to a property sheet in the IDE --
and certainly gives me no clue how to do so.

In other words, I'm stuck in the catch-22 that afflicts most beginning
users of MFC: the help is meaningless, or is not even accessible,
unless I already know what I'm trying to find out.

If you can suggest a source of information that does not have that
weakness, I'll be grateful.
- -
Jonathan Sachs
Sand River Software, Inc.
To email me, replace the 'x' with an 'a'.



Fri, 16 Jun 2000 03:00:00 GMT  
 Controls in a property sheet, outside property pages



Quote:
>I appreciate the time you've taken to offer a suggestion, but I think
>you've forgotten how unhelpful Microsoft's documentation is to those
>who, unlike you, need information about concepts rather than details
>about implementation.

In MS help form VC++ 5.0 There are 3 lines about you problem. :) I
think you miss it. For insert a controls outside property page you
need do follow steps:
1. Determinate place where You would like to insert control. You can
do it base on already present buttons (>> << Finish, and so on)

2. Create a control with function CreateWindow( ...,
"YOURCONTROLCLASS",... hParentWnd);

Please, notice, that hParentWnd - id handle of Yours propertysheet
window.

3.
  Set the same fornt as the property sheet have, You can do this by
following next lines:
 HFONT hFont = SendMessage(hPropertySheet,WM_GETFONT,....)
 SendMessage(hMyControl,WM_SETFONT,(WPARAM) hFont,...)

4. Call ShowWindow to visualise your control

Tha's all
Hapy New Year.
PS. Pardon for my bad English

Quote:
>You told me to read the documentation and gave step by step
>instructions for reaching it, with the caution: "remember, you must
>have created a CPropertySheet object and added CPropertyPage objects
>to it for this to work."

>But the documentation I *have* found appears to say that it is
>impossible to add a property page to a property sheet except in the
>IDE -- and certainly gives me no clue how to do so.

>In other words, I'm stuck in the catch-22 that afflicts most beginning
>users of MFC: the help is meaningless, or is not even accessible,
>unless I already know what I'm trying to find out.

>If you can suggest a source of information that does not have that
>weakness, I'll be grateful.
>- -
>Jonathan Sachs
>Sand River Software, Inc.
>To email me, replace the 'x' with an 'a'.



Sat, 17 Jun 2000 03:00:00 GMT  
 Controls in a property sheet, outside property pages

Might I also suggest you take a look at the FIRE example included with
VC++. It shows how to use the tab control in a dialog, which is probably
not quite what you want.

I would also suggest you take a look at http://www.codeguru.com in the
Property Sheets section. There's examples of how to move, resize, and
add controls to a property sheet as well as how to create a property
sheet inside a dialog.

I would strongly recommend that you get comfortable creating a standard
property sheet with standard property pages in MFC before you try to do
the special stuff you want. Once you understand the basic principles of
property sheets in MFC, it'll be easier to understand the special stuff
you want to do.

Ken



Sun, 18 Jun 2000 03:00:00 GMT  
 Controls in a property sheet, outside property pages

Here is a portion of code I use in my property sheets (it creates a
tabbed dialog box with "pages" for XY plot options and polar plot
options):

COptionSheet:COptionSheet(UINT  nIDCaption,
                          CWnd* pParentWnd,
                          UINT  iSelectPage)
    : CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
    // create the pages (dialog boxes)
    m_pXYOptionPage    = new CXYOptionPage(this);
    m_pPolarOptionPage = new CPolarOptionPage(this);

    // add the pages to the sheet
    this->AddPage(m_pXYOptionPage);
    this->AddPage(m_pPolarOptionPage);

Quote:
}

where CXYOptionPage and CPolarOptionPage are handlers for dialog boxes I
created through the resource editor.  They should/must have the
following attributes (properties):
  General              More Styles
     Style: child         x  Visible
     Border: thin         x  Disabled
       x  Title Bar
       x  System menu

The "sheet" creates the two "pages" (dialog boxes) and "adds" them to
itself, creating the property sheet.  Note that if there are "global" OK
or Cancel buttons, you must provide them yourself *OR* add them to EVERY
individual page/dialog box.

May not be the most elegant, but it works!!

Bill Stevener

Quote:

> I think I now understand the problem better. It's different, and
> worse, than I thought.

> I approached this project thinking of a "property sheet" as a control
> which one adds to a dialog box; then one adds pages to the property
> sheet and defines controls in them. When I found no "property sheet"
> control in the editor's palette I read some documentation and thought
> I had to make just a small adjustment in my mental model: in MFC
> terminology the dialog box containing the pages was the "property
> sheet," and the pages were defined as separate dialog boxes. Then I
> was puzzled by the instructions for putting it all together, which
> seemed to ignore the (to me) obvious necessity of identifying the
> property sheet template one had defined, since it contained the
> controls.

> When I couldn't find a solution to the problem as I conceived it I
> resorted to VB for Applications as a design tool so that I could
> define my user interface while I worked out the technical issues with
> MFC. My misunderstanding was reinforced by the fact that in VBA
> property sheets work almost exactly as I expected.

> Now it appears to me that in MFC the architecture is completely
> different: the dialog editor can't be used to define a property sheet
> at all, because a property sheet has no template. MFC simply makes the
> property sheet big enough to hold the property pages that are added to
> it at run time. The position of the property page stack is fixed. So
> are the positions and functions of the OK, Cancel, and Apply buttons.

> This is a little staggering to me, since I'm used to thinking of MFC
> as The Answer whenever VB[A] doesn't allow me to do what I need. Now,
> right at the start of my first real MFC project, I've hit something
> basic to my design that VBA makes easy and MFC makes very difficult.

> It seems that to make the property sheet look the way I want I'll need
> to hide the three standard buttons, resize the property sheet,
> reposition the property pages, and add the other controls I need --
> all at run time.

> But wait, it gets worse. My application requires *two* stacks of
> property pages in the same dialog box (actually, in the same
> CFormView, as this is to be my app's main window). As I add them, how
> can I tell the property sheet which ones belong together? Well, maybe
> by repositioning each page to the coordinates of one or the other page
> stack.

> But the property sheet's methods seem to assume that the pages form a
> single stack. I keep reading stuff like: "Property sheet pages are not
> physically created until they are activated by the person using the
> property sheet." So if MFC thinks page A is "on top" it will create
> page A when it creates the property sheet, ignoring the fact that page
> A is on top of one page stack, and page X is on top of the other
> stack. What can I do about that? Well, maybe I can force MFC to create
> both pages by selecting each in turn in OnInit.

> But what will happen when MFC thinks that one stack's top page is "the
> one on top" and the user does something to a control in the other
> stack's top page? Or when the other stack's top page is covered, then
> uncovered, and has to be repainted? And so on.

> Each of these potential problems could turn out to be benign or
> solvable, but there are so many potential causes of trouble that I
> have grave doubts that my user interface can be implemented with
> CPropertyPage at all.

> I'm kind of at a loss right now. Should I resort to VB for the user
> interface part of my app? Or look for tricks that will make
> CPropertySheet work for me? Or try to splice together two property
> sheets and some dialog boxes so that to the user they look like a
> single (nonmodal) box? Or write my own custom version of
> CPropertySheet that supports multiple page stacks? Or try to find a
> custom version of  CPropertySheet that somebody else has already
> written?

> Suggestions are welcome.
> - -
> Jonathan Sachs
> Sand River Software, Inc.



Sun, 18 Jun 2000 03:00:00 GMT  
 Controls in a property sheet, outside property pages

Jonathan,

Here is a portion of code I use in my property sheets (it creates a
tabbed dialog box with "pages" for XY plot options and polar plot
options):

COptionSheet:COptionSheet(UINT  nIDCaption,
                          CWnd* pParentWnd,
                          UINT  iSelectPage)
    : CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
    // create the pages (dialog boxes)
    m_pXYOptionPage    = new CXYOptionPage(this);
    m_pPolarOptionPage = new CPolarOptionPage(this);

    // add the pages to the sheet
    this->AddPage(m_pXYOptionPage);
    this->AddPage(m_pPolarOptionPage);

Quote:
}

where CXYOptionPage and CPolarOptionPage are handlers for dialog boxes I
created through the resource editor.  They should/must have the
following attributes (properties):
  General              More Styles
     Style: child         x  Visible
     Border: thin         x  Disabled
       x  Title Bar
       x  System menu

The "sheet" creates the two "pages" (dialog boxes) and "adds" them to
itself, creating the property sheet.  Note that if there are "global" OK
or Cancel buttons, you must provide them yourself *OR* add them to EVERY
individual page/dialog box.

May not be the most elegant, but it works!!

Bill Stevener
----------------

Quote:

> I think I now understand the problem better. It's different, and
> worse, than I thought.

> I approached this project thinking of a "property sheet" as a control
> which one adds to a dialog box; then one adds pages to the property
> sheet and defines controls in them. When I found no "property sheet"
> control in the editor's palette I read some documentation and thought
> I had to make just a small adjustment in my mental model: in MFC
> terminology the dialog box containing the pages was the "property
> sheet," and the pages were defined as separate dialog boxes. Then I
> was puzzled by the instructions for putting it all together, which
> seemed to ignore the (to me) obvious necessity of identifying the
> property sheet template one had defined, since it contained the
> controls.

> When I couldn't find a solution to the problem as I conceived it I
> resorted to VB for Applications as a design tool so that I could
> define my user interface while I worked out the technical issues with
> MFC. My misunderstanding was reinforced by the fact that in VBA
> property sheets work almost exactly as I expected.

> Now it appears to me that in MFC the architecture is completely
> different: the dialog editor can't be used to define a property sheet
> at all, because a property sheet has no template. MFC simply makes the
> property sheet big enough to hold the property pages that are added to
> it at run time. The position of the property page stack is fixed. So
> are the positions and functions of the OK, Cancel, and Apply buttons.

> This is a little staggering to me, since I'm used to thinking of MFC
> as The Answer whenever VB[A] doesn't allow me to do what I need. Now,
> right at the start of my first real MFC project, I've hit something
> basic to my design that VBA makes easy and MFC makes very difficult.

> It seems that to make the property sheet look the way I want I'll need
> to hide the three standard buttons, resize the property sheet,
> reposition the property pages, and add the other controls I need --
> all at run time.

> But wait, it gets worse. My application requires *two* stacks of
> property pages in the same dialog box (actually, in the same
> CFormView, as this is to be my app's main window). As I add them, how
> can I tell the property sheet which ones belong together? Well, maybe
> by repositioning each page to the coordinates of one or the other page
> stack.

> But the property sheet's methods seem to assume that the pages form a
> single stack. I keep reading stuff like: "Property sheet pages are not
> physically created until they are activated by the person using the
> property sheet." So if MFC thinks page A is "on top" it will create
> page A when it creates the property sheet, ignoring the fact that page
> A is on top of one page stack, and page X is on top of the other
> stack. What can I do about that? Well, maybe I can force MFC to create
> both pages by selecting each in turn in OnInit.

> But what will happen when MFC thinks that one stack's top page is "the
> one on top" and the user does something to a control in the other
> stack's top page? Or when the other stack's top page is covered, then
> uncovered, and has to be repainted? And so on.

> Each of these potential problems could turn out to be benign or
> solvable, but there are so many potential causes of trouble that I
> have grave doubts that my user interface can be implemented with
> CPropertyPage at all.

> I'm kind of at a loss right now. Should I resort to VB for the user
> interface part of my app? Or look for tricks that will make
> CPropertySheet work for me? Or try to splice together two property
> sheets and some dialog boxes so that to the user they look like a
> single (nonmodal) box? Or write my own custom version of
> CPropertySheet that supports multiple page stacks? Or try to find a
> custom version of  CPropertySheet that somebody else has already
> written?

> Suggestions are welcome.
> - -
> Jonathan Sachs
> Sand River Software, Inc.



Sun, 18 Jun 2000 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Sample: Manipulating controls on property page/Property Sheet

2. Property Sheet and Property pages in ATL

3. How to disable property page on property sheet.

4. Property sheet in a property page

5. Property pages disappearing from property sheet on selection

6. questions regarding property sheet and property page

7. Problem with same property page in multiple property sheets

8. Sizing Property Sheets/Property Pages

9. Problems with property sheets and property pages

10. Property Sheet and Property Pages

11. Property Sheet on Property Page?

12. resizable property sheet and property page

 

 
Powered by phpBB® Forum Software