You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
1.6 KiB
C++

#include "stdafx.h"
#include "MyPictrueBttom.h"
#include "GlobalDefine.h"
IMPLEMENT_DYNAMIC(CMyPictrueBttom, CMFCButton)
BEGIN_MESSAGE_MAP(CMyPictrueBttom, CMFCButton)
END_MESSAGE_MAP()
CMyPictrueBttom::CMyPictrueBttom()
{
m_CurPicType = _EPicType_1;//当前的类型
m_PictrueId1 = 0;
m_PictrueId2 = 0;
m_PictrueId3 = 0;
m_PictrueId4 = 0;
m_font.CreatePointFont(100,"宋体",NULL);
}
CMyPictrueBttom::~CMyPictrueBttom()
{
}
void CMyPictrueBttom::Refresh()
{
SetFont(&m_font);
}
void CMyPictrueBttom::SetCurPicType(EPicType t)
{
//无变化
if(m_CurPicType == t)
return;
m_CurPicType = t;
int PictrueId = 0;
switch(t)
{
case _EPicType_1:
PictrueId = m_PictrueId1;
break;
case _EPicType_2:
PictrueId = m_PictrueId2;
break;
case _EPicType_3:
PictrueId = m_PictrueId3;
break;
case _EPicType_4:
PictrueId = m_PictrueId4;
break;
default:
break;
}
if(PictrueId!=0)
{
SetImage(PictrueId);
//刷新显示
Refresh();
}
}
//屏蔽键盘操作
BOOL CMyPictrueBttom::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message==WM_KEYDOWN)
{
char c = pMsg->wParam;
if(c==VK_RETURN || c==VK_ESCAPE)
{
return TRUE;
}
}
return CMFCButton::PreTranslateMessage(pMsg);
}
//适用只有ON/OFF的按钮
void CMyPictrueBttom::SetPictrueByBool(bool b)
{
if(b)
{
SetCurPicType(_EPicType_2);
}
else
{
SetCurPicType(_EPicType_1);
}
}