CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Location
    Fort Worth Texas
    Posts
    614

    Resources in a DLL

    How does one compile the resources used by an MFC exe or MFC DLL so that they are in a DLL? Then how do you load those resources into the exe or DLL?


    Thanks

    Jim Bassett


  2. #2
    Join Date
    Apr 1999
    Posts
    90

    Re: Resources in a DLL

    The online MSDN help contains an article called "Create a Resource-Only DLL".


  3. #3
    Join Date
    May 1999
    Location
    United Kingdom
    Posts
    136

    Re: Resources in a DLL

    Just add the resources to the project which is the DLL and then compile the DLL as normal.

    Every time you want to load a resource, do the following:

    // save current resource handle
    HINSTANCE hInstance = AfxGetResourceHandle();
    // set resource handle to ourselves (the DLL)
    AfxSetResourceHandle(theApp.m_hInstance);

    // then display a dialog or...
    int rv = dlg->DoModal();

    // ...load an image list, or whatever
    CImageList ilMyImageList.Create(IDB_IMAGE_LIST_ID, 16, 0, RGB(192, 192, 192));

    // finally, reset resource handle to what it was before
    AfxSetResourceHandle(hInstance);


    theApp is defined by the Wizard for you and looks something like below:

    /////////////////////////////////////////////////////////////////////////////
    // The one and only CDLLApp object

    CDLLApp theApp;





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured