Create and call VC pure resource DLL

Source: Internet
Author: User
Pure resource DLL is a DLL that only contains resources (tags, bitmaps, strings, and dialogs. When pure resource DLL is used Program A good way to share the same group of resources between them. It is also a good way to provide its resources for localized applications in multiple languages. To create a pure resource DLL, create a new Win32 DLL (non-MFC) project and add the resource to this project.
    • In the "Create Project" dialog box, select "Win32 project" and specify the DLL project type in the "Win32 Project Wizard.

    • Create a new resource script that contains resources (such as strings or menus) for the DLL and save the. RC file. If the. RC file contains a bitmap, open it in notepad, you can see the following section:

    • Dib_bkgd_hf bitmap "bkgd _ **. BMP"
      Dib_bkgd_gt bitmap "bkgd _ ***. BMP"
      Dib_bkgd_bf bitmap "bkgd _ *****. BMP"

    • These are the declarations for bitmap. Just add the corresponding bitmap to this field.

    • In"Project"Click Add existing item on the menu, and insert the new. RC file in the project.

    • Specify/NoentryLinker Options. /Noentry prevents the linker from linking _ main references to the DLL. This option is required to create a pure resource DLL.

    • Generate DLL.

Applications that use pure resource dll should callLoadlibraryComeExplicitly link to DLL. To access resources, call the general functionFindresourceAndLoadresourceThese two functions are valid for any type of resources or call one of the following resource-specific functions:

    • Formatmessage

    • Loadaccelerators

    • Loadbitmap

    • Loadcursor

    • Loadicon

    • Loadmenu

    • Loadstring

After resources are used, the application should callFreelibrary.

The following section describes how to dynamically load and display BMP in a resource.

Hmodule = loadlibrary ("extenddll. dll ");
HDC m_hdcmem;
M_hdcmem = createcompatibledc (HDC );
Bitmap bm;
Rect;

Hbitmap = loadbitmap (hmodule, "dib_bkgd_hf"); // makeintresource (idb_bitmap1)
// Hbitmap = (hbitmap) LoadImage (hmodule, "dib_bkgd_hf", image_bitmap, 0, 0, lr_defaultsize );
GetObject (hbitmap, sizeof bitmap, & BM );
SelectObject (m_hdcmem, hbitmap );
Getclientrect (hwnd, & rect );
//: Setstretchbltmode (HDC, coloroncolor );
//: Stretchblt (HDC, rect. left, rect. top, rect. right, rect. bottom, m_hdcmem, 0, 0, BM. bmwidth, BM. bmheight, srccopy );
Bitblt (HDC, BM. bmwidth, BM. bmheight, m_hdcmem, srccopy );
Releasedc (hwnd, m_hdcmem );
Freelibrary (hmodule );

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.