Reputation:
I have a dialog template in an extension DLL. I need to create that dialog from another module(exe). But before creating that dialog, i need to know the dialog size. So i tried to get the dialog size from the dialog template. Here is my code -
CSize CEMCNewPropertyPage::CalcDialogSize()
{
CSize size(0, 0);
HRSRC hRsrc = FindResource(AfxGetInstanceHandle(),MAKEINTRESOURCE(m_nResourceID), RT_DIALOG);
if(hRsrc == NULL)
return size;
HGLOBAL hTemplate = ::LoadResource(AfxGetResourceHandle(), hRsrc);
if(hTemplate == NULL)
return NULL;
DLGTEMPLATE* pTemplate = (DLGTEMPLATE*)::LockResource(hTemplate);
if(pTemplate == NULL)
return NULL;
size.cx = pTemplate->cx;
size.cy = pTemplate->cy;
::UnlockResource(hTemplate);
return size;
}
Here, FindResource
is returning NULL
. But the dialog template is in the resource file of that extension DLL. So i am assuming that, FindResource
is not searching the whole resource chain. So, is there any way to force to carry out the search in the whole resource chain?
Upvotes: 0
Views: 715
Reputation: 4590
I have a dialog template in an extension DLL
You need to save the current resource handle (AfxGetResourceHandle) and set it to the extension dll using AfxSetResourceHandle. When you are done working with the template, you need to restore the resource handle back to its previous setting. As you suspected, your current code is actually looking in the exe only.
Upvotes: 1