Print Page | Close Window

CXTPPRopertySheet and OnInitDialog

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=10799
Printed Date: 09 July 2025 at 9:02pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPPRopertySheet and OnInitDialog
Posted By: gerrysweeney
Subject: CXTPPRopertySheet and OnInitDialog
Date Posted: 27 May 2008 at 11:56am

I have used CXTPPropertySheet/CXTPPropertyPage instead of the standard MFC provided ones to get the alternative navigation schemes. This works OK for me except for one issue: -

 

When a CXTPPropertySheet is created (using DoModal()) each CXTPPropertyPage is created and its related OnInitDialog() is invoked.  In the standard CPropertySheet/CPropertyPage the OnInitDialog method is only invoked if you switch to that tab which is of course far more efficient.  This would not cause a problem apart from the fact that some of the tabs need to do a bit of processing when they are first initialized.  For example, we use a Property Sheet for our about dialog, and one of the tabs provides a list of all the applications loaded modules and their versions, which can take a good few seconds to load.  With the MFC property sheet/page this loading would only occur if one clicks the "Loaded Modules" tab, but with the CXTPPropertySheet/Page implementation the whole dialog takes about 10 seconds to load and display,

 

As the CXTPPropertySheet/Page classes are designed to be a *better* replacement for their MFC counterparts, I would say this is a bug? Any ideas on what I could do about this?

 

Gerry

 




Replies:
Posted By: Oleg
Date Posted: 27 May 2008 at 12:13pm
Hello,
 
Sorry, now you can't change it, it was designed to work this way. We will check if it possible to enhance it. Thanks.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: gerrysweeney
Date Posted: 27 May 2008 at 12:51pm

Hi Oleg,

 

Thanks for the response.  For those of you that care about this functionality in the meantime, here is a peice of code that resolves the issue, just derive your pages from CXTPPropertyPageEx instead of CXTPPropertyPage and place the following code in your stdafx.h/.cpp files (or stand-alone files if you like. Nothing interesting going on, I just sunk the WM_INITDIALOG message and invoke OnInitDialog() method from the OnSetActive() method...

 

Perhaps the good folks at codejock will see their way to including this behavior in future library releases.

 

Gerry

 
n.b Just updated the code, I forgot a "OnSetActive" should not have been private
n.b Just updated to include a call to UpdateData() to ensure that controls that are DDX_ subclassed are subclassed even before the page is first displayed 
 
 
///////////////////////////////////////////////////////////////////////////////////
// For stdafx.h
class CXTPPropertyPageEx : public CXTPPropertyPage
{
public:
 CXTPPropertyPageEx();
 CXTPPropertyPageEx(UINT nIDTemplate, UINT nIDCaption = 0);
 CXTPPropertyPageEx(LPCTSTR lpszTemplateName, UINT nIDCaption = 0);
// Implementation
protected:
 DECLARE_MESSAGE_MAP()
 virtual BOOL OnSetActive()
 {
  if(m_bInitUpdate)
  {
   OnInitDialog();
   m_bInitUpdate = false;
  }
  return CXTPPropertyPage::OnSetActive();
 }
private:
 LRESULT OnInitDialogEx(WPARAM, LPARAM)
 {
  // Make sure that all DDX controls are sub-classed when the dialog is initialized
  // If not, when any of the sub-classed objects are accessed before the page is displayed MFC asserts (rightly)
  UpdateData(FALSE);

  return 0;
 }
 bool m_bInitUpdate;
};
///////////////////////////////////////////////////////////////////////////////////
// For stdafx.cpp
CXTPPropertyPageEx::CXTPPropertyPageEx()
{
 m_bInitUpdate = true;
}
CXTPPropertyPageEx::CXTPPropertyPageEx(UINT nIDTemplate, UINT nIDCaption)
 : CXTPPropertyPage(nIDTemplate, nIDCaption)
{
 m_bInitUpdate = true;
}
CXTPPropertyPageEx::CXTPPropertyPageEx(LPCTSTR lpszTemplateName, UINT nIDCaption)
 : CXTPPropertyPage(lpszTemplateName, nIDCaption)
{
 m_bInitUpdate = true;
}
BEGIN_MESSAGE_MAP(CXTPPropertyPageEx, CXTPPropertyPage)
 //{{AFX_MSG_MAP(CXTPPropertyPageEx)
 ON_MESSAGE(WM_INITDIALOG, OnInitDialogEx)
 //}}AFX_MSG_MAP
END_MESSAGE_MAP()
///////////////////////////////////////////////////////////////////////////////////////
 



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net