I need help to display a dialog from Resource-only DLL
-
Hi, I created a resource-only Dll to store string, dialog, icon and bitmap. With loadstring function i can load a string from this dll, but i don't know how dipslay a dialog from it. here is my code :
UINT CDataResource::GetResourceDialog(int ResourceID) { // load resource LPCDLGTEMPLATE lpDialogTemplate = NULL; HGLOBAL hDialogTemplate = NULL; HINSTANCE hInst = AfxFindResourceHandle(MAKEINTRESOURCE(ResourceID), RT_DIALOG); HRSRC hResource = ::FindResource(hInst, MAKEINTRESOURCE(ResourceID), RT_DIALOG); hDialogTemplate = LoadResource(hInst, hResource); if (hDialogTemplate != NULL) lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate); else return 0; ASSERT(lpDialogTemplate != NULL);
// HERE I WANT TO DISPLAY MY DIALOG// free resource UnlockResource(hDialogTemplate); FreeResource(hDialogTemplate); return 1; }
Thanks in advance -
Hi, I created a resource-only Dll to store string, dialog, icon and bitmap. With loadstring function i can load a string from this dll, but i don't know how dipslay a dialog from it. here is my code :
UINT CDataResource::GetResourceDialog(int ResourceID) { // load resource LPCDLGTEMPLATE lpDialogTemplate = NULL; HGLOBAL hDialogTemplate = NULL; HINSTANCE hInst = AfxFindResourceHandle(MAKEINTRESOURCE(ResourceID), RT_DIALOG); HRSRC hResource = ::FindResource(hInst, MAKEINTRESOURCE(ResourceID), RT_DIALOG); hDialogTemplate = LoadResource(hInst, hResource); if (hDialogTemplate != NULL) lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate); else return 0; ASSERT(lpDialogTemplate != NULL);
// HERE I WANT TO DISPLAY MY DIALOG// free resource UnlockResource(hDialogTemplate); FreeResource(hDialogTemplate); return 1; }
Thanks in advancehm... It is about 4 years ago, that I did it... I had the same ressource IDs in the main App AND in the DLL, but in different languages. I guess, you can do it like this: HINSTANCE hDLL = AfxLoadLibrary("ress.dll"); HINSTANCE hRes = AfxGetRessourceHandle(); AfxSetRessourceHandle(hDLL); //now do your dialog stuff.. AfxSetRessourceHandle(hRes); AfxFreeLibrary(hDLL); :confused:
-
Hi, I created a resource-only Dll to store string, dialog, icon and bitmap. With loadstring function i can load a string from this dll, but i don't know how dipslay a dialog from it. here is my code :
UINT CDataResource::GetResourceDialog(int ResourceID) { // load resource LPCDLGTEMPLATE lpDialogTemplate = NULL; HGLOBAL hDialogTemplate = NULL; HINSTANCE hInst = AfxFindResourceHandle(MAKEINTRESOURCE(ResourceID), RT_DIALOG); HRSRC hResource = ::FindResource(hInst, MAKEINTRESOURCE(ResourceID), RT_DIALOG); hDialogTemplate = LoadResource(hInst, hResource); if (hDialogTemplate != NULL) lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate); else return 0; ASSERT(lpDialogTemplate != NULL);
// HERE I WANT TO DISPLAY MY DIALOG// free resource UnlockResource(hDialogTemplate); FreeResource(hDialogTemplate); return 1; }
Thanks in advanceCheickna wrote: // HERE I WANT TO DISPLAY MY DIALOG
CYourDialogClass dlg;
dlg.InitModalIndirect(lpDialogTemplate);
dlg.DoModal();Hope this helps,
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"