⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wzdstatb.cpp

📁 《vc++扩展编程实例》源码。运用Visual C++ 5.0或6.0的高级编程技巧
💻 CPP
字号:
// WzdStatB.cpp : implementation file
//

#include "stdafx.h"
#include "wzd.h"
#include "WzdStatB.h"
#include "MainFrm.h"

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

/////////////////////////////////////////////////////////////////////////////
// CWzdStatusBar

CWzdStatusBar::CWzdStatusBar()
{
	// load any graphics
	m_hRedLedIcon=AfxGetApp()->LoadIcon(IDI_RED_LED);
	m_hGreenLedIcon=AfxGetApp()->LoadIcon(IDI_GREEN_LED);

}

CWzdStatusBar::~CWzdStatusBar()
{
}


BEGIN_MESSAGE_MAP(CWzdStatusBar, CStatusBar)
	//{{AFX_MSG_MAP(CWzdStatusBar)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CWzdStatusBar message handlers

void CWzdStatusBar::InitDrawing()
{
	UINT nID,nStyle;
	int nPane,nWidth;

	// for each pane that we will be drawing
	nPane=CommandToIndex(ID_INDICATOR_LED);
	GetPaneInfo(nPane, nID, nStyle, nWidth) ;
	SetPaneInfo(nPane, nID, SBPS_OWNERDRAW|SBPS_NOBORDERS, nWidth) ;

}

void CWzdStatusBar::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	// get graphic context to draw to
	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);

	// get the pane's rectangle
	CRect rect(lpDrawItemStruct->rcItem);

	// get the pane's id
	UINT nID,nStyle;
	int nWidth;
	GetPaneInfo(lpDrawItemStruct->itemID, nID, nStyle, nWidth);

	// draw to that pane based on a status
	switch (nID)
	{
		case ID_INDICATOR_LED:
			// draw the background
			CBrush bkColor(GetSysColor(COLOR_3DFACE));
			CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&bkColor);
			pDC->FillRect(rect, &bkColor);
			pDC->SelectObject(pOldBrush);

			// draw the appropriate LED
			HICON hicon=((CMainFrame*)AfxGetMainWnd())->m_bTest?
							m_hRedLedIcon:m_hGreenLedIcon;
			pDC->DrawIcon(rect.left,rect.top,hicon);
			break;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -