我重载了SetExtent函数,但是在SetExtent函数里怎么获得一个在资源里的对话框的大小呢?我试了Create和GetWindowRect在SetExtent函数里调用都出错。有没有哪个消息是在SetExtent之前并且可以Create和GetWindowRect的呢?

解决方案 »

  1.   

    http://www.codeguru.com/dialog/dlgsize.html
    Finding Display Size of Dialog From Resource http://www.codeguru.com/mfc/comments/45723.shtml
    void CMyAppApp::CalcDialogSize(UINT nResourceId, SIZE& size) 

    HRSRC hRsrc = ::FindResource(m_hInstance, MAKEINTRESOURCE(nResourceId), RT_DIALOG); 
    ASSERT(hRsrc != NULL); 
    HGLOBAL hTemplate = ::LoadResource(m_hInstance, hRsrc); 
    ASSERT(hTemplate != NULL); 
    DLGTEMPLATE* pTemplate = (DLGTEMPLATE*)::LockResource(hTemplate); 
    CDialogTemplate dlgtemplate(pTemplate); 
    dlgtemplate.GetSizeInPixels(&size); 
    ::UnlockResource(hTemplate); return bResult; 
      

  2.   

    To Masterz:没成功,我用的是第一篇文章的方法,我是用MFC做的是放到IE的ocx控件。我在OnSetExtent()里加入CalDialogSize结果在AfxFindResourceHandle就ASSERT报错,
    跟踪后发现是在AfxGetResourceHandle()里ASSERT(afxCurrentResourceHandle != NULL)出错的。请问怎么解决呢?谢谢。
      

  3.   

    //ensure we are using our own resources
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
      

  4.   

    Excuse my dullness,I still don't understand how to solve this problem.
    Can you describe it more detailed?