Old fashion design for PC-104
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.
 
 
 
 
 

108 lines
2.8 KiB

//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright © 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 04/03/2003
// PROJECT:
// SUBSYSTEM:
// FILE: DSWnd.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of DSWnd.cpp
//----------------------------------------------------------------------------
#include "stdafx.h"
#include <stdio.h>
#include "DSWnd.h"
CDSVideoWnd::CDSVideoWnd()
{
::CoInitializeEx( NULL, COINIT_MULTITHREADED );
m_pVideoWindow = NULL;
}
CDSVideoWnd::~CDSVideoWnd()
{
FreeDirectShow();
::CoUninitialize();
}
BOOL CDSVideoWnd::Create( HWND hWndParent, int x, int y, int nWidth, int nHeight, CDSVideoProcessor *pDSVideoProcessor )
{
LPCTSTR lpClassName = _T("DirectShowWndClass");
if( !CGenericWnd::RegisterClass( lpClassName, (HINSTANCE)::GetWindowLong( hWndParent, GWL_HINSTANCE ), CS_HREDRAW | CS_VREDRAW ) )
return FALSE;
if( !CGenericWnd::Create( lpClassName, "", WS_CHILD | WS_VISIBLE, x, y, nWidth, nHeight, hWndParent, NULL, NULL ) )
return FALSE;
if( !pDSVideoProcessor->ConnectVideoWnd( &m_pVideoWindow ) )
return FALSE;
HRESULT hr = m_pVideoWindow->put_Owner( (OAHWND) GetSafeHwnd() );
if( FAILED( hr ) )
return FALSE;
hr = m_pVideoWindow->put_WindowStyle( WS_CHILD | WS_CLIPCHILDREN );
if( FAILED( hr ) )
return FALSE;
RECT rect;
if( !GetClientRect( &rect ) )
return FALSE;
hr = m_pVideoWindow->SetWindowPosition( rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top );
if( FAILED( hr ) )
return FALSE;
hr = m_pVideoWindow->put_AutoShow( OAFALSE );
if( FAILED( hr ) )
return FALSE;
hr = m_pVideoWindow->put_Visible( OATRUE );
if( FAILED( hr ) )
return FALSE;
hr = m_pVideoWindow->put_MessageDrain( (OAHWND)GetSafeHwnd() );
if( FAILED( hr ) )
return FALSE;
return TRUE;
}
LRESULT CDSVideoWnd::OnDestroy( WPARAM wParam, LPARAM lParam )
{
FreeDirectShow();
return CGenericWnd::OnDestroy( wParam, lParam );
}
BOOL CDSVideoWnd::DestroyWindow()
{
FreeDirectShow();
return CGenericWnd::DestroyWindow();
}
void CDSVideoWnd::FreeDirectShow()
{
if( m_pVideoWindow )
{
m_pVideoWindow->Release();
m_pVideoWindow = NULL;
}
}
LRESULT CDSVideoWnd::OnSize( WPARAM wParam, LPARAM lParam )
{
if( !m_pVideoWindow )
return CGenericWnd::OnSize( wParam, lParam );
RECT rect;
::SetRect( &rect, 0, 0, LOWORD( lParam ), HIWORD( lParam ) );
::MapWindowPoints( GetSafeHwnd(), HWND_DESKTOP, (LPPOINT)&rect, 2 );
m_pVideoWindow->SetWindowPosition( rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top );
return CGenericWnd::OnSize( wParam, lParam );
}