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

📄 readme.wzd

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

WzdBtmap.cpp -- CWzdBitmap, a bitmap class that converts gray to the selected color
WzdBtmap.h

Also create a long skinny bitmap that will become the new caption. Add this
bitmap to your resources twice--once as IDB_ACTIVE_CAPTION_BITMAP and then
as IDB_INACTIVE_CAPTION_BITMAP.

/////////////////////////////////////////////////////////////////////
// Modify CMainFrame...
/////////////////////////////////////////////////////////////////////

// 1) Add the following to the .h file:

private:
	BOOL m_bActive;
	CWzdBitmap m_bitmapActive;
	CWzdBitmap m_bitmapInactive;
	void DrawTitle();


// 2) Add the following to the constructor:

CMainFrame::CMainFrame()
{
	m_bActive=TRUE;
	m_bitmapActive.LoadBitmapEx(IDB_ACTIVE_CAPTION_BITMAP,GetSysColor(COLOR_ACTIVECAPTION));
	m_bitmapInactive.LoadBitmapEx(IDB_INACTIVE_CAPTION_BITMAP,GetSysColor(COLOR_INACTIVECAPTION));
}

// 3) Prevent the document name from appearing in the caption bar by modifying the
// PreCreateWindow() function like so:

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	// keep flash small
	cs.style &= ~ FWS_ADDTOTITLE;

	return CMDIFrameWnd::PreCreateWindow(cs);
}


// 4) Use the ClassWizard to add a WM_ACTIVATE message handler and fill it in like so:

void CMainFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) 
{
	CMDIFrameWnd::OnActivate(nState, pWndOther, bMinimized);

	// set state and draw title
	m_bActive=(nState!=WA_INACTIVE);
	DrawTitle();
}


// 5) Use the ClassWizard to add a WM_NCPAINT message handler and fill it in like so:

void CMainFrame::OnNcPaint() 
{
	CMDIFrameWnd::OnNcPaint();
	
	// draw title
	DrawTitle();
}

// 6) Use the ClassWizard to add a WM_NCACTIVATE message handler and fill it in like so:

BOOL CMainFrame::OnNcActivate(BOOL bActive) 
{
	BOOL b=CMDIFrameWnd::OnNcActivate(bActive);

	// set state and draw title
	m_bActive=bActive;
	DrawTitle();

	return b;
}

// 7) Also add this function which actually draws the caption:

void CMainFrame::DrawTitle() 
{
	// if window isn't visible or is minimized, skip
	if (!IsWindowVisible() || IsIconic())
		return;

	// get appropriate bitmap
	CDC memDC;
	CDC* pDC = GetWindowDC();
	memDC.CreateCompatibleDC(pDC);
	memDC.SelectObject(m_bActive ?   &m_bitmapActive:&m_bitmapInactive);

	// calculate where to draw caption
	CRect rect, rectWnd;
	GetWindowRect(&rect);
	rect.top += GetSystemMetrics(SM_CYFRAME)+1;						// for small caption use SM_CYDLGFRAME
	rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE)-4;			// for small caption use SM_CYSMSIZE
	rect.left += GetSystemMetrics(SM_CXFRAME) +				 		// for small caption use SM_CXDLGFRAME
							 GetSystemMetrics(SM_CXSIZE);			// for small caption use SM_CXSMSIZE
	rect.right -= GetSystemMetrics(SM_CXFRAME) - 					// for small caption use SM_CXDLGFRAME
								( 3 * 								// set to number of buttons already in caption + 1
							 GetSystemMetrics(SM_CXSIZE))-1;		// for small caption use SM_CXSMSIZE
	GetWindowRect(rectWnd);
	rect.OffsetRect(-rectWnd.left, -rectWnd.top);

	// draw it
	pDC->BitBlt( rect.left, rect.top, rect.Width(), rect.Height(), &memDC, 0, 0, SRCCOPY );

	memDC.DeleteDC();
	ReleaseDC(pDC);
}


/////////////////////////////////////////////////////////////////////
// From: Visual C++ MFC Programming by Example by John E. Swanke
// Copyright (C) 1999 jeswanke. All rights reserved.
/////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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