首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

调用自定义类的消息函数有关问题

2013-12-09 
调用自定义类的消息函数问题。走过路过的兄弟姐妹,帮个小忙看看啦在工程PC_COMMON建了个基类CBASEBASE,CBAS

调用自定义类的消息函数问题。
走过路过的兄弟姐妹,帮个小忙看看啦
在工程PC_COMMON建了个基类CBASEBASE,CBASEBASE定义了消息映射函数OnCtlColor
.h文件
class CBASEBASE : public CDialog
{
public:
CBASEBASE(UINT nID=0,CWnd *pParent=NULL);
    ~CBASEBASE();
BOOL SetNeedInput(UINT uID);
virtual BOOL OnInitDialog();
protected:
char cNeedInputNum;
int  nNeedINputNumID[100];
static COLORREF m_rgbColorArray[MSGBOX_ITEM+1][2];
static CBrush m_brColorArray[MSGBOX_ITEM+1];
    UINT m_nDlgID;  // 画面ID
static int GetRgtFromIni();
// Generated message map functions
//{{AFX_MSG(CBASEBASE)
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
.CPP文件
BEGIN_MESSAGE_MAP(CBASEBASE,CDialog)
//{{AFX_MSG_MAP(CBASEBASE)
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

HBRUSH CBASEBASE::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
UINT uID=pWnd->GetDlgCtrlID();
// TODO: Change any attributes of the DC here
//HBRUSH brush;
switch(nCtlColor)
{
case CTLCOLOR_DLG:
pDC->SetBkMode(TRANSPARENT);
//brush=CreateSolidBrush(CBASEBASE::m_rgbColorArray[DIALOGBK_ITEM][0]);
//return  brush;
return  CBASEBASE::m_brColorArray[DIALOGBK_ITEM];
case CTLCOLOR_EDIT:
for(int i=0;i<cNeedInputNum;i++)
{
if(nNeedINputNumID[i]==(int)uID)
{
pDC->SetTextColor(CBASEBASE::m_rgbColorArray[NEEDINPUT_ITEM][1]);
pDC->SetBkColor(CBASEBASE::m_rgbColorArray[NEEDINPUT_ITEM][0]);
//brush=CreateSolidBrush(CBASEBASE::m_rgbColorArray[NEEDINPUT_ITEM][0]);
//return  brush;
return CBASEBASE::m_brColorArray[NEEDINPUT_ITEM];
}
}
}
// TODO: Return a different brush if the default is not desired
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
return hbr;
}
[解决办法]
“CBASEBASE类不同工程的对话框(CDIALOGTEST2)”
要 继承: class CDIALOGTEST2 : public CBASEBASE
[解决办法]
“另外一个不同工程用”
不明白 ?

热点排行