Vc6.0slider slider control background image Experience Summary

Source: Internet
Author: User

Some time ago, I used the slider control to write a program, but when I changed the background, the slider background did not change as I thought. Baidu finally solved the problem. However, a new problem occurs. After the image is used in the dialog box window, the slider control still has a problem and Baidu does not get the result.


During the day, I thought of a very stupid method. You can make an urgent request, and then find a good way to despise it.


First look

If it is a pure background, you can directly change the background of the slider control in oncolor.


Hbrush cpage2: onctlcolor (CDC * PDC, cwnd * pwnd, uint nctlcolor)
{
Hbrush HBr = cdialog: onctlcolor (PDC, pwnd, nctlcolor );

PDC-> setbkmode (transparent); // transparent mode

If (nctlcolor = ctlcolor_static)
{
PDC-> settextcolor (RGB (255, 50, 0 ));
Return (hbrush) getstockobject (null_brush); // The static background is transparent.
}
Return HBr;
}

My method is to cut down the background image corresponding to the slider control, and then paste it to the background of the slider control in oncolor. The Code is as follows:

1.

Initialize bitmap painter in oninitdialog ()


/// Bitmap image painter /////////////////////////////////// ////////////////////
Cbitmap * pbitmap = new cbitmap;
Pbitmap-> loadbitmap (idb_gmcslider1 );
Brushslider1.createpatternbrush (pbitmap );
Delete pbitmap;
Pbitmap = NULL;


2.

Hbrush cpage4: onctlcolor (CDC * PDC, cwnd * pwnd, uint nctlcolor)
{
Hbrush HBr = cdialog: onctlcolor (PDC, pwnd, nctlcolor );

If (pwnd = getdlgitem (idc_slider1 ))
{
Return (hbrush) brushslider2.getsafehandle ();
}

Return HBr;
}


OK.

I am very stupid. If anyone has a better way to share it, thank you!

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.