Beautify the appearance of your application interface

Source: Internet
Author: User

Many programmers have this experience, their own program is very beautiful, but in the Windows Platform Development program is always not escape the Windows default style constraints. The title bar, the toolbar, the same style makes the creative works fade. Here we have a surgical procedure for the dialog box application, which is intended to introduce a method to your readers and hope that you will have further development on this basis.

This example is based on a dialog application, painting a non-customer area, finishing the application landscaping, the code will run the following effect diagram:

Now let's explore the specific implementation process

First, define resources:

Add a bitmap resource for the system button (use 10 bitmaps in this example to display Help, minimize, maximize, restore, and turn off the normal state and focus state of the button, which can be customized as required by the program)

Second, define global variables and functions:

CRect m_rtButtExit;  //关闭按钮位置
    CRect m_rtButtMax;  //最大化按钮位置
    CRect m_rtButtMin;  //最小化按钮位置
    CRect m_rtButtHelp;  //帮助按钮位置
    CRect m_rtIcon;    //图标位置
    void DrawTitleBar(CDC *pDC);  //画非客户区主函数

Third, function implementation:

This example requires the following message to be overloaded DefWindowProc, On_wm_ncmousemove, On_wm_nclbuttondown.

The function implementation body is as follows:

Main function, which can be used to draw the form according to the actual situationvoid CTitleBarDlg::DrawTitleBar(CDC *pDC)
   {
     if (m_hWnd)
     {
       CBrush Brush(RGB(0,100,255));
       CBrush* pOldBrush = pDC->SelectObject(&Brush);
       CRect rtWnd, rtTitle, rtButtons;
       GetWindowRect(&rtWnd);
   ……………………………..
   //因代码过长,未贴,见源程序
   ……………………………...
   }
   }
  

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.