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!