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

📄 video.cpp

📁 vc ad
💻 CPP
字号:
// Video.cpp : implementation file
//

#include "stdafx.h"
#include "Card.h"
#include "cardtest.h"
#include "preview.h"
#include "Video.h"

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

int UpdateScreen();

/////////////////////////////////////////////////////////////////////////////
// CVideo dialog
CVideo::CVideo(CWnd* pParent, CCard *pCard)
	: CDialog(CVideo::IDD, pParent)
{
	//{{AFX_DATA_INIT(CVideo)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_pCard=pCard;
	m_OverlayMode=0;
	m_Channel=0;
	m_OverlayMode=2;
	m_pParent=(CPreview*)pParent;
}


void CVideo::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CVideo)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CVideo, CDialog)
	//{{AFX_MSG_MAP(CVideo)
	ON_WM_CLOSE()
	ON_WM_PAINT()
	ON_WM_WINDOWPOSCHANGING()
	ON_WM_WINDOWPOSCHANGED()
	ON_WM_ACTIVATE()
	ON_WM_SIZE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CVideo message handlers

void CVideo::OnOK() 
{
	// TODO: Add extra validation here
	
//	CDialog::OnOK();
}

BOOL CVideo::Create()
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CDialog::Create(IDD);
}

BOOL CVideo::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	nXBorder=GetSystemMetrics(SM_CXSIZEFRAME);
	nYBorder=GetSystemMetrics(SM_CYSIZEFRAME);
	nYHeader=GetSystemMetrics(SM_CYSIZEFRAME)+GetSystemMetrics(SM_CYMENU);
	nXScreen=GetSystemMetrics(SM_CXSCREEN);
	nYScreen=GetSystemMetrics(SM_CYSCREEN);
	SetWindowPos(NULL, 
		0,
		0,
		320+nXBorder*2,
		288+nYBorder+nYHeader,
		SWP_NOZORDER);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CVideo::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	m_pCard->Overlay(NULL, 0, FALSE);
	CDialog::OnClose();
	m_pParent->VideoClosed();
}

void CVideo::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	CBrush* pbsOld;
	CBrush bsCyan;
	CRgn rgn;
	//create a cran brush
	bsCyan.CreateSolidBrush(RGB(255,0,255));
	pbsOld=(CBrush*)dc.SelectObject(bsCyan);
	//paint the whole dialog
	rgn.CreateRectRgn(0,0,
		nXScreen,
		nYScreen);
	dc.PaintRgn(&rgn);
	
	// Do not call CDialog::OnPaint() for painting messages
}

void CVideo::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) 
{
	CDialog::OnWindowPosChanging(lpwndpos);
	// TODO: Add your message handler code here
	if(!(lpwndpos->flags&SWP_NOMOVE)){
		if(lpwndpos->x<0)
			lpwndpos->x=0;
		if(lpwndpos->y<0)
			lpwndpos->y=0;
		if(lpwndpos->x+lpwndpos->cx>nXScreen)
			lpwndpos->x=nXScreen-lpwndpos->cx;
		if(lpwndpos->y+lpwndpos->cy>nYScreen)
			lpwndpos->y=nYScreen-lpwndpos->cy;
	}
	if(!(lpwndpos->flags&SWP_NOSIZE)){
		if(lpwndpos->cx>720+nXBorder*2)
			lpwndpos->cx=720+nXBorder*2;
		if(lpwndpos->cy>576+nYBorder+nYHeader)
			lpwndpos->cy=576+nYBorder+nYHeader;
	}
	if(m_OverlayMode==1 &&
		lpwndpos->flags&(SWP_NOACTIVATE))
		//when primary mode and the window isn't active close preview
		m_pCard->Overlay(NULL, 0, FALSE);
	else
		DoOverlay();	
}

void CVideo::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos) 
{
	CDialog::OnWindowPosChanged(lpwndpos);
	// TODO: Add your message handler code here

	if(m_OverlayMode==2 ||
		!(lpwndpos->flags&(SWP_NOACTIVATE)))
		//when primary mode and the window isn't active close preview
		//CloseOverlay();
	//else
		DoOverlay();	
}

void CVideo::OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized)
{
	// TODO: Add your specialized code here and/or call the base class
	if(m_OverlayMode==1 && nState==WA_INACTIVE)
		//if primary mode and the window is inactive close preview
		m_pCard->Overlay(NULL, 0, FALSE);
	if(m_OverlayMode==2 && nState!=WA_INACTIVE)
		UpdateScreen();
	CDialog::OnActivate(nState, pWndOther, bMinimized);
}

void CVideo::DoOverlay()
{
	RECT rect;
	GetWindowRect(&rect);
	rect.left+=nXBorder;
	rect.left&=0xfffffffe;
	rect.right-=nXBorder;
	rect.top+=nYHeader;
	rect.bottom-=nYBorder;
	if(rect.left<0 || rect.top<0)
		return;
	m_pCard->Overlay(&rect, m_Channel, TRUE);
}

void CVideo::SetChannel(int nChannel)
{
	m_Channel=nChannel;
	InvalidateRect(NULL);
	DoOverlay();
}

void CVideo::SetOverlayMode(int nMode)
{
	m_OverlayMode=nMode;
	InvalidateRect(NULL);
	DoOverlay();
}

void CVideo::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	if(nType==SIZE_MAXIMIZED)
		MoveWindow(0, 0, 720+nXBorder*2, 576+nYBorder+nYHeader);
}

⌨️ 快捷键说明

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