怎样改变工具栏的背景色?

newHung 2006-08-17 10:51:31
怎样改变工具栏的背景色?请各位大侠指点.多谢!
...全文
797 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
cleverwyq 2006-08-17
  • 打赏
  • 举报
回复
第一个是头文件,第二个是实现

关键是继承CToolBar,重载OnEraseBkGnd函数

然后把cmainframe里面的Ctoolbar成员类型改成你的新类
cleverwyq 2006-08-17
  • 打赏
  • 举报
回复
// ToolBarEx.cpp : implementation file
//

#include "stdafx.h"
#include "FormV.h"
#include "ToolBarEx.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CToolBarEx

CToolBarEx::CToolBarEx()
{
}

CToolBarEx::~CToolBarEx()
{
}


BEGIN_MESSAGE_MAP(CToolBarEx, CToolBar)
//{{AFX_MSG_MAP(CToolBarEx)
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CToolBarEx message handlers

BOOL CToolBarEx::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
CBrush brush(RGB(0,255,0));
CRect r;
GetClientRect(&r);
pDC->FillRect(&r,&brush);
return TRUE;
}
cleverwyq 2006-08-17
  • 打赏
  • 举报
回复
#if !defined(AFX_TOOLBAREX_H__2FAF4DF2_DD0C_4D08_BC3B_81577D01407F__INCLUDED_)
#define AFX_TOOLBAREX_H__2FAF4DF2_DD0C_4D08_BC3B_81577D01407F__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ToolBarEx.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CToolBarEx window

class CToolBarEx : public CToolBar
{
// Construction
public:
CToolBarEx();

// Attributes
public:

// Operations
public:

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CToolBarEx)
//}}AFX_VIRTUAL

// Implementation
public:
virtual ~CToolBarEx();

// Generated message map functions
protected:
//{{AFX_MSG(CToolBarEx)
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
//}}AFX_MSG

DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_TOOLBAREX_H__2FAF4DF2_DD0C_4D08_BC3B_81577D01407F__INCLUDED_)
Featured 2006-08-17
  • 打赏
  • 举报
回复
重载,修改OnEraseBkGnd或者OnPaint、DrawItem之类的函数
VC里面都这样做
newHung 2006-08-17
  • 打赏
  • 举报
回复
谢谢,谢谢

15,980

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧