Some time ago I was wondering how to make the window more beautiful and attractive? I have also seen many experts on the Internet, but for people I don't like too complicated, I don't really like writing code like that, getsystemmetrics function to get the length or width of each border .... In a few cases, my head was dizzy. After I checked a lot of materials and experiments, I finally found a simple method to beautify the window. Now I will show myself ugly, if you think it is not good, jump over ~~
Please refer to this figure:
In fact, this figure intuitively expresses the layout inside the window. Do you think it is still difficult to beautify the window with this picture? If you want to look good, you can look good .... <Note: This figure is obtained from the Internet. I am very grateful to this author for providing convenience. Here I just want to take this picture for reference.>
// Obtain the position of the title bar
Rttitle. Left = 6;
Rttitle. Top = 0;
Rttitle. Right = rtwnd. Right-rtwnd. Left-6;
Rttitle. Bottom = 30;
// Calculate the minimum button position
M_rtbuttmin.left = rtwnd. Right-rtwnd. Left-66;
M_rtbuttmin.top = 0;
M_rtbuttmin.right = rtwnd. Right-rtwnd. Left-46;
M_rtbuttmin.bottom = 30;
// Calculate the maximum button position
M_rtbuttmax.left = rtwnd. Right-rtwnd. Left-46;
M_rtbuttmax.top = 0;
M_rtbuttmax.right = rtwnd. Right-rtwnd. Left-26;
M_rtbuttmax.bottom = 30;
// Calculate the position of the close button
M_rtbuttexit.left = rtwnd. Right-rtwnd. Left-26;
M_rtbuttexit.top = 0;
M_rtbuttexit.right = rtwnd. Right-rtwnd. Left-6;
M_rtbuttexit.bottom = 30;
With their location, it is easy to beautify them:
// Prepare for drawing
Cbitmap * pbitmap = new cbitmap;
Bitmap BMP Info;
Cbitmap * poldbitmap;
CDC * pdisplaymemdc = new CDC;
Pdisplaymemdc-> createcompatibledc (PDC );
// Redraw the title bar
Pbitmap-> loadbitmap (idb_title_top );
Pbitmap-> getbitmap (& BMP info );
Poldbitmap = (cbitmap *) pdisplaymemdc-> SelectObject (pbitmap );
PDC-> stretchblt (6, 0, rtwnd. right-rtWnd.left-12,
30,
Pdisplaymemdc, 0, 0,
BMP info. bmwidth,
BMP info. bmheight, srccopy );
Pdisplaymemdc-> SelectObject (poldbitmap );
Pbitmap-> deleteobject ();
// Write the title
Writecaption (m_captioncolor, m_caption );
// Redraw a small border on both sides of the two title bars
Pbitmap-> loadbitmap (idb_down );
Pbitmap-> getbitmap (& BMP info );
Poldbitmap = (cbitmap *) pdisplaymemdc-> SelectObject (pbitmap );
// On the left
PDC-> stretchblt (0, 0, 6, 30,
Pdisplaymemdc, 0, 0,
BMP info. bmwidth,
BMP info. bmheight,
Srccopy );
//
PDC-> stretchblt (rtwnd. right-rtWnd.left-6, 30,
Pdisplaymemdc, 0, 0,
BMP info. bmwidth,
BMP info. bmheight,
Srccopy );
Pdisplaymemdc-> SelectObject (poldbitmap );
Pbitmap-> deleteobject ();
// Relay button
Pbitmap-> loadbitmap (idb_normal );
Pbitmap-> getbitmap (& BMP info );
Poldbitmap = (cbitmap *) pdisplaymemdc-> SelectObject (pbitmap );
PDC-> stretchblt (m_rtbuttmin.left,
M_rtbuttmin.top + 4,
60, 21, pdisplaymemdc,
0, 0, BMP info. bmwidth,
BMP info. bmheight, srccopy );
Pdisplaymemdc-> SelectObject (poldbitmap );
Pbitmap-> deleteobject ();
In this way, we can easily paste the position of the window.
From http://c.chinaitlab.com/vc/916576_2.html