我的工程中有一个类CFontBaseEditorPage,对话框类型,该类含有一个子类,在class CFontBaseEditorPage : public CPropertyPage
{
....
CImitateOsdToolBar *ImitateToolBar;//定义....
}
在CFontBaseEditorPage 初始化函数中生成一个实例,无模对话框.BOOL CFontBaseEditorPage::OnInitDialog() 
{
....
ImitateToolBar = new CImitateOsdToolBar;
ImitateToolBar->Create(IDD_DIALOG_Imitate,NULL);
....
}下面是我希望用类ImitateToolBar 的成员函数调用父类的成员函数,运行windows 错误,请帮忙指点,感激
void CImitateOsdToolBar::OnImitateChooseColor()
{
    CWnd* pWnd = GetParent();
    while(!pWnd->IsKindOf(RUNTIME_CLASS(CFontBaseEditorPage)) && pWnd != NULL)
       pWnd = pWnd->GetParent();//此处会失败 :(    ((CFontBaseEditorPage*)pWnd)->RecordGlobalPalette();//RecordGlobalPalette();是CFontBaseEditorPage成员函数
}

解决方案 »

  1.   

    CImitateOsdToolBar类添加一个成员函数,接收CFontBaseEditorPage类的指针
    BOOL   CFontBaseEditorPage::OnInitDialog()  
    {
    ....
    ImitateToolBar   =   new   CImitateOsdToolBar;
    ImitateToolBar-> Create(IDD_DIALOG_Imitate,NULL);
    ImitateToolBar->SetParentHandle(this);
    ....
    } void   CImitateOsdToolBar::OnImitateChooseColor()
    {
           m_pParentHandle-> RecordGlobalPalette();//RecordGlobalPalette();是CFontBaseEditorPage成员函数
      

  2.   

    ImitateToolBar->Create(IDD_DIALOG_Imitate,this);这样行不? 
      

  3.   

    // Calculate the byte offset of a field in a structure of type type.
    //
    #define FIELD_OFFSET(type, field)    ((LONG)(INT_PTR)&(((type *)0)->field))#define GET_NAME_OFFSET(table,rva) ((LONG)(table.Name - rva.VirtualAddress+rva.PointerToRawData))
      

  4.   

    谢谢 ouyh12345 ,OK了,谢谢,给你分了.