📄 mystatusbar.cpp
字号:
// Written by JHCC, 1997
#include "stdafx.h"
#include "MyStatusBar.h"
#include "resource.h"
#include "jhhbdoc.h"
// Constructor
CMyStatusBar::CMyStatusBar()
{
}
// Destructor
CMyStatusBar::~CMyStatusBar()
{
}
void CMyStatusBar::InitStatusBar(UINT idCommand)
{
// Make a new font.
CFont* pFont = GetFont();
LOGFONT logFont;
pFont->GetLogFont(&logFont);
logFont.lfHeight *= 2;
CFont font;
VERIFY(font.CreateFontIndirect(&logFont));
SetFont(&font, TRUE);
// Set the fourth part to be owner-drawn.
GetStatusBarCtrl().SetText(_T(""), CommandToIndex(idCommand), SBT_OWNERDRAW);
// Recalc the layout of the panes in the statusbar.
GetParentFrame()->RecalcLayout();
}
void CMyStatusBar::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// Load the bitmap for the owner-drawn part of the status bar.
HBITMAP hBitmap;
if (CCtrlInfoObject::m_nCurWorkStation == -1)
hBitmap = ::LoadBitmap(AfxGetResourceHandle(), MAKEINTRESOURCE(IDB_GREEN_SEMAPHORE));
else
hBitmap = ::LoadBitmap(AfxGetResourceHandle(), MAKEINTRESOURCE(IDB_RED_SEMAPHORE));
// Create a compatible DC for the bit block transfer.
HDC hdcMem = ::CreateCompatibleDC(lpDrawItemStruct->hDC);
// Select the bitmap into the DC.
HBITMAP hbmOld = (HBITMAP)::SelectObject(hdcMem, hBitmap);
BITMAP bm;
// Get the information about the bitmap's size.
::GetObject(hBitmap, sizeof(bm), &bm);
// Use BitBlt to transfer the bitmap.
::BitBlt(lpDrawItemStruct->hDC,
lpDrawItemStruct->rcItem.left+2,
lpDrawItemStruct->rcItem.top+2,
bm.bmWidth,
bm.bmHeight,
hdcMem, 0, 0,
SRCCOPY);
// Reselect the original bitmap.
::SelectObject(hdcMem, hbmOld);
// Delete the compatible DC.
::DeleteDC(hdcMem);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -