添加类CImgButton,继承自CBitmapButton。选择CImgButton类的property,通过重载DrawItem(不是Message下的WM_DRAWITEM,其响应函数OnDrawItem不会被调用。),实现在bitmap上写入文字的功能。
.h文件代码
#pragma once
#include <afxext.h>
class CImgButton :
public CBitmapButton
{
//DECLARE_DYNAMIC(CImgButton)
public:
CImgButton();
virtual ~CImgButton();
protected:
//DECLARE_MESSAGE_MAP()
public:
public:
COLORREF TextColor;
void SetTextColor(COLORREF crColor);
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
};
.cpp文件代码
#include "stdafx.h"
#include "ImgButton.h"
CImgButton::CImgButton()
{
}
CImgButton::