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

📄 ~selstatic.~cpp

📁 实时监控
💻 ~CPP
字号:
// SelStatic.cpp : implementation file
//

#include "stdafx.h"
#include "../dvrmanager.h"
#include "SelStatic.h"
#include "memdc.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSelStatic
CSelStatic* CSelStatic::cur_sel = NULL;
CSelStatic* CSelStatic::def = NULL;

CSelStatic::CSelStatic(): frcl(norm_fr)
{
	ZeroMemory(&lf, sizeof(lf));
}

CSelStatic::~CSelStatic()
{
}


BEGIN_MESSAGE_MAP(CSelStatic, selstatic_base)
	//{{AFX_MSG_MAP(CSelStatic)
	ON_WM_LBUTTONDOWN()
	ON_WM_PAINT()
	ON_WM_ERASEBKGND()
	ON_WM_LBUTTONDBLCLK()
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSelStatic message handlers

CString CSelStatic::get_title() const
{
	return title;
}

void CSelStatic::set_title(LPCTSTR t)
{
	title = t;
	RedrawWindow();
}

void CSelStatic::draw_sel()
{
	CSelStatic* p = cur_sel;
	if( p )
	{
		cur_sel->draw_unsel();
	}
	cur_sel = this;
	
	//ModifyStyleEx(0, WS_EX_CLIENTEDGE, SWP_DRAWFRAME);
	frcl = sel_fr;
	RedrawWindow();

	on_sel();
	if( p )
		p->on_unsel();
}

void CSelStatic::draw_unsel()
{
	cur_sel = NULL;
	
	frcl = norm_fr;
	RedrawWindow();
	cur_sel = this;
	//ModifyStyleEx(WS_EX_CLIENTEDGE, 0, SWP_DRAWFRAME);

//	on_unsel();
}

bool CSelStatic::is_sel() const
{
	return cur_sel == this;
}

void CSelStatic::toggle_sel()
{
	if( is_sel() )
		draw_unsel();
	else
		draw_sel();
}

void CSelStatic::clear_sel()
{
	if( cur_sel )
		cur_sel->draw_unsel();
	cur_sel = NULL;
}

void CSelStatic::OnLButtonDown(UINT nFlags, CPoint point) 
{
	if( is_fulled() )
		restore();
	else
		toggle_sel();
	selstatic_base::OnLButtonDown(nFlags, point);
}

void CSelStatic::OnPaint() 
{
	if( !IsWindowVisible() )
		return;

	if( !is_fulled() )
	{
		CClientDC dc(GetParent());
		CRect rc;
		GetWindowRect(rc);
		GetParent()->ScreenToClient(rc);
		
		rc.InflateRect(1,1,1,1);
		dc.FrameRect(rc, &CBrush(frcl));
	}
	CPaintDC pdc(this); // device context for painting
	CRect rc;
	GetClientRect(rc);
	
	// 涂黑窗口
	CMemDC dc(&pdc, rc);
	dc.FillRect(rc, &CBrush(bkcl));

	// 画窗口标题
	CFont* old = NULL;
	if( !lf.lfHeight )
	{
		old = GetParent()->GetFont();
		old->GetLogFont(&lf);
	}
	if( is_sel() )
		lf.lfWeight = FW_HEAVY;
	else
		lf.lfWeight = FW_BOLD;

	CFont ft;
	ft.CreateFontIndirect(&lf);

	old = dc.SelectObject(&ft);
	if( is_sel() )
		dc.SetTextColor(RGB(255,255,255));
	else
		dc.SetTextColor(cltext);
	dc.SetBkMode(TRANSPARENT);
	dc.TextOut(title_x,title_y,title);
	
	dc.SelectObject(old);
}
#include "memdc.h"
#include "logfont.h"

BOOL CSelStatic::OnEraseBkgnd(CDC* pDC) 
{
	return TRUE;
}

void CSelStatic::OnLButtonDblClk(UINT nFlags, CPoint point) 
{
	full_scr();
	selstatic_base::OnLButtonDblClk(nFlags, point);	
}


void CSelStatic::restore()
{
	selstatic_base::restore();
	clear_sel();
}

void CSelStatic::clear_wnd()
{
	SetTimer(1, 200, NULL);
}

void CSelStatic::OnTimer(UINT nIDEvent) 
{
	if( nIDEvent == 1 )		// clear window
	{
		KillTimer(1);
		RedrawWindow();
	}
	selstatic_base::OnTimer(nIDEvent);
}

⌨️ 快捷键说明

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