本文介绍了不可能从另一个CDialog模态到达主CFrameWnd上的CRecordView类:(的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我坚持要竞争我的项目,只是从模态CDialog派生类-到达CRecordView派生类,该类是主CFrameWnd类的子类.这样做的目的是当用户在模式对话框中单击 OK 按钮时,应调用该CRecordView派生类上的公共函数.
我尝试了所有可能的函数来访问该CRecordView派生类,这些类是:

I am stuck to compete my project in just reaching a CRecordView derived class which is a child class on the main CFrameWnd class - from a modal CDialog derived class -. The purpose of this is when the user clicks on the OK button from the modal dialog, a public function on that CRecordView derived class should be called.
I tried all possible functions to access that CRecordView derived class, which are:

::AfxGetMainWnd()->GetDescendantWindow(nID);
::FindWindow(LPCTSTR lpClassName, LPCTSTR lpWindowName);
::GetWindow(HWND hWnd, UINT uCmd);



什么都没用:(

还有其他窍门吗?

请帮助我:((<



nothing is working :(

Is there any other tricks to do that?

Help me please :((

推荐答案



class CYourDialog : public CDialog
{
  CRecordView* m_pcView;
..

public:
  CYourDialog(CRecordView* pcView, CWnd* pcParent)
    : CDialog(pcParent, CYourDialog::IDD), m_pcView(pcView) {};

..
  virtual void OnOK()
  {
    if (pcView->GetSafeHwnd()) {
      //..
    }
  }
..
};


..或,如Carlo所说,在父端使用OK事件:


..or, as Carlo said, use the OK event at the parent side:

void CMainFrame::OnRecordViewConfig()
{
  CYourDialog cDlg(this);
  if (IDOK == cDlg.DoModal()) {
    if (m_pcRecordView->GetSafeHwnd()) {
      //..
    }
  }
}


:)


这篇关于不可能从另一个CDialog模态到达主CFrameWnd上的CRecordView类:(的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 23:45