Bindable Properties -- Change Notifications

If an ActiveX control has a property designated as bindable, the control will send an OnChanged notification to its container when the value of the property changes inside the control. In addition, the control can send an OnRequestEdit notification for a property whose value is about to change but has not yet changed. If the container returns FALSE from its OnRequestEdit handler, the control should not change the property value.

MFC fully supports property change notifications in ActiveX control containers, but as of Visual C++ version 6.0, no ClassWizard support was available. That means you must manually add entries to your container class's event sink map.

Suppose you have an ActiveX control with a bindable property named Note with a dispatch ID of 4. You add an ON_PROPNOTIFY macro to the EVENTSINK macros in this way:

BEGIN_EVENTSINK_MAP(CAboutDlg, CDialog)     //{{AFX_EVENTSINK_MAP(CAboutDlg)     // ClassWizard places other event notification macros here     //}}AFX_EVENTSINK_MAP     ON_PROPNOTIFY(CAboutDlg, IDC_MYCTRL1, 4, OnNoteRequestEdit, OnNoteChanged) END_EVENTSINK_MAP()

You must then code the OnNoteRequestEdit and OnNoteChanged functions with return types and parameter types exactly as shown here:

BOOL CMyDlg::OnNoteRequestEdit(BOOL* pb) {     TRACE("CMyDlg::OnNoteRequestEdit\n");     *pb = TRUE; // TRUE means change request granted     return TRUE; } BOOL CMyDlg::OnNoteChanged()  {     TRACE("CMyDlg::OnNoteChanged\n");     return TRUE; }

You'll also need corresponding prototypes in the class header, as shown here:

afx_msg BOOL OnNoteRequestEdit(BOOL* pb); afx_msg BOOL OnNoteChanged();


Programming Microsoft Visual C++
Programming Microsoft Visual C++
ISBN: 1572318570
EAN: 2147483647
Year: 1997
Pages: 332

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net