|
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
#include "MyBttom.h"
|
|
|
|
|
#include "GlobalDefine.h"
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC(CMyBottom, CMFCButton)
|
|
|
|
|
|
|
|
|
|
CMyBottom::CMyBottom()
|
|
|
|
|
{
|
|
|
|
|
m_font.CreatePointFont(120,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>",NULL);
|
|
|
|
|
m_TextColor = RGB_BLACK;
|
|
|
|
|
m_DownColor = RGB_GRAY1;
|
|
|
|
|
m_UpColor = RGB_GRAY2;//Ĭ<><C4AC><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
CMyBottom::~CMyBottom()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CMyBottom, CMFCButton)
|
|
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
|
|
|
|
// m_MyImgBtn <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>btn <20><><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ʽ<EFBFBD><CABD>Tooltip <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڰ<EFBFBD>ť<EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|
|
|
|
void CMyBottom::SetButtonStyle(CString Tooltip)
|
|
|
|
|
{
|
|
|
|
|
EnableFullTextTooltip(true);
|
|
|
|
|
// Use the application menu font at the button text font.
|
|
|
|
|
EnableMenuFont();
|
|
|
|
|
// Use the current Windows theme to draw the button borders.
|
|
|
|
|
EnableWindowsTheming(false);
|
|
|
|
|
// Set the button to auto-repeat mode.
|
|
|
|
|
SetAutorepeatMode();
|
|
|
|
|
// Set the background color for the button text.
|
|
|
|
|
//m_CtrlDoorBtn.SetFaceColor(RGB(255,0,0),true);
|
|
|
|
|
|
|
|
|
|
SetFontStyle();
|
|
|
|
|
// Set the tooltip of the button.
|
|
|
|
|
SetTooltip(Tooltip);
|
|
|
|
|
SizeToContent();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
void CMyBottom::SetFontStyle()
|
|
|
|
|
{
|
|
|
|
|
SetFont(&m_font);
|
|
|
|
|
}
|
|
|
|
|
void CMyBottom::Refreash()
|
|
|
|
|
{
|
|
|
|
|
//SetFontStyle();
|
|
|
|
|
}
|
|
|
|
|
void CMyBottom::SetDownColor(COLORREF color)
|
|
|
|
|
{//CMyButton<6F><6E><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>
|
|
|
|
|
m_DownColor = color;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
void CMyBottom::SetUpColor(COLORREF color)
|
|
|
|
|
{
|
|
|
|
|
if(color != m_UpColor)//<2F><>ɫ<EFBFBD>仯<EFBFBD><E4BBAF>ʱ<EFBFBD><CAB1>ˢ<EFBFBD><CBA2><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
{
|
|
|
|
|
m_UpColor = color;
|
|
|
|
|
SetFontStyle();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void CMyBottom::SetTextColor(COLORREF color)
|
|
|
|
|
{
|
|
|
|
|
m_TextColor = color;
|
|
|
|
|
}
|
|
|
|
|
void CMyBottom::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
|
|
|
|
|
{
|
|
|
|
|
CDC dc;
|
|
|
|
|
dc.Attach(lpDrawItemStruct->hDC);//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>CDC
|
|
|
|
|
VERIFY(lpDrawItemStruct->CtlType==ODT_BUTTON);
|
|
|
|
|
//<2F>õ<EFBFBD>Button<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD>:1,<2C>ȵõ<C8B5><C3B5><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>༭<EFBFBD>İ<EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|
|
|
|
|
|
|
|
|
//Ȼ<><EFBFBD><F3BDABB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>»<EFBFBD><C2BB>Ƶ<EFBFBD><C6B5><EFBFBD>ť<EFBFBD><C5A5>,
|
|
|
|
|
//ͬʱ<CDAC><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵı<D6B5><C4B1><EFBFBD>ɫ<EFBFBD><C9AB>Ϊ<CEAA><CDB8>,<2C><><EFBFBD><EFBFBD>,<2C><>ť<EFBFBD>Ͻ<EFBFBD><CFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|
|
|
|
const int bufSize = 512;
|
|
|
|
|
TCHAR buffer[bufSize];
|
|
|
|
|
GetWindowText(buffer, bufSize);
|
|
|
|
|
int size=strlen(buffer);//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
DrawText(lpDrawItemStruct->hDC,buffer,size,&lpDrawItemStruct->rcItem,DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_TABSTOP);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
SetBkMode(lpDrawItemStruct->hDC,TRANSPARENT);//<><CDB8>
|
|
|
|
|
if (lpDrawItemStruct->itemState&ODS_SELECTED)//<2F><><EFBFBD><EFBFBD><EFBFBD>°<EFBFBD>ťʱ<C5A5>Ĵ<EFBFBD><C4B4><EFBFBD>
|
|
|
|
|
{////<2F>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
CBrush brush(m_DownColor);
|
|
|
|
|
dc.FillRect(&(lpDrawItemStruct->rcItem),&brush);//<2F><><EFBFBD>û<EFBFBD>ˢbrush<73><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD>
|
|
|
|
|
//<2F><>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ػ<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҲҪ<D2B2>ػ<EFBFBD>
|
|
|
|
|
DrawText(lpDrawItemStruct->hDC,buffer,size,&lpDrawItemStruct->rcItem,DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_TABSTOP);
|
|
|
|
|
SetBkMode(lpDrawItemStruct->hDC,TRANSPARENT);
|
|
|
|
|
}
|
|
|
|
|
else//<2F><><EFBFBD><EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD>ʱ
|
|
|
|
|
{
|
|
|
|
|
CBrush brush(m_UpColor);
|
|
|
|
|
dc.FillRect(&(lpDrawItemStruct->rcItem),&brush);//
|
|
|
|
|
dc.SetTextColor(m_TextColor);
|
|
|
|
|
DrawText(lpDrawItemStruct->hDC,buffer,size,&lpDrawItemStruct->rcItem,DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_TABSTOP);
|
|
|
|
|
SetBkMode(lpDrawItemStruct->hDC,TRANSPARENT);
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD>Ʊ߿<C6B1>
|
|
|
|
|
{
|
|
|
|
|
COLORREF fc=RGB(255-GetRValue(m_UpColor),255-GetGValue(m_UpColor),255-GetBValue(m_UpColor));
|
|
|
|
|
CBrush brush(fc);
|
|
|
|
|
dc.FrameRect(&(lpDrawItemStruct->rcItem),&brush);//<2F>û<EFBFBD>ˢbrush<73><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>α߿<CEB1>
|
|
|
|
|
}
|
|
|
|
|
}
|