所有的操作针对添加的对话框
添加初始化:类导向--虚函数--OnInitDialog()
1、添加背景色:WM_PAINT->void CAboutDlg::OnPaint()
2、调用子对话框:InitInstance();创建了新的对话框,不要忘记将类添加到头文件中
3、
关于改变AfxMessageBox对话框标题
4、MFC中改变button的背景颜色和字体颜色,字体大小等;采用自绘的方式:需要将控件Owner Draw改为TRUE,不然无法没有效果
添加ClrButton.h
#if !defined(AFX_CLRBUTTON_H__3611A4FC_CBDB_11D5_A183_B13329B34330__INCLUDED_)
#define AFX_CLRBUTTON_H__3611A4FC_CBDB_11D5_A183_B13329B34330__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ClrButton.h : header file
//
/
// CClrButton window
const COLORREF BLACK = RGB(1, 1, 1);
const COLORREF GRARY = RGB(122, 122, 122);
const COLORREF DKRED = RGB(128, 0, 0);
const COLORREF GREEN = RGB(0, 255, 0);
const COLORREF RED = RGB(255, 0, 0);
const COLORREF BLUE = RGB(0, 0, 255);
const COLORREF WHITE = RGB(255, 255, 255);
class CClrButton : public CButton
{
// Construction
public:
CClrButton();
// Attributes
public:
// Operations
public:
// UK version
void SetColour(COLORREF text_colour,
COLORREF background_colour);
// US version
void SetColor(COLORREF text_colour,
COLORREF background_colour)
{
SetColour(text_colour,
background_colour);
};
// UK version
void SetColour(COLORREF text_colour,
COLORREF background_colour,
COLORREF disabled_background_colour);
// US version
void SetColor(COLORREF text_colour,
COLORREF background_colour,
COLORREF disabled_background_colour)
{
SetColour(text_colour,
background_colour,
disabled_background_colour);
};
void ResetColour();
// Overrides
// ClassWizard generated virtual function overrides
//{
{AFX_VIRTUAL(CClrButton)
public:
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CClrButton();
private:
COLORREF text_colour, background_colour, disabled_background_colour;
COLORREF light, highlight, shadow, dark_shadow;
// Generated message map functions
protected:
//{
{AFX_MSG(CClrButton)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
void DrawFrame(CDC *dc, CRect r, int state);
void DrawFilledRect(CDC *dc, CRect r, COLORREF colour);
void DrawLine(CDC *dc, long sx, long sy, long ex, long ey, COLORREF colour);
void DrawButtonText(CDC *dc, CRect r, const char *buf, COLORREF text_colour);
DECLARE_MESSAGE_MAP()
};
/
//{
{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CLRBUTTON_H__3611A4FC_CBDB_11D5_A183_B13329B34330__INCLUDED_)
添加ClrButton.c(在编码不同时,下面可能产生错误;Unicode和宽字节编码)
// ClrButton.cpp : implementation file
//
#include "stdafx.h"
#include "ClrButton.h"
<