#include <dlgs.h>
BOOL CMacFileDialog::OnInitDialog() 
{
CFileDialog::OnInitDialog();

CWnd* pwndParent = GetParent();
CWnd* pwndOK = pwndParent->GetDlgItem(IDOK);
m_macOK.SubclassWindow(pwndOK->m_hWnd); return TRUE;
}

解决方案 »

  1.   

    m_macOK.SubclassDlgItem(IDOK, this);就可以了。
    用你的代码:
    //CWnd* pwndParent = GetParent();//多余
    CWnd* pwndOK = GetDlgItem(IDOK);
    m_macOK.SubclassWindow(pwndOK->m_hWnd);
      

  2.   

    你们有没有试过啊,m_macOK.SubclassDlgItem(IDOK, this);返回FALSE。
      

  3.   

    我试了一下也有问题,不过在CFileDialog::OnInitDialog();之前子类化就行
    BOOL CMacFileDialog::OnInitDialog() 
    {
    CWnd* pwndParent = GetParent();
    CWnd* pwndOK = pwndParent->GetDlgItem(IDOK);
    m_macOK.SubclassWindow(pwndOK->m_hWnd); CFileDialog::OnInitDialog(); return TRUE;
    }
    但我不知这种子类化有什么作用。