資源簡介
自繪的單選按鈕<br>提供了一個簡單的實現(xiàn),自帶單選位圖。有鼠標滑過響應。
代碼片段和文件信息
//?CustomButton.cpp:?implementation?of?the?CCustomButton?class.
//
//////////////////////////////////////////////////////////////////////
#include?“stdafx.h“
#include?“CustomButton.h“
#include?“colors.h“
//////////////////////////////////////////////////////////////////////
//?Construction/Destruction
//////////////////////////////////////////////////////////////////////
BYTE?CCustomButton::m_cMarkMono[]?=?
{
0x00?0x00?0x00?0x00?0x00?0x00?0x01
0x00?0x00?0x00?0x00?0x00?0x01?0x01
0x01?0x00?0x00?0x00?0x01?0x01?0x01
0x01?0x01?0x00?0x01?0x01?0x01?0x00
0x01?0x01?0x01?0x01?0x01?0x00?0x00
0x00?0x01?0x01?0x01?0x00?0x00?0x00
0x00?0x00?0x01?0x00?0x00?0x00?0x00
};
CCustomButton::CCustomButton()
{
m_crBack?=?XD_COLOR_VIEW_BK;
m_crBorder?=?XD_COLOR_BORDER;
m_crHot?=?XD_COLOR_HOT;
m_crLight?=?XD_COLOR_WHITE;
m_crGrey?=?XD_COLOR_GREY;
m_crText?=?XD_COLOR_BLACK;
m_bBmpBack?=?FALSE;
m_bTracking?=?FALSE;
m_bMouseOver?=?FALSE;
m_bFocused?=?FALSE;
m_bPressed?=?FALSE;
m_bChecked?=?FALSE;
m_bDisabled?=?FALSE;
m_bAlwaysTrack?=?FALSE;
m_bBitmap?=?FALSE;
m_nButtonstyle?=?BS_PUSHBUTTON;
m_nFocusRectMargin?=?1;
}
CCustomButton::~CCustomButton()
{
}
IMPLEMENT_DYNAMIC(CCustomButton?CButton)
BEGIN_MESSAGE_MAP(CCustomButton?CButton)
//{{AFX_MSG_MAP(CCustomButton)
ON_WM_KEYDOWN()
ON_WM_ERASEBKGND()
ON_WM_PAINT()
ON_WM_KILLFOCUS()
ON_WM_SETFOCUS()
ON_WM_MOUSEMOVE()
ON_WM_ACTIVATE()
ON_WM_ENABLE()
ON_WM_CANCELMODE()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_LBUTTONDBLCLK()
ON_WM_CTLCOLOR_REFLECT()
//}}AFX_MSG_MAP
ON_MESSAGE(BM_SETCHECK?OnSetCheck)
ON_MESSAGE(BM_GETCHECK?OnGetCheck)
ON_MESSAGE(BM_SETstyle?OnSetstyle)
ON_MESSAGE(WM_MOUSELEAVE?onmouseleave)
ON_MESSAGE(WM_CUSTOM_SETCHECK?OnCustomSetCheck)
END_MESSAGE_MAP()
void?CCustomButton::PreSubclassWindow()?
{
m_nButtonstyle?=?GetButtonstyle();
if(m_nButtonstyle?==?BS_AUTOCHECKBOX?||?m_nButtonstyle?==?(BS_AUTOCHECKBOX?|?BS_CHECKBOX))
m_nButtonstyle?=?BS_CHECKBOX;
else?if(m_nButtonstyle?==?BS_AUTORADIOBUTTON?||?m_nButtonstyle?==?(BS_AUTORADIOBUTTON?|?BS_RADIOBUTTON))
m_nButtonstyle?=?BS_RADIOBUTTON;
else?
m_nButtonstyle?=?BS_PUSHBUTTON;
m_bChecked?=?CButton::GetCheck(); //?初始化m_bChecked?在實際應用時,可能之類化前已經(jīng)SetCheck過。
CButton::PreSubclassWindow();
Modifystyle(0?BS_OWNERDRAW);
}
BOOL?CCustomButton::OnEraseBkgnd(CDC*?pDC)?
{
return?TRUE;?
}
HBRUSH?CCustomButton::CtlColor(CDC*?pDC?UINT?nCtlColor)
{
return?(HBRUSH)::GetStockobject(NULL_BRUSH);
}
void?CCustomButton::DrawItem(LPDRAWITEMSTRUCT?lpDrawItemStruct)?
{
????ASSERT?(lpDrawItemStruct);
DrawFlatButton(lpDrawItemStruct);
}
LRESULT?CCustomButton::DefWindowProc(UINT?message?WPARAM?wParam?LPARAM?lParam)?
{
if?(message?==?WM_LBUTTONDBLCLK)
{
message?=?WM_LBUTTONDOWN;
}
return?CButton::DefWindowProc(message?wParam?lParam);
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄??????????0??2008-01-24?11:01??res
?????文件????????696??2007-12-26?14:43??res\PIC_RADIOBUTTON_DEMO.exe.manifest
?????文件???????1078??2007-12-25?10:21??res\PIC_RADIOBUTTON_DEMO.ico
?????文件????????412??2007-12-25?10:21??res\PIC_RADIOBUTTON_DEMO.rc2
?????文件???????4412??2007-12-27?10:27??res\Raido_button.bmp
?????文件???????3400??2007-12-04?10:41??Colors.h
?????文件??????13187??2008-01-02?11:08??CustomButton.cpp
?????文件???????2729??2008-01-02?15:00??CustomButton.h
?????文件???????2259??2007-12-25?10:21??PIC_RADIOBUTTON_DEMO.cpp
?????文件???????4788??2008-01-02?17:04??PIC_RADIOBUTTON_DEMO.dsp
?????文件????????563??2007-12-25?10:21??PIC_RADIOBUTTON_DEMO.dsw
?????文件???????1478??2007-12-25?10:21??PIC_RADIOBUTTON_DEMO.h
?????文件???????7160??2008-01-07?16:53??PIC_RADIOBUTTON_DEMO.rc
?????文件???????6294??2008-01-25?13:26??PIC_RADIOBUTTON_DEMODlg.cpp
?????文件???????2085??2008-01-07?16:42??PIC_RADIOBUTTON_DEMODlg.h
?????文件???????1151??2007-12-29?16:34??RadioButtonEx.cpp
?????文件???????1212??2007-12-29?16:34??RadioButtonEx.h
?????文件???????1663??2008-01-07?16:53??resource.h
?????文件????????222??2007-12-25?10:21??StdAfx.cpp
?????文件???????1054??2007-12-25?10:21??StdAfx.h
?????目錄??????????0??2008-01-25?13:39??src
?????文件??????13109??2008-01-25?13:38??src\DibRadioButton.cpp
?????文件???????4957??2008-01-25?13:39??src\DibRadioButton.h
?????文件???????4412??2008-01-07?10:45??src\Raido_button.bmp
?????文件????????748??2008-01-08?14:19??src\使用說明.txt
-----------?---------??----------?-----??----
????????????????79069????????????????????25
- 上一篇:傲文聽力通的KEY
- 下一篇:建立文件數(shù)據(jù)索引的c 代碼
評論
共有 條評論