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

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 04/03/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: DSWnd.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of DSWnd.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include <stdio.h>
  16. #include "DSWnd.h"
  17. CDSVideoWnd::CDSVideoWnd()
  18. {
  19. ::CoInitializeEx( NULL, COINIT_MULTITHREADED );
  20. m_pVideoWindow = NULL;
  21. }
  22. CDSVideoWnd::~CDSVideoWnd()
  23. {
  24. FreeDirectShow();
  25. ::CoUninitialize();
  26. }
  27. BOOL CDSVideoWnd::Create( HWND hWndParent, int x, int y, int nWidth, int nHeight, CDSVideoProcessor *pDSVideoProcessor )
  28. {
  29. LPCTSTR lpClassName = _T("DirectShowWndClass");
  30. if( !CGenericWnd::RegisterClass( lpClassName, (HINSTANCE)::GetWindowLong( hWndParent, GWL_HINSTANCE ), CS_HREDRAW | CS_VREDRAW ) )
  31. return FALSE;
  32. if( !CGenericWnd::Create( lpClassName, "", WS_CHILD | WS_VISIBLE, x, y, nWidth, nHeight, hWndParent, NULL, NULL ) )
  33. return FALSE;
  34. if( !pDSVideoProcessor->ConnectVideoWnd( &m_pVideoWindow ) )
  35. return FALSE;
  36. HRESULT hr = m_pVideoWindow->put_Owner( (OAHWND) GetSafeHwnd() );
  37. if( FAILED( hr ) )
  38. return FALSE;
  39. hr = m_pVideoWindow->put_WindowStyle( WS_CHILD | WS_CLIPCHILDREN );
  40. if( FAILED( hr ) )
  41. return FALSE;
  42. RECT rect;
  43. if( !GetClientRect( &rect ) )
  44. return FALSE;
  45. hr = m_pVideoWindow->SetWindowPosition( rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top );
  46. if( FAILED( hr ) )
  47. return FALSE;
  48. hr = m_pVideoWindow->put_AutoShow( OAFALSE );
  49. if( FAILED( hr ) )
  50. return FALSE;
  51. hr = m_pVideoWindow->put_Visible( OATRUE );
  52. if( FAILED( hr ) )
  53. return FALSE;
  54. hr = m_pVideoWindow->put_MessageDrain( (OAHWND)GetSafeHwnd() );
  55. if( FAILED( hr ) )
  56. return FALSE;
  57. return TRUE;
  58. }
  59. LRESULT CDSVideoWnd::OnDestroy( WPARAM wParam, LPARAM lParam )
  60. {
  61. FreeDirectShow();
  62. return CGenericWnd::OnDestroy( wParam, lParam );
  63. }
  64. BOOL CDSVideoWnd::DestroyWindow()
  65. {
  66. FreeDirectShow();
  67. return CGenericWnd::DestroyWindow();
  68. }
  69. void CDSVideoWnd::FreeDirectShow()
  70. {
  71. if( m_pVideoWindow )
  72. {
  73. m_pVideoWindow->Release();
  74. m_pVideoWindow = NULL;
  75. }
  76. }
  77. LRESULT CDSVideoWnd::OnSize( WPARAM wParam, LPARAM lParam )
  78. {
  79. if( !m_pVideoWindow )
  80. return CGenericWnd::OnSize( wParam, lParam );
  81. RECT rect;
  82. ::SetRect( &rect, 0, 0, LOWORD( lParam ), HIWORD( lParam ) );
  83. ::MapWindowPoints( GetSafeHwnd(), HWND_DESKTOP, (LPPOINT)&rect, 2 );
  84. m_pVideoWindow->SetWindowPosition( rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top );
  85. return CGenericWnd::OnSize( wParam, lParam );
  86. }