Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - CXTPPRopertySheet and OnInitDialog
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPPRopertySheet and OnInitDialog

 Post Reply Post Reply
Author
Message
gerrysweeney View Drop Down
Newbie
Newbie
Avatar

Joined: 27 May 2008
Location: United Kingdom
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote gerrysweeney Quote  Post ReplyReply Direct Link To This Post Topic: CXTPPRopertySheet and OnInitDialog
    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

 

Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
gerrysweeney View Drop Down
Newbie
Newbie
Avatar

Joined: 27 May 2008
Location: United Kingdom
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote gerrysweeney Quote  Post ReplyReply Direct Link To This Post 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()
///////////////////////////////////////////////////////////////////////////////////////
 
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.