Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. I need help to display a dialog from Resource-only DLL

I need help to display a dialog from Resource-only DLL

Scheduled Pinned Locked Moved C / C++ / MFC
graphicshelplearning
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cheickna
    wrote on last edited by
    #1

    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

    W R 2 Replies Last reply
    0
    • C Cheickna

      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

      W Offline
      W Offline
      wb
      wrote on last edited by
      #2

      hm... 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:

      1 Reply Last reply
      0
      • C Cheickna

        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

        R Offline
        R Offline
        Ryan Binns
        wrote on last edited by
        #3

        Cheickna 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"

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups