Make the VC window easy to beautiful

Source: Internet
Author: User

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

 

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.