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

📄 ngstatusbar.cpp

📁 ResOrg 图形化管理Vc项目的资源ID的工具的源代码。 ResOrg - Manage and Renumber Resource Symbol IDs Introduction The
💻 CPP
📖 第 1 页 / 共 3 页
字号:
		COLORREF	oldFgColor	= pDC->SetTextColor(textColor);
		int			textAlign	= mode & XSB_ALIGN;
		

		CSize s = pDC->GetTextExtent(text);
		pDC->DrawText(text, rect, textAlign|DT_END_ELLIPSIS);
		pDC->SelectObject(oldFont);
		pDC->SetTextColor(oldFgColor);
		pDC->SetBkMode(oldBkMode);
	}

}

/*****************************************************************************
 * Klasse:		CNGStatusBar
 * Funktion:	DrawBitmapPane
 * Parameter:	pDC			Aktueller Device-Kstring[1]
 *				ix			Index des aktuellen Panes
 *				rect		Bounding Rectangle des aktuellen Panes
 *				aktPane		Aktueller Pane
 * Return:		-
 *
 * A bit-map in a Pane outputs. If, gescrollt can this bit-map in horizontal 
 * and/or vertical direction is required. The adjustment can take place left, 
 * on the right or centered or the bit-map can to the current Pane size be adapted 
 * (stretching). With the scrollen several pictures can be secondary or set, 
 * so that a continuous movement develops. 
 ****************************************************************************/
void CNGStatusBar::DrawBitmapPane(CDC *pDC, int ix, CRect& rect, CNGStatusBarPaneInfo& aktPane)
{
	UNUSED_ALWAYS(ix);

	CString		bmString	= aktPane.GetBitmap(on);
	if (bmString.IsEmpty())
		return;
	CDC			memDC;
	memDC.CreateCompatibleDC(pDC);
	CBitmap		bitmap;
	bitmap.LoadBitmap(bmString);
	BITMAP		bm;
	bitmap.GetBitmap(&bm);

	CBitmap		*oldBitmap	= memDC.SelectObject(&bitmap);
	const int	mode		= aktPane.GetMode();
	const int	hScroll		= mode & XSB_HSCROLL;
	const int	vScroll		= mode & XSB_VSCROLL;
	const int	repeat		= mode & XSB_REPEAT;
	const int	stretch		= mode & XSB_STRETCH;

	if (repeat)
	{
		if (hScroll)	
			aktPane.HScroll(rect, bm.bmWidth, 1);

		if (vScroll)	
			aktPane.VScroll(rect, bm.bmHeight, 1);

		if (hScroll && !vScroll)
		{
			for (int x = rect.left; x < rect.right; x += bm.bmWidth)
			{
				pDC->BitBlt(x, rect.top, bm.bmWidth, bm.bmHeight, &memDC, 0, 0, SRCCOPY);
			}
		}
		else if (vScroll && !hScroll)
		{
			for (int y = rect.top; y < rect.bottom; y += bm.bmHeight)
			{
				pDC->BitBlt(rect.left, y, bm.bmWidth, bm.bmHeight, &memDC, 0, 0, SRCCOPY);
			}
		}
		else
		{
			for (int x = rect.left; x < rect.right; x += bm.bmWidth)
			{
				for (int y = rect.top; y < rect.bottom; y += bm.bmHeight)
				{
					pDC->BitBlt(x, y, bm.bmWidth, bm.bmHeight, &memDC, 0, 0, SRCCOPY);
				}
			}
		}
	}
	else
	{
		if (hScroll)	
			aktPane.HScroll(rect, bm.bmWidth, -rect.Width());

		if (vScroll)	
			aktPane.VScroll(rect, bm.bmHeight, -rect.Height());

		if (hScroll || vScroll)
		{
			pDC->BitBlt(rect.left, rect.top, bm.bmWidth, bm.bmHeight, &memDC, 0, 0, SRCCOPY);
		}
		else if (stretch)
		{
			pDC->StretchBlt(rect.left, rect.top, rect.Width(), rect.Height(), &memDC, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
		}
		else
		{
			if (mode & DT_RIGHT)	
				rect.left	= rect.right - bm.bmWidth;

			if (mode & DT_CENTER)	
				rect.left	= (rect.left + rect.right - bm.bmWidth) / 2;

			if (mode & DT_BOTTOM)	
				rect.top	= rect.bottom - bm.bmHeight;

			if (mode & DT_VCENTER)	
				rect.top	= (rect.top + rect.bottom - bm.bmHeight) / 2;

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

	memDC.SelectObject(oldBitmap);
}

/*****************************************************************************
 * Klasse:		CNGStatusBar
 * Funktion:	DrawProgressPane
 * Parameter:	pDC			Aktueller Device-Kstring[1]
 *				ix			Index des aktuellen Panes
 *				rect		Bounding Rectangle des aktuellen Panes
 *				aktPane		Aktueller Pane
 * Return:		-
 *
 * This function draws the progress check. For this only the definition of the size is necessary. 
 ****************************************************************************/
void CNGStatusBar::DrawProgressPane(CDC *pDC, int ix, CRect& rect, CNGStatusBarPaneInfo& aktPane)
{
	UNUSED_ALWAYS(pDC);
	UNUSED_ALWAYS(aktPane);
	rect.InflateRect(1, 1);
	GetProgressCtrl(ix)->MoveWindow(rect, FALSE);
}

/*****************************************************************************
 * Klasse:		CNGStatusBar
 * Funktion:	GetCNGStatusBarPaneInfo
 * Parameter:	ix
 * Return:		CNGStatusBarPaneInfo&
 *
 * This function returns the CNGStatusBarPaneInfo variable for the current Pane as reference,
 * so that the Members of this variables can be changed directly. 
 ****************************************************************************/
CNGStatusBarPaneInfo& CNGStatusBar::GetCNGStatusBarPaneInfo(int ix)
{
	ASSERT(ix < GetCount());
	return paneInfo[ix];
}

/*****************************************************************************
 * Klasse:		CNGStatusBar
 * Funktion:	OnTimer
 * Parameter:	nIDEvent	Aktuelle Timer-Event-ID
 * Return:		-
 *
 * After each timer vent ethose is again drawn status bar.
 ****************************************************************************/
void CNGStatusBar::OnTimer(UINT nIDEvent)
{
	if (nIDEvent == timerID)	Invalidate(FALSE);
}

/*****************************************************************************
 * Klasse:		CNGStatusBar
 * Funktion:	SetStyle, SetWidth, GetStyle, GetWidth, GetID
 * Parameter:	ix		Index des Panes
 *				style	Neuer Style f黵 das Pane
 *				width	Neue Breite f黵 das Pane
 * Return:		Vorheriger Style bzw. vorherige Breite des Panes bzw.
 *				gew黱schter Style
 *
 * Or new width for the indicated Pane sets a new Style or gives the value back 
 * 
 ****************************************************************************/
#define GET_PANE_INFO(ix)	ASSERT(ix < GetCount()); \
UINT id, style; int width; \
GetPaneInfo(ix, id, style, width)

UINT CNGStatusBar::SetStyle(int ix, UINT newStyle)
{
	GET_PANE_INFO(ix);
	SetPaneInfo(ix, id, newStyle, width);
	return style;
}
int  CNGStatusBar::SetWidth(int ix, int newWidth)
{
	GET_PANE_INFO(ix);
	SetPaneInfo(ix, id, style, newWidth);
	return width;
}
UINT CNGStatusBar::GetStyle(int ix)
{
	GET_PANE_INFO(ix);
	return style;
}
int  CNGStatusBar::GetWidth(int ix)
{
	GET_PANE_INFO(ix);
	return width;
}
UINT CNGStatusBar::GetID(int ix)
{
	GET_PANE_INFO(ix);
	return id;
}

#undef GET_PANE_INFO

/*****************************************************************************
 * Klasse:		CNGStatusBar
 * Funktion:	OnDestroy
 * Parameter:	-
 * Return:		-
 *
 * When destroying the status line the timer must be deleted. 
 ****************************************************************************/
void CNGStatusBar::OnDestroy()
{
	if (timerID)	KillTimer(timerID);
	timerID = 0;

	CStatusBar::OnDestroy();
}

/*****************************************************************************
 * Klasse:		CNGStatusBar
 * Funktion:	SavePane, RestorePane
 * Parameter:	ix		Aktueller Paneindex
 * Return:		-
 *
 * With these two functions the current status of a Panes can be restored 
 * temporarly secured and at a later point in time again, or into another Pane 
 * to be copied. This is then meaningful for example if in a Pane temporarily 
 * to another mode (for example a progress bar) is switched. For each Pane 
 * a buffer is available.
 ****************************************************************************/
void CNGStatusBar::SavePane(int ix)
{
	ASSERT(ix < GetCount());

	CNGStatusBarPaneInfo	value;
	if (!buffer.Lookup(ix, value))
		buffer[ix] = paneInfo[ix];
}

void CNGStatusBar::RestorePane(int ix)
{
	ASSERT(ix < GetCount());

	CNGStatusBarPaneInfo	value;
	if (buffer.Lookup(ix, value))
	{
		paneInfo[ix] = value;
		buffer.RemoveKey(ix);
	}

	Invalidate(FALSE);
}

/*****************************************************************************
 * Klasse:		CNGStatusBar
 * Funktion:	GetPaneAtPosition
 * Parameter:	point		Aktuelle Mausposition
 * Return:		Index des Panes, der unter der Maus liegt
 *
 * With this function one tests, which is to Pane under the mouse and which 
 * index of this Panes returned. It must be noted that the mouse position 
 * must be transferred to the status line in Client coordinates. If the father 
 * window is a dialog, a coordinate adjustment must be executed before the position 
 * examination. 
 ****************************************************************************/
int CNGStatusBar::GetPaneAtPosition(CPoint& point)
{
	if (pParent->IsKindOf(RUNTIME_CLASS(CDialog)))
	{
		pParent->ClientToScreen(&point);
		ScreenToClient(&point);
	}

	CRect rect;
	for (int i = 0, n = GetCount(); i < n; i++)
	{
		GetItemRect(i, rect);
		if (rect.PtInRect(point))	return i;
	}

	return -1;
}

/*****************************************************************************
 * Klasse:		CNGStatusBar
 * Funktion:	OnLButtonUp, OnMButtonUp, OnRButtonUp, OnMouseMove,
 *				OnLButtonDown, OnMButtonDown, OnRButtonDown,
 *				OnLButtonDblClk, OnMButtonDblClk, OnRButtonDblClk
 * Parameter:	nFlags		Zusatztasten bei der Mausoperation
 *				point		Aktuelle Mausposition
 * Return:		-
 *
 * These mouse functions pass the message on directly to the parent window. 
 * 
 ****************************************************************************/
#define TO_PARENT(fkt, event)	\
void CNGStatusBar::fkt(UINT nFlags, CPoint point) \
{ \
pParent->SendMessage(event, (WPARAM) nFlags, MAKELPARAM(point.x, point.y)); \
CStatusBar::fkt(nFlags, point); \
}

TO_PARENT(OnLButtonUp,		WM_LBUTTONUP);
TO_PARENT(OnMButtonUp,		WM_MBUTTONUP);
TO_PARENT(OnRButtonUp,		WM_RBUTTONUP);
TO_PARENT(OnLButtonDown,	WM_LBUTTONDOWN);
TO_PARENT(OnMButtonDown,	WM_MBUTTONDOWN);
TO_PARENT(OnRButtonDown,	WM_RBUTTONDOWN);
TO_PARENT(OnLButtonDblClk,	WM_LBUTTONDBLCLK);
TO_PARENT(OnMButtonDblClk,	WM_MBUTTONDBLCLK);
TO_PARENT(OnRButtonDblClk,	WM_RBUTTONDBLCLK);
TO_PARENT(OnMouseMove,		WM_MOUSEMOVE);

#undef TO_PARENT

BOOL CNGStatusBar::OnEraseBkgnd(CDC* pDC) 
{
	UNUSED_ALWAYS(pDC);
	
	return TRUE;//CMDIFrameWnd::OnEraseBkgnd(pDC);
}


/////////////////////////////////////////////////////////////////////////////
// Tool tip operations
void CNGStatusBar::AddToolTip(LPCTSTR lpszText, LPCRECT lpRectTool, UINT nIDTool)
{
	m_ToolTip.AddTool(this, lpszText, lpRectTool, nIDTool);
}

void CNGStatusBar::SetToolRects()
{
	CRect rect;
	for (int i = 1, n = GetCount(); i < n; i++)
	{
		GetItemRect(i, &rect);
		m_ToolTip.SetToolRect(this, i, &rect);
	}
}

void CNGStatusBar::UpdateTipText(LPCTSTR lpszText, UINT nIDTool)
{
	m_ToolTip.UpdateTipText(lpszText, this, nIDTool);
}

void CNGStatusBar::DeleteToolTip(UINT nIDTool)
{
	m_ToolTip.DelTool(this, nIDTool);
}

⌨️ 快捷键说明

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