多文档结构的工程  我在class CFtuDoc : public CDocument中建 了
一个文本打开的函数
现在想 在打开文本后发送一个消息给 
class CChildFrame : public CMDIChildWnd CWnd * pParent  
if(pParent != NULL )
::SendMessage(pParent->m_hWnd, MYWM_DISPLAYFTUVIEW, 0, 0);
SendMessage(NULL, MYWM_DISPLAYFTUVIEW, 0, 0);请问我要怎么样才能得出 CChildFrame 的句柄呢,
请大虾帮忙,在线等ing;

解决方案 »

  1.   

    CWinApp *pApp = AfxGetApp();
    CMainFrame *pMainFrame = pApp->GetMainFrame();
    CChileFrame *pChildFrame = pMainFrame->GetActiveFrame();
    OK!!
      

  2.   

    错了,而且在class CFtuDoc 中不认识 CMainFrame 
    error C2039: 'GetMainFrame' : is not a member of 'CWinApp'再想想帮帮忙
      

  3.   

    这样
    CMainFrame* pMainFrame = (CMainFrame*)::AfxGetMainWnd()
      

  4.   


    CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd();
    CChileFrame *pChildFrame = pMainFrame->GetActiveFrame();
      

  5.   

    在CMainFrame的初始化中把自己的 HWND 保存在全局变量里。
      

  6.   

    CMainFrame *pMainFrame = pApp->GetMainFrame();
    CChileFrame *pChildFrame = pMainFrame->GetActiveFrame();
      

  7.   

    mfc什么都封装起来,初学者还是先用SDK入门快。
    MFC中用CWnd::GetDlgItem()取窗口句柄即可。
      

  8.   

    该方法可以的。
    下述代码在你的App类的GetYourFrm(CMDIChildWnd* ),返回值PosFrm 为你的窗口类型指针
    {
    CMainFrame* PosFrmMain = (CMainFrame*)AfxGetMainWnd();
    CString strTitle;
    int i = 0;
    PosFrm = PosFrmMain->MDIGetActive(NULL);
    while(PosFrm!=NULL)
    {
    PosFrm->GetWindowText(strTitle);
    if(strTitle=="你的文档窗口名")//用模糊的判断也比较好
    return;
    PosFrmMain->MDINext();
    PosFrm = PosFrmMain->MDIGetActive(NULL);
    i++;
    if(i>你的文档窗口数)break;
    }
    }
      

  9.   

    在你的文档cpp中先调用上面的函数,获得Frame句柄
    就可以给他发消息了。
    :)
      

  10.   

    补充一句,别忘记了进行判断
    !=NULL哦
    祝你成功!