Property Page won't call OnApply() or OnKillActive() 
Author Message
 Property Page won't call OnApply() or OnKillActive()

Hello,

I have a property page class derived from CSnapInPropertyPageImpl.  When I
run the program and display the property page and subsequently close it by
clicking on the Ok button, everything works fine and the OnApply() function
gets called.

However when I put in BEGIN_MSG_MAP() and END_MSG_MAP() in my class header
file the OnApply function does not get called at all. This also applies to
the OnKillActive() method.
Thanks for any help anybody can provide.

For reference my class definition is below:

class CSetLogLevelPage : public CSnapInPropertyPageImpl<CSetLogLevelPage>,
public CWinDataExchange<CSetLogLevelPage>
{
public :
 CSetLogLevelPage(long lNotifyHandle, bool bDeleteHandle = false, TCHAR*
pTitle = NULL) :
  CSnapInPropertyPageImpl<CSetLogLevelPage> (pTitle),
  m_lNotifyHandle(lNotifyHandle),
  m_bDeleteHandle(bDeleteHandle) // Should be true for only page.
 {
 }

 ~CSetLogLevelPage()
 {
  if (m_bDeleteHandle)
   MMCFreeNotifyHandle(m_lNotifyHandle);
 }

 enum { IDD = IDD_SETLOGLEVEL };

BEGIN_MSG_MAP(CSetLogLevelPage)
    MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
END_MSG_MAP()

BEGIN_DDX_MAP(CSetLogLevelPage)
 DDX_TEXT(IDC_LOGLEVELTXT,m_nLogLevel)
END_DDX_MAP()

 HRESULT PropertyChangeNotify(long param)
 {
  return MMCPropertyChangeNotify(m_lNotifyHandle, param);
 }

 // Set the finish button to be displayed
 LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
 {
  SetModified( TRUE );
  USES_CONVERSION;
  ATLASSERT(::IsWindow(m_hWnd));
  ATLASSERT(GetParent() != NULL);
  DoDataExchange(FALSE); // Load data values to screen
  ::PostMessage(GetParent(), PSM_SETWIZBUTTONS, 0, PSWIZB_FINISH);
  return TRUE;

 }

// virtual BOOL OnFinish(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled);
public:
 BOOL OnApply();
 BOOL OnKillActive();
 long m_lNotifyHandle;
 bool m_bDeleteHandle;
 CConfigData *m_nDataObj;

public:
 CString m_nLogLevel;

protected:
 CContainedWindowT<WTL::CUpDownCtrl> m_CLogLevelSpin;

Quote:
};



Sun, 11 Jul 2004 01:27:04 GMT  
 Property Page won't call OnApply() or OnKillActive()
I forgot to put in a question on my last post,
Does anyone know why this behaviour is happening and how do I get around it?
Also I'm using the WTL and not MFC so that might have some relevance.
Thanks,
John


Quote:
> Hello,

> I have a property page class derived from CSnapInPropertyPageImpl.  When I
> run the program and display the property page and subsequently close it by
> clicking on the Ok button, everything works fine and the OnApply()
function
> gets called.

> However when I put in BEGIN_MSG_MAP() and END_MSG_MAP() in my class header
> file the OnApply function does not get called at all. This also applies to
> the OnKillActive() method.
> Thanks for any help anybody can provide.

> For reference my class definition is below:

> class CSetLogLevelPage : public CSnapInPropertyPageImpl<CSetLogLevelPage>,
> public CWinDataExchange<CSetLogLevelPage>
> {
> public :
>  CSetLogLevelPage(long lNotifyHandle, bool bDeleteHandle = false, TCHAR*
> pTitle = NULL) :
>   CSnapInPropertyPageImpl<CSetLogLevelPage> (pTitle),
>   m_lNotifyHandle(lNotifyHandle),
>   m_bDeleteHandle(bDeleteHandle) // Should be true for only page.
>  {
>  }

>  ~CSetLogLevelPage()
>  {
>   if (m_bDeleteHandle)
>    MMCFreeNotifyHandle(m_lNotifyHandle);
>  }

>  enum { IDD = IDD_SETLOGLEVEL };

> BEGIN_MSG_MAP(CSetLogLevelPage)
>     MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
> END_MSG_MAP()

> BEGIN_DDX_MAP(CSetLogLevelPage)
>  DDX_TEXT(IDC_LOGLEVELTXT,m_nLogLevel)
> END_DDX_MAP()

>  HRESULT PropertyChangeNotify(long param)
>  {
>   return MMCPropertyChangeNotify(m_lNotifyHandle, param);
>  }

>  // Set the finish button to be displayed
>  LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
> bHandled)
>  {
>   SetModified( TRUE );
>   USES_CONVERSION;
>   ATLASSERT(::IsWindow(m_hWnd));
>   ATLASSERT(GetParent() != NULL);
>   DoDataExchange(FALSE); // Load data values to screen
>   ::PostMessage(GetParent(), PSM_SETWIZBUTTONS, 0, PSWIZB_FINISH);
>   return TRUE;

>  }

> // virtual BOOL OnFinish(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
> bHandled);
> public:
>  BOOL OnApply();
>  BOOL OnKillActive();
>  long m_lNotifyHandle;
>  bool m_bDeleteHandle;
>  CConfigData *m_nDataObj;

> public:
>  CString m_nLogLevel;

> protected:
>  CContainedWindowT<WTL::CUpDownCtrl> m_CLogLevelSpin;
> };



Sun, 11 Jul 2004 01:35:55 GMT  
 Property Page won't call OnApply() or OnKillActive()
Hello,

You should redirect unhandled messages to CSnapInPropertyPageImpl base
class, e.g:

BEGIN_MSG_MAP(CSetLogLevelPage)
    MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
    CHAIN_MSG_MAP(CSnapInPropertyPageImpl<CSetLogLevelPage>)
 END_MSG_MAP()

--
Best regards,
Vadim Melnik,
_____________________
http://www.docsultant.com/


Quote:
> I forgot to put in a question on my last post,
> Does anyone know why this behaviour is happening and how do I get around
it?
> Also I'm using the WTL and not MFC so that might have some relevance.
> Thanks,
> John



> > Hello,

> > I have a property page class derived from CSnapInPropertyPageImpl.  When
I
> > run the program and display the property page and subsequently close it
by
> > clicking on the Ok button, everything works fine and the OnApply()
> function
> > gets called.

> > However when I put in BEGIN_MSG_MAP() and END_MSG_MAP() in my class
header
> > file the OnApply function does not get called at all. This also applies
to
> > the OnKillActive() method.
> > Thanks for any help anybody can provide.

> > For reference my class definition is below:

> > class CSetLogLevelPage : public

CSnapInPropertyPageImpl<CSetLogLevelPage>,

- Show quoted text -

Quote:
> > public CWinDataExchange<CSetLogLevelPage>
> > {
> > public :
> >  CSetLogLevelPage(long lNotifyHandle, bool bDeleteHandle = false, TCHAR*
> > pTitle = NULL) :
> >   CSnapInPropertyPageImpl<CSetLogLevelPage> (pTitle),
> >   m_lNotifyHandle(lNotifyHandle),
> >   m_bDeleteHandle(bDeleteHandle) // Should be true for only page.
> >  {
> >  }

> >  ~CSetLogLevelPage()
> >  {
> >   if (m_bDeleteHandle)
> >    MMCFreeNotifyHandle(m_lNotifyHandle);
> >  }

> >  enum { IDD = IDD_SETLOGLEVEL };

> > BEGIN_MSG_MAP(CSetLogLevelPage)
> >     MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
> > END_MSG_MAP()

> > BEGIN_DDX_MAP(CSetLogLevelPage)
> >  DDX_TEXT(IDC_LOGLEVELTXT,m_nLogLevel)
> > END_DDX_MAP()

> >  HRESULT PropertyChangeNotify(long param)
> >  {
> >   return MMCPropertyChangeNotify(m_lNotifyHandle, param);
> >  }

> >  // Set the finish button to be displayed
> >  LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
> > bHandled)
> >  {
> >   SetModified( TRUE );
> >   USES_CONVERSION;
> >   ATLASSERT(::IsWindow(m_hWnd));
> >   ATLASSERT(GetParent() != NULL);
> >   DoDataExchange(FALSE); // Load data values to screen
> >   ::PostMessage(GetParent(), PSM_SETWIZBUTTONS, 0, PSWIZB_FINISH);
> >   return TRUE;

> >  }

> > // virtual BOOL OnFinish(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
> > bHandled);
> > public:
> >  BOOL OnApply();
> >  BOOL OnKillActive();
> >  long m_lNotifyHandle;
> >  bool m_bDeleteHandle;
> >  CConfigData *m_nDataObj;

> > public:
> >  CString m_nLogLevel;

> > protected:
> >  CContainedWindowT<WTL::CUpDownCtrl> m_CLogLevelSpin;
> > };



Sun, 11 Jul 2004 06:11:44 GMT  
 Property Page won't call OnApply() or OnKillActive()
Cheers Vadim,

That worked a treat.


Quote:
> Hello,

> You should redirect unhandled messages to CSnapInPropertyPageImpl base
> class, e.g:

> BEGIN_MSG_MAP(CSetLogLevelPage)
>     MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
>     CHAIN_MSG_MAP(CSnapInPropertyPageImpl<CSetLogLevelPage>)
>  END_MSG_MAP()

> --
> Best regards,
> Vadim Melnik,
> _____________________
> http://www.docsultant.com/



> > I forgot to put in a question on my last post,
> > Does anyone know why this behaviour is happening and how do I get around
> it?
> > Also I'm using the WTL and not MFC so that might have some relevance.
> > Thanks,
> > John



> > > Hello,

> > > I have a property page class derived from CSnapInPropertyPageImpl.
When
> I
> > > run the program and display the property page and subsequently close
it
> by
> > > clicking on the Ok button, everything works fine and the OnApply()
> > function
> > > gets called.

> > > However when I put in BEGIN_MSG_MAP() and END_MSG_MAP() in my class
> header
> > > file the OnApply function does not get called at all. This also
applies
> to
> > > the OnKillActive() method.
> > > Thanks for any help anybody can provide.

> > > For reference my class definition is below:

> > > class CSetLogLevelPage : public
> CSnapInPropertyPageImpl<CSetLogLevelPage>,
> > > public CWinDataExchange<CSetLogLevelPage>
> > > {
> > > public :
> > >  CSetLogLevelPage(long lNotifyHandle, bool bDeleteHandle = false,
TCHAR*
> > > pTitle = NULL) :
> > >   CSnapInPropertyPageImpl<CSetLogLevelPage> (pTitle),
> > >   m_lNotifyHandle(lNotifyHandle),
> > >   m_bDeleteHandle(bDeleteHandle) // Should be true for only page.
> > >  {
> > >  }

> > >  ~CSetLogLevelPage()
> > >  {
> > >   if (m_bDeleteHandle)
> > >    MMCFreeNotifyHandle(m_lNotifyHandle);
> > >  }

> > >  enum { IDD = IDD_SETLOGLEVEL };

> > > BEGIN_MSG_MAP(CSetLogLevelPage)
> > >     MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
> > > END_MSG_MAP()

> > > BEGIN_DDX_MAP(CSetLogLevelPage)
> > >  DDX_TEXT(IDC_LOGLEVELTXT,m_nLogLevel)
> > > END_DDX_MAP()

> > >  HRESULT PropertyChangeNotify(long param)
> > >  {
> > >   return MMCPropertyChangeNotify(m_lNotifyHandle, param);
> > >  }

> > >  // Set the finish button to be displayed
> > >  LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
> > > bHandled)
> > >  {
> > >   SetModified( TRUE );
> > >   USES_CONVERSION;
> > >   ATLASSERT(::IsWindow(m_hWnd));
> > >   ATLASSERT(GetParent() != NULL);
> > >   DoDataExchange(FALSE); // Load data values to screen
> > >   ::PostMessage(GetParent(), PSM_SETWIZBUTTONS, 0, PSWIZB_FINISH);
> > >   return TRUE;

> > >  }

> > > // virtual BOOL OnFinish(UINT uMsg, WPARAM wParam, LPARAM lParam,
BOOL&
> > > bHandled);
> > > public:
> > >  BOOL OnApply();
> > >  BOOL OnKillActive();
> > >  long m_lNotifyHandle;
> > >  bool m_bDeleteHandle;
> > >  CConfigData *m_nDataObj;

> > > public:
> > >  CString m_nLogLevel;

> > > protected:
> > >  CContainedWindowT<WTL::CUpDownCtrl> m_CLogLevelSpin;
> > > };



Sun, 11 Jul 2004 18:26:12 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Calling Control's property page from a container

2. CPropertySheet: dynamic page creation and OnKillActive()?

3. Why does OnKillActive() get called before OnApply() when CPropertyPage Apply button is pressed?

4. Property Pages in a Property Page

5. Modeless Property Sheet - how to get OnKillActive?

6. Property page 'help' button

7. Who's responsible for the OnKillActive notification

8. Howto call a MMC Property Page Extending from a Dialog

9. Property Page call from Main Object of a DLL

10. Win 2000 built OCX won't load on a WIn NT or 98 system

11. DoDataExchange() called twice when viewing a property page

12. Calling display settings property page from MFC application

 

 
Powered by phpBB® Forum Software