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.

140 lines
2.9 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: 08/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: VideoWnd.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of VideoWnd.cpp
  13. //----------------------------------------------------------------------------
  14. // VideoWnd.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "setupcld.h"
  18. #include "VideoWnd.h"
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CVideoWnd
  26. CVideoWnd::CVideoWnd()
  27. {
  28. }
  29. CVideoWnd::~CVideoWnd()
  30. {
  31. }
  32. BEGIN_MESSAGE_MAP(CVideoWnd, CWnd)
  33. //{{AFX_MSG_MAP(CVideoWnd)
  34. ON_WM_SIZE()
  35. ON_WM_PAINT()
  36. //}}AFX_MSG_MAP
  37. ON_MESSAGE( WM_VIDEO_SAMPLE, OnVideoSample )
  38. END_MESSAGE_MAP()
  39. BOOL CVideoWnd::Create( CWnd *pParentWnd, int x, int y, int nWidth, int nHeight )
  40. {
  41. DestroyWindow();
  42. CRect rect( x, y, x + nWidth, y + nHeight );
  43. CString strClassName = ::AfxRegisterWndClass( CS_HREDRAW | CS_VREDRAW, ::LoadCursor( NULL, IDC_ARROW ), NULL, NULL );
  44. if( !CWnd::Create( strClassName, "", WS_CHILD | WS_VISIBLE, rect, pParentWnd, 0 ) )
  45. return FALSE;
  46. SetCross();
  47. return TRUE;
  48. }
  49. void CVideoWnd::OnVideoSample( double SampleTime )
  50. {
  51. // pos message to window
  52. if( GetSafeHwnd() )
  53. ::PostMessage( GetSafeHwnd(), WM_VIDEO_SAMPLE, 0, 0 );
  54. }
  55. LRESULT CVideoWnd::OnVideoSample( WPARAM wParam, LPARAM )
  56. {
  57. InvalidateRect( NULL );
  58. return 0;
  59. }
  60. BOOL CVideoWnd::DestroyWindow()
  61. {
  62. // unlink from direct show stream
  63. CDirectShowVideo::Unlink();
  64. CLgDirectDrawVideo::OnDestroy();
  65. return CWnd::DestroyWindow();
  66. }
  67. void CVideoWnd::OnSize(UINT nType, int cx, int cy)
  68. {
  69. CWnd::OnSize(nType, cx, cy);
  70. CLgDirectDrawVideo::OnSize( GetSafeHwnd() );
  71. }
  72. void CVideoWnd::OnDraw( CDC *pDC )
  73. {
  74. CLgDirectDrawVideo::OnPaint( TRUE );
  75. }
  76. void CVideoWnd::OnPaint()
  77. {
  78. CPaintDC dc(this); // device context for painting
  79. OnDraw( &dc );
  80. }
  81. void CVideoWnd::SetCross()
  82. {
  83. if( !GetSafeHwnd() )
  84. return;
  85. CRect rect;
  86. GetClientRect( &rect );
  87. const int L1 = 2;
  88. const int L2 = 20;
  89. int W1 = L1;
  90. int H1 = L2;
  91. int W2 = L2;
  92. int H2 = L1;
  93. int x1 = ( rect.Width() - W1 ) / 2;
  94. int y1 = ( rect.Height() - H1 ) / 2;
  95. int x2 = ( rect.Width() - W2 ) / 2;
  96. int y2 = ( rect.Height() - H2 ) / 2;
  97. CRect frame1( x1, y1, x1 + W1, y1 + H1 );
  98. CRect frame2( x2, y2, x2 + W2, y2 + H2 );
  99. CRgn rgn;
  100. rgn.CreateRectRgnIndirect( &rect );
  101. CRgn rgn1;
  102. rgn1.CreateRectRgnIndirect( frame1 );
  103. CRgn rgn2;
  104. rgn2.CreateRectRgnIndirect( frame2 );
  105. rgn.CombineRgn( &rgn, &rgn1, RGN_DIFF );
  106. rgn.CombineRgn( &rgn, &rgn2, RGN_DIFF );
  107. SetWindowRgn( (HRGN)rgn.GetSafeHandle(), TRUE );
  108. }