MFC Learning Interface Beautification <2>

Source: Internet
Author: User

1. Change the icon

Copy the icon to the resource file, load the project, and set the ID.

In the dialog constructor, modify the icon's ID.

Iconcmfc_framedlg::cmfc_framedlg (cwnd* pparent/*=null*/): CDialog (Cmfc_framedlg::idd, pparent) {M_hIcon = AfxGetApp ()->loadicon (idi_mainframe);  Change to New icon ID}

2. Direct Skin Change

Skinshape tools SkinH.dll Skinh.; The IB Skinh.she SkinH.h are copied to the project catalog.

Add in StdAfx.h

<span style= "color: #ff0000;" > #include "SkinH.h" #pragma comment (lib, "SkinH.lib") </span>

dialog box is called before the add
<span style= "color: #ff0000;" > Skinh_attach ();  </span> Cmfc_framedlg Dlg;m_pmainwnd = &dlg;int_ptr Nresponse = dlg. DoModal ();

3. Change the background

First load a picture, the image ID is set to IDB_BITMAP1;

Add a definition to the header file:

<pre name= "code" class= "CPP" >public:    CBrush m_brbk;
afx_msg hbrush OnCtlColor (cdc* PDC, cwnd* pWnd, UINT nCtlColor);

CPP file, add the following:

BOOL Ctestdlg::oninitdialog () {    <span style= "color: #ff0000;" >cdialog::oninitdialog ();    CBitmap bmp;    Bmp. LoadBitmap (IDB_BITMAP1);    M_brbk.createpatternbrush (&bmp);    Bmp. DeleteObject ();</span>    return TRUE;       Return TRUE unless you set the focus to a control}
Add a message map

Begin_message_map (Cmfc_framedlg, CDialog) On_wm_syscommand () On_wm_paint () On_wm_querydragicon () <span style= " Color: #ff0000; " >on_wm_ctlcolor () </span>//}}afx_msg_mapend_message_map ()
The function is implemented as follows:

Hbrush Cmfc_framedlg::onctlcolor (cdc* PDC, cwnd* pWnd, UINT nctlcolor) {    Hbrush HBR = Cdialog::onctlcolor (PDC, PWND, n Ctlcolor);    if (pWnd = = this)    {         return m_brbk;    }    return HBR;}










MFC Learning Interface Beautification <2>

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.