📄 showtop.cpp
字号:
// ShowTop.cpp : implementation file
//
#include "stdafx.h"
#include "SuperViseSystem.h"
#include "ShowTop.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CShowTop
CShowTop::CShowTop()
{
close_rect.left = 976;
close_rect.top = 7;
close_rect.right = 1005;
close_rect.bottom = 35;
min_rect.left = 900;
min_rect.top = 7;
min_rect.right = 928;
min_rect.bottom = 35;
m_bIsSetImage = true;
}
CShowTop::~CShowTop()
{
}
BEGIN_MESSAGE_MAP(CShowTop, CWnd)
//{{AFX_MSG_MAP(CShowTop)
ON_WM_LBUTTONDOWN()
ON_WM_PAINT()
// ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CShowTop message handlers
BOOL CShowTop::Create(DWORD dwStyle, CRect& rect, CWnd* pParent, UINT id)
{
BOOL result ;
result = CWnd::CreateEx(NULL ,
NULL, NULL, dwStyle,
rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
pParent->GetSafeHwnd(), (HMENU)id) ;
if( !result )
AfxMessageBox("Error creating window");
m_rcImgWnd.top = m_rcImgWnd.left = 0;
m_rcImgWnd.bottom = m_rcImgWnd.top + rect.Height();
m_rcImgWnd.right = m_rcImgWnd.left + rect.Width();
//m_MemDC为CDC类的一个对象.
m_MemDC.CreateCompatibleDC(GetDC());// 创建什么东西?
return result;
}
//-----------
void CShowTop::SetImage(HBITMAP *hbp)
{
m_bpImageWnd.Attach(hbp);
m_bIsSetImage = true;
this->Invalidate();
}
//-----------
void CShowTop::OnPaint()
{
CPaintDC dc(this);
if(m_bIsSetImage)
{
m_MemDC.SelectObject(m_bpImageWnd);
dc.BitBlt(0,0,m_rcImgWnd.Width(),m_rcImgWnd.Height(),&m_MemDC,0,0,SRCCOPY);
}
}
//-----------
void CShowTop::OnLButtonDown(UINT nFlags, CPoint point)
{
//窗口关闭
if (((close_rect.left < point.x) && (point.x< close_rect.right)) &&
(close_rect.top < point.y) && (point.y < close_rect.bottom))
{
AfxGetMainWnd()->PostMessage(WM_CLOSE);
}
//窗口最小化
if((point.x > min_rect.left) && (point.x < min_rect.right) &&
(point.y > min_rect.top) && (point.y < min_rect.bottom))
{
AfxGetMainWnd()->PostMessage(WM_SYSCOMMAND,SC_MINIMIZE,0);
}
CWnd::OnLButtonDown(nFlags, point);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -