You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
140 lines
2.9 KiB
140 lines
2.9 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: VideoWnd.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of VideoWnd.cpp
|
|
//----------------------------------------------------------------------------
|
|
// VideoWnd.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "setupcld.h"
|
|
#include "VideoWnd.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CVideoWnd
|
|
|
|
CVideoWnd::CVideoWnd()
|
|
{
|
|
}
|
|
|
|
CVideoWnd::~CVideoWnd()
|
|
{
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CVideoWnd, CWnd)
|
|
//{{AFX_MSG_MAP(CVideoWnd)
|
|
ON_WM_SIZE()
|
|
ON_WM_PAINT()
|
|
//}}AFX_MSG_MAP
|
|
ON_MESSAGE( WM_VIDEO_SAMPLE, OnVideoSample )
|
|
END_MESSAGE_MAP()
|
|
|
|
BOOL CVideoWnd::Create( CWnd *pParentWnd, int x, int y, int nWidth, int nHeight )
|
|
{
|
|
DestroyWindow();
|
|
|
|
CRect rect( x, y, x + nWidth, y + nHeight );
|
|
CString strClassName = ::AfxRegisterWndClass( CS_HREDRAW | CS_VREDRAW, ::LoadCursor( NULL, IDC_ARROW ), NULL, NULL );
|
|
if( !CWnd::Create( strClassName, "", WS_CHILD | WS_VISIBLE, rect, pParentWnd, 0 ) )
|
|
return FALSE;
|
|
|
|
SetCross();
|
|
return TRUE;
|
|
}
|
|
|
|
void CVideoWnd::OnVideoSample( double SampleTime )
|
|
{
|
|
// pos message to window
|
|
if( GetSafeHwnd() )
|
|
::PostMessage( GetSafeHwnd(), WM_VIDEO_SAMPLE, 0, 0 );
|
|
}
|
|
|
|
LRESULT CVideoWnd::OnVideoSample( WPARAM wParam, LPARAM )
|
|
{
|
|
InvalidateRect( NULL );
|
|
return 0;
|
|
}
|
|
|
|
BOOL CVideoWnd::DestroyWindow()
|
|
{
|
|
// unlink from direct show stream
|
|
CDirectShowVideo::Unlink();
|
|
|
|
CLgDirectDrawVideo::OnDestroy();
|
|
|
|
return CWnd::DestroyWindow();
|
|
}
|
|
|
|
void CVideoWnd::OnSize(UINT nType, int cx, int cy)
|
|
{
|
|
CWnd::OnSize(nType, cx, cy);
|
|
|
|
CLgDirectDrawVideo::OnSize( GetSafeHwnd() );
|
|
}
|
|
|
|
void CVideoWnd::OnDraw( CDC *pDC )
|
|
{
|
|
CLgDirectDrawVideo::OnPaint( TRUE );
|
|
}
|
|
|
|
void CVideoWnd::OnPaint()
|
|
{
|
|
CPaintDC dc(this); // device context for painting
|
|
|
|
OnDraw( &dc );
|
|
}
|
|
|
|
void CVideoWnd::SetCross()
|
|
{
|
|
if( !GetSafeHwnd() )
|
|
return;
|
|
|
|
CRect rect;
|
|
GetClientRect( &rect );
|
|
|
|
const int L1 = 2;
|
|
const int L2 = 20;
|
|
|
|
int W1 = L1;
|
|
int H1 = L2;
|
|
int W2 = L2;
|
|
int H2 = L1;
|
|
|
|
int x1 = ( rect.Width() - W1 ) / 2;
|
|
int y1 = ( rect.Height() - H1 ) / 2;
|
|
|
|
int x2 = ( rect.Width() - W2 ) / 2;
|
|
int y2 = ( rect.Height() - H2 ) / 2;
|
|
|
|
CRect frame1( x1, y1, x1 + W1, y1 + H1 );
|
|
CRect frame2( x2, y2, x2 + W2, y2 + H2 );
|
|
|
|
CRgn rgn;
|
|
rgn.CreateRectRgnIndirect( &rect );
|
|
|
|
CRgn rgn1;
|
|
rgn1.CreateRectRgnIndirect( frame1 );
|
|
CRgn rgn2;
|
|
rgn2.CreateRectRgnIndirect( frame2 );
|
|
|
|
rgn.CombineRgn( &rgn, &rgn1, RGN_DIFF );
|
|
rgn.CombineRgn( &rgn, &rgn2, RGN_DIFF );
|
|
|
|
SetWindowRgn( (HRGN)rgn.GetSafeHandle(), TRUE );
|
|
}
|
|
|