Another modification dialog box background color

Source: Internet
Author: User

Bool ctestkeydlg: onerasebkgnd (CDC * PDC) {// todo: add your message handler code here and/or call defaultcdialog: onerasebkgnd (PDC); hbitmap h_bitmap; h_bitmap = shloadimagefile (L "bg.gif"); If (h_bitmap = NULL) {return false;} bitmap bm; GetObject (& h_bitmap, sizeof (hbitmap), & BM ); /* assign a value to an image. */HDC = createcompatibledc (PDC-> getsafehdc ();/* The DC in the memory is only stored in the memory. When a DC is created, its appearance (display mode) is only a pixel size. Therefore, before using DC for an application, use "createcompatiablebitmap" to select an appropriate image to the memory. In this way, the size of the DC is the size of the image. When a DC in the memory is created, all attributes are default values. If you want to treat it as a common DC, you must set its attributes to obtain the current settings, and the size of the selected paint brush, paint brush, and area. The createcompatibledc function can only be used for devices that support grating operations. You can use the "getdevicecaps" function to determine whether the application supports grating operations. After the DC is used up, use deletedc to destroy the DC. * // * A memory DC exists only in memory. when the memory DC is created, its display surface is exactly one monochrome pixel wide and one monochrome pixel High. before an application can use a memory DC for drawing operations, it must select a bitmap of the correct width and height into the DC. to select a bitmap into a DC, use the createcompatiblebitmap function, specifying the height, width, and Colo R organization required. when a memory DC is created, all attributes are set to normal default values. the memory DC can be used as a normal DC. you can set the attributes; obtain the current settings of its attributes; and select pens, brushes, and regions. the createcompatibledc function can only be used with devices that support raster operations. an application can determine whether a device sup Ports these operations by calling the getdevicecaps function. when you no longer need the memory DC, call the deletedc function. */hbitmap holdbmp = NULL; holdbmp = (hbitmap) SelectObject (HDC, & h_bitmap);/* Save the original image information for restoration. (After use, you need to restore the system information) * // * This function returns the previusly selected object of the specified type. an application shoshould always replace a new object with the original, default object after it has finished drawing with the new object. */crect rect; getclientrect (& rect);/* obtain the size of the current customer zone. */Stretchblt (PDC-> getsafehdc (), rect. left, rect. top, rect. width (), rect. height (), HDC, 0, 0, BM. bmwidth, BM. bmheight, srccopy);/* draw the picture. */SelectObject (HDC, holdbmp); deletedc (HDC); HDC = NULL; If (h_bitmap! = NULL) {deleteobject (h_bitmap);} return true ;}

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.