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.6 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: LgUISiteSensorWnd.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of LgUISiteSensorWnd.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "LgUISiteSensorWnd.h"
  16. #include "LgUISiteSensor.h"
  17. #include "LgUISiteEngine.h"
  18. #include "LgUISiteCamera.h"
  19. #include "..\UICamera\LgUICamera.h"
  20. #include "..\UICamera\LgUICameraVideoWnd.h"
  21. CLgUISiteSensorWnd::CLgUISiteSensorWnd()
  22. {
  23. }
  24. CLgUISiteSensorWnd::~CLgUISiteSensorWnd()
  25. {
  26. }
  27. BEGIN_MESSAGE_MAP(CLgUISiteSensorWnd, CWnd)
  28. //{{AFX_MSG_MAP(CLgUISiteSensorWnd)
  29. ON_WM_PAINT()
  30. //}}AFX_MSG_MAP
  31. END_MESSAGE_MAP()
  32. BOOL CLgUISiteSensorWnd::Create( CWnd *pParentWnd, int x, int y, int nWidth, int nHeight )
  33. {
  34. DestroyWindow();
  35. CString strClassName = ::AfxRegisterWndClass( CS_HREDRAW | CS_VREDRAW, ::LoadCursor( NULL, IDC_ARROW ), (HBRUSH)COLOR_WINDOW, NULL );
  36. CRect rect( x, y, x + nWidth, y + nHeight );
  37. if( !CWnd::Create( strClassName, NULL, WS_CHILD | WS_DLGFRAME | WS_CLIPSIBLINGS, rect, pParentWnd, 0 ) )
  38. return FALSE;
  39. return TRUE;
  40. }
  41. BOOL CLgUISiteSensorWnd::DestroyWindow()
  42. {
  43. // Unlink sensor
  44. CLgLink<CLgUISiteSensorWnd,CLgUISiteSensor>::Unlink();
  45. return CWnd::DestroyWindow();
  46. }
  47. BOOL CLgUISiteSensorWnd::Link( CLgLink<CLgUISiteSensor, CLgUISiteSensorWnd> *pSensor )
  48. {
  49. // Unlink old sensor
  50. CLgUISiteSensor *pOldSensor = *this;
  51. if( pOldSensor && pOldSensor != pSensor )
  52. Unlink( pOldSensor );
  53. if( !CLgLink<CLgUISiteSensorWnd,CLgUISiteSensor>::Link( pSensor ) )
  54. return FALSE;
  55. // update drawing
  56. if( GetSafeHwnd() )
  57. InvalidateRect( NULL );
  58. return TRUE;
  59. }
  60. BOOL CLgUISiteSensorWnd::Unlink( CLgLink<CLgUISiteSensor, CLgUISiteSensorWnd> *pSensor )
  61. {
  62. if( !CLgLink<CLgUISiteSensorWnd,CLgUISiteSensor>::Unlink( pSensor ) )
  63. return FALSE;
  64. // update drawing
  65. if( GetSafeHwnd() )
  66. InvalidateRect( NULL );
  67. return TRUE;
  68. }
  69. void CLgUISiteSensorWnd::OnDraw( CDC *pDC )
  70. {
  71. CRect rect;
  72. GetClientRect( &rect );
  73. pDC->Rectangle( &rect );
  74. CLgUISiteSensor *pSensor = *this;
  75. if( pSensor )
  76. {
  77. CString str;
  78. str.Format( "Sensor %p", pSensor );
  79. pDC->DrawText( str, &rect, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
  80. }
  81. }
  82. void CLgUISiteSensorWnd::OnPaint()
  83. {
  84. CPaintDC dc( this );
  85. OnDraw( &dc );
  86. }