Question : CFileDialog extending? - How to add button & onclick handler

I am extending the common open dialog.  I derived a class from CFileDialog plus added a new dialog resource with my new extending controls.  How do I add an onclick hander for a CButton I've added? I noted that when using class wizard to create a class derived from CFileDialog no support is there for DDX and other things associated with CDialog which its downline from.  

Answer : CFileDialog extending? - How to add button & onclick handler

Here is sample code.. I added a button with IDC_DELETE id on the resource template. You can handle the button click messages in normal way a CDialog does. And you can add the virtual function for DDE support too......



//{{AFX_VIRTUAL(CSpecialFileDialog)
      protected:
      virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
      //}}AFX_VIRTUAL

// Generated message map functions
      //{{AFX_MSG(CSpecialFileDialog)
      virtual BOOL OnInitDialog();
      afx_msg void OnDelete();
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()

// In source file
BEGIN_MESSAGE_MAP(CSpecialFileDialog, CFileDialog)
      //{{AFX_MSG_MAP(CSpecialFileDialog)
      ON_BN_CLICKED(IDC_DELETE, OnDelete)
      //}}AFX_MSG_MAP
END_MESSAGE_MAP()

void CSpecialFileDialog::OnDelete()
{
      // Handle button click here
}

void CSpecialFileDialog::DoDataExchange(CDataExchange* pDX)
{
      CFileDialog::DoDataExchange(pDX);
      //{{AFX_DATA_MAP(CSpecialFileDialog)
            // NOTE: the ClassWizard will add DDX and DDV calls here
      //}}AFX_DATA_MAP
}
Random Solutions  
 
programming4us programming4us