我从CButton 派生了一个类CDrawButton来实现对话框上的透明浮动按钮
class CDrawButton : public CButton
{
// Construction
public:
CDrawButton();private:
CFont* m_pFont;
CBitmap* m_pBmp;
UINT mBtnStats;
public:
virtual ~CDrawButton();
void SetButtonMode(UINT action, UINT mode);
void Draw(CWnd *pParent);
BOOL Load(UINT nID, CWnd *pParent);
// Generated message map functions
protected:
//{{AFX_MSG(CDrawButton)
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
//}}AFX_MSG DECLARE_MESSAGE_MAP()
};其中: Load如下:
BOOL CDrawButton::Load(UINT nID, CWnd *pParent)
{
if (m_pBmp!=0)
return FALSE; if (!SubclassDlgItem(nID, pParent))
return FALSE; Draw(pParent); return TRUE;
}在对话框中添加了OnMouseMove函数来初始化
void CEgDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_Button.Load(IDC_SET,this);
CDialog::OnMouseMove(nFlags, point);
}
上面的OnMouseMove只能初始化一个按钮,也就是说Load只能运行一次,
我的问题就是:我的对话框上的按钮有多个,怎样来初始化其它的按钮
class CDrawButton : public CButton
{
// Construction
public:
CDrawButton();private:
CFont* m_pFont;
CBitmap* m_pBmp;
UINT mBtnStats;
public:
virtual ~CDrawButton();
void SetButtonMode(UINT action, UINT mode);
void Draw(CWnd *pParent);
BOOL Load(UINT nID, CWnd *pParent);
// Generated message map functions
protected:
//{{AFX_MSG(CDrawButton)
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
//}}AFX_MSG DECLARE_MESSAGE_MAP()
};其中: Load如下:
BOOL CDrawButton::Load(UINT nID, CWnd *pParent)
{
if (m_pBmp!=0)
return FALSE; if (!SubclassDlgItem(nID, pParent))
return FALSE; Draw(pParent); return TRUE;
}在对话框中添加了OnMouseMove函数来初始化
void CEgDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_Button.Load(IDC_SET,this);
CDialog::OnMouseMove(nFlags, point);
}
上面的OnMouseMove只能初始化一个按钮,也就是说Load只能运行一次,
我的问题就是:我的对话框上的按钮有多个,怎样来初始化其它的按钮
建一个句柄数组 CDrawButton m_Button[n];for(int i=0;i<n;i++)
{
m_Button[i].Load(id[i],this);
}