15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


CPropertySheet question

runefr@ifi.uio.no
Friday, September 15, 1995

I'm working on a MDI project, using Visual C++ v2.1 and MFC.

How can I put a CComboBox (or an other control) on the top of a
CPropertySheet, so that it is available from all the CPropertyPages?
(Is it possible to draw a complete PropertySheet within the Dialog Editor,
without creating a CPropertyPage-derived class corresponding to each
property page dialog template, as described in the article "Property
Sheets" in "Programming with the Microsoft Foundation Class library"?)



LeRoy Baxter -- lbaxter@tcinfo.com
Friday, September 15, 1995

question 1 - yes you can put a combobox on the sheet - see the Propdlg
	sample that comes with VC++

question 2 - no, the PropertySheet acts as a frame around the
	PropertyPage. Only the pages get defined as dialogs - the sheet
	is dynamic. If you did not define a page in the dialog editor,
	you would need to do all the handling dynamically - a true
	mess.

note: you instantiate a PropertySheet, and then add each page to it -
	the sheet recalculates itself for each page you add.

What is it that you are really trying to accomplish?

----------
From: 	Rune Fr=F8ysa[SMTP:runefr@ifi.uio.no]
Sent: 	Friday, September 15, 1995 6:01 AM
To: 	mfc-l@netcom.com
Subject: 	CPropertySheet question

I'm working on a MDI project, using Visual C++ v2.1 and MFC.

How can I put a CComboBox (or an other control) on the top of a
CPropertySheet, so that it is available from all the CPropertyPages?
(Is it possible to draw a complete PropertySheet within the Dialog =
Editor,
without creating a CPropertyPage-derived class corresponding to each
property page dialog template, as described in the article "Property
Sheets" in "Programming with the Microsoft Foundation Class library"?)






Rick Esterling -- rick@eco.twg.com
Friday, September 15, 1995

On 15 Sep 95 at 15:01, =?iso-8859-1?Q?Rune_Fr=F8ysa? wrote:

> How can I put a CComboBox (or an other control) on the top of a
> CPropertySheet, so that it is available from all the
> CPropertyPages? (Is it possible to draw a complete PropertySheet
> within the Dialog Editor, without creating a CPropertyPage-derived
> class corresponding to each property page dialog template, as
> described in the article "Property Sheets" in "Programming with
> the Microsoft Foundation Class library"?)

If I understand your request correctly, all you need to do is
derive a class from CPropertySheet, instantiate an object of this
new class, and then call Create() instead of DoModal() to start
the object.  By calling Create() versus DoModal(), you won't get
any of the standard buttons that are normally included with a
CPropertySheet-derived object - you'll have to create those buttons
yourself in OnCreate().  You can also create your combo box there
and resize your CPropertySheet-derived object there, too.  Consider
the following snippet which only adds the default buttons - you'll 
have to decide how/where to put your combo box and the new size of 
the sheet-derived object required to accommodate that control: 

int CMySheet::OnCreate(LPCREATESTRUCT lpCreateStruct) {
   TRACE0( "CMySheet::OnCreate()\n" );

   if (CPropertySheet::OnCreate(lpCreateStruct) == -1)
      return -1;
   
   // Get the dimensions of the CMySheet window.
   CRect rcSheet;
   GetWindowRect( &rcSheet );
   ScreenToClient( &rcSheet );
   
   // Get the dimensions of the first CPropertyPage object
   CRect rcPage;
   m_pgMyPage->GetWindowRect( &rcPage );
   ScreenToClient( &rcPage );

   int btnTop = rcPage.bottom + 10;
   // The GetSystemMetrics() call is to substract whatever heighth is
   // being consumed by the DLG frame itself.
   int btnBottom = rcSheet.bottom - 10 - GetSystemMetrics( SM_CYDLGFRAME );
   
   // Compute the locations of the buttons based on the dimensions of
   // the CPropertySheet object and the CPropertyPage objects.  The rules
   // I'm using for the buttons are:
   //
   //    o  The top of each button is 10 pixels down from the CPropertyPage 
   // object.
   //    o  The bottom is 10 pixels up from the CPropertySheet object (not 
   // including the frame).
   //    o  Each button is 88 pixels wide.
   //    o  The right side of the Help button is lined up with the right side
   // of the CPropertyPage objects.
   //    o  The buttons are separated by 7 pixels (width).
   
   CRect rcHelp( rcPage.right - 88, btnTop, rcPage.right, btnBottom );
   CRect rcApply( rcHelp.left - 95, btnTop, rcHelp.left - 7, btnBottom );
   CRect rcCancel( rcApply.left - 95, btnTop, rcApply.left - 7, btnBottom );
   CRect rcOK( rcCancel.left - 95, btnTop, rcCancel.left - 7, btnBottom );
   
   // Create all three buttons
   m_BtnOK.Create( "&OK", WS_CHILD | WS_VISIBLE | WS_TABSTOP | 
                   BS_DEFPUSHBUTTON, rcOK, this, IDC_BTN_OK );
   
   m_BtnCancel.Create( "&Cancel", WS_CHILD | WS_VISIBLE | WS_TABSTOP |
                       BS_PUSHBUTTON, rcCancel, this, IDC_BTN_CANCEL );
   
   // This button starts out disabled.
   m_BtnApply.Create( "&Apply Now", WS_CHILD | WS_VISIBLE | WS_TABSTOP |
                      WS_DISABLED | BS_PUSHBUTTON, rcApply, this, 
                      IDC_BTN_APPLY );
   
   // This button is disabled until the Help file is finished.
   m_BtnHelp.Create( "&Help", WS_CHILD | WS_VISIBLE | WS_TABSTOP |
                      BS_PUSHBUTTON, rcHelp, this, IDC_BTN_HELP );
                      
   // Put the sheet object on the screen
   ShowWindow( SW_NORMAL );
   

   return 0;
}

Hope that helps,
Rick Esterling                     The Wollongong Group, Inc.
Senior Software Engineer           McLean, VA
http://widget.eco.twg.com:1080     http://www.twg.com



Amir Shoval -- torin@netvision.net.il
Thursday, November 07, 1996

Hello,

Environment: Win 95, VC++ 4.2b

I use MFC's CPropertySheet to create a multiple paged property sheet.
All is well until I try to set an extended style to one of the dialogs
which is one of the sheet's pages (or to one of the controls on it).

At run time I get ASSERTed at dlgprop.cpp line 238. The remark before
that line is quite clear:

// WINBUG: Windows currently does not support DIALOGEX resources!
// Assert that the template is *not* a DIALOGEX template.
// DIALOGEX templates are not supported by the PropertySheet API.

// To change a DIALOGEX template back to a DIALOG template,
// remove the following:
//  1. Extended styles on the dialog
//  2. Help IDs on any control in the dialog
//  3. Control IDs that are DWORDs
//  4. Weight, italic, or charset attributes on the dialog's font

My question is, how - inspite the above - can I create a property sheet
which pages DO contain such things (extended styles, Help IDs etc.)?

I know IT IS possible in windows (so it's not a WINBUG but and MFCBUG).
Does the meaning of this I have to implement my own property sheet
class?

	thanx,
		Amir

-- 
--------------------------
Amir Shoval N.C.C. Israel
torin@netvision.net.il
--------------------------



David Lowndes -- David.Lowndes@bj.co.uk
Friday, November 08, 1996

[Mini-digest: 3 responses]

Amir,

> My question is, how - inspite the above - can I create a property sheet
which pages DO contain such things (extended styles, Help IDs etc.)?
<

Modify the property sheet style after it has been created by using
ModifyStyleEx during the OnInitDialog handler.

Dave
-----From: "David Lantsman" 

It's not an answer to the problem but all I know is that if your compile
your
program in the RELEASE mode (not debug) the assert will go away.
Hope it helps,
	David

=======================================
     Sent by David Lantsman
         mailto:davidlan@luckynet.co.il

Visit me at: http://www.luckynet.co.il/~davidlan
=======================================

-----From: "William B. Weidner" 

No, what this means is that you need to change the style of your property
sheet at runtime.
I usually do this in OnInitDialog() for the sheet something like:

C_sheetProperty::OnInitDialog() 
{
	CPropertySheet::OnInitDialog();
	
	// TODO: Add extra initialization here
	ModifyStyleEx(NULL,WS_EX_CONTEXTHELP,0);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}



Amir Shoval -- torin@netvision.net.il
Sunday, November 10, 1996

David Lowndes wrote:
> 
> [Mini-digest: 3 responses]
> 
> Amir,
> 
> > My question is, how - inspite the above - can I create a property sheet
> which pages DO contain such things (extended styles, Help IDs etc.)?
> <
> 
> Modify the property sheet style after it has been created by using
> ModifyStyleEx during the OnInitDialog handler.
> 
> Dave
> -----From: "David Lantsman" 
> 
> It's not an answer to the problem but all I know is that if your compile
> your
> program in the RELEASE mode (not debug) the assert will go away.
> Hope it helps,
>         David
> 
> =======================================
>      Sent by David Lantsman
>          mailto:davidlan@luckynet.co.il
> 
> Visit me at: http://www.luckynet.co.il/~davidlan
> =======================================
> 
> -----From: "William B. Weidner" 
> 
> No, what this means is that you need to change the style of your property
> sheet at runtime.
> I usually do this in OnInitDialog() for the sheet something like:
> 
> C_sheetProperty::OnInitDialog()
> {
>         CPropertySheet::OnInitDialog();
> 
>         // TODO: Add extra initialization here
>         ModifyStyleEx(NULL,WS_EX_CONTEXTHELP,0);
> 
>         return TRUE;  // return TRUE unless you set the focus to a control
>                       // EXCEPTION: OCX Property Pages should return FALSE
> }

Thanks for the above, but that doesn't answer it all.
I can change the style of the property sheet at run time, but it seems
I need to change the style of the DIALOGs (the propery pages), too.

How do I supply Help IDs for the controls on the propery pages?
How do I apply extended styles (like right-aligh & RTL reading) to those
controls.
>From what I tried, if I apply this kind of styles at run time to the
dialogs, the same assertion happens.

	Amir

-- 
--------------------------
Amir Shoval N.C.C. Israel
torin@netvision.net.il
--------------------------



Mike Blaszczak -- mikeblas@nwlink.com
Sunday, November 10, 1996

At 08:11 11/7/96 +0200, Amir Shoval wrote:

>Environment: Win 95, VC++ 4.2b

>At run time I get ASSERTed at dlgprop.cpp line 238. The remark before
>that line is quite clear:
> [...]
>//  1. Extended styles on the dialog
>//  2. Help IDs on any control in the dialog
>//  3. Control IDs that are DWORDs
>//  4. Weight, italic, or charset attributes on the dialog's font

>My question is, how - inspite the above - can I create a property sheet
>which pages DO contain such things (extended styles, Help IDs etc.)?

The only reason you can create such a property sheet (that is, one that uses
a DIALOGEX resource) is that you're using an upgrade version of Windows 95.
Some software that you've installed has updated COMCTL32.DLL, and that
new version (in addition to being twice the size of the original version
which shipped with Windows 95) provides a fix to the Windows bug of
not supporting DIALOGEX resources in a property sheet.

If you copy your program to a system that doesn't have IE 3.0 installed,
has never been patched with OSR1, or didn't have any of a bunch of 
third-party apps installed, your code will fail miserably.

Further, DIALOGEX resources won't work as property pages on a
Windows NT 3.51 machine, at all, period. Since MFC 4.2b still supports
Windows NT 3.51, the ASSERT() is going to stay.

>I know IT IS possible in windows (so it's not a WINBUG but and MFCBUG).

Says you, and that's worth nothing. Look: just because you don't know
all the facts doesn't mean that there's a bug in MFC.  Or in anything
else, for that matter.  Please check your facts before you start
throwing stones.

This isn't a bug: if you never saw this ASSERT(), you'd never know
that you were doing something risky.  And if you never knew that,
you'd end up going through life without understanding this problem,
and would probably run into it after you started distributing your
application.

Unfortunately, lots of people (including Microsoft _and_ ISVs)
have installed the updated COMCTL32.DLL with different software.
MFC can check the version of Windows before asserting, but there's
really no sure-fire way to guarantee that this ASSERT will be correctly
issued or not--it would take forever for MFC to load COMCTL32.DLL and
check its version stamp just to issue an ASSERT.

>Does the meaning of this I have to implement my own property sheet
>class?

No.  The problem isn't nearly that severe.

.B ekiM
http://www.nwlink.com/~mikeblas/
I'm afraid I've become some sort of speed freak.
These words are my own. I do not speak on behalf of Microsoft.





| Вернуться в корень Архива |