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.

176 lines
4.2 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: 02/11/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: LgSubScrollDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of LgSubScrollDlg.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "lglibreport.h"
  16. #include "LgSubScrollDlg.h"
  17. #include "LgReportDlg.h"
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. CLgSubScrollDlg::CLgSubScrollDlg(CWnd* pParent /*=NULL*/)
  24. : CDialog(CLgSubScrollDlg::IDD, pParent)
  25. {
  26. //{{AFX_DATA_INIT(CLgSubScrollDlg)
  27. // NOTE: the ClassWizard will add member initialization here
  28. //}}AFX_DATA_INIT
  29. m_pReportDlg = NULL;
  30. memset( &m_ReportEvent, 0, sizeof(m_ReportEvent) );
  31. }
  32. void CLgSubScrollDlg::DoDataExchange(CDataExchange* pDX)
  33. {
  34. CDialog::DoDataExchange(pDX);
  35. //{{AFX_DATA_MAP(CLgSubScrollDlg)
  36. DDX_Control(pDX, IDC_SCROLLBAR_VIDEO, m_ScrollBarVideo);
  37. //}}AFX_DATA_MAP
  38. }
  39. BEGIN_MESSAGE_MAP(CLgSubScrollDlg, CDialog)
  40. //{{AFX_MSG_MAP(CLgSubScrollDlg)
  41. ON_WM_SIZE()
  42. ON_WM_HSCROLL()
  43. //}}AFX_MSG_MAP
  44. END_MESSAGE_MAP()
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CLgSubScrollDlg message handlers
  47. BOOL CLgSubScrollDlg::Create(CLgReportDlg *pReportDlg, CWnd *pParentWnd, CRect *pRect )
  48. {
  49. m_pReportDlg = pReportDlg;
  50. if( !CDialog::Create( IDD, pParentWnd ) )
  51. return FALSE;
  52. ShowWindow( SW_SHOW );
  53. CRect rect;
  54. if( pRect )
  55. rect = *pRect;
  56. else
  57. pParentWnd->GetClientRect( &rect );
  58. MoveWindow( &rect );
  59. return TRUE;
  60. }
  61. void CLgSubScrollDlg::OnSize(UINT nType, int cx, int cy)
  62. {
  63. CDialog::OnSize(nType, cx, cy);
  64. if( m_ScrollBarVideo.GetSafeHwnd() )
  65. m_ScrollBarVideo.MoveWindow( 0, 0, cx, cy );
  66. }
  67. void CLgSubScrollDlg::OnHScroll( UINT nSBCode, UINT nPos, CScrollBar* pScrollBar )
  68. {
  69. // Get the minimum and maximum scroll-bar positions.
  70. int minpos;
  71. int maxpos;
  72. pScrollBar->GetScrollRange(&minpos, &maxpos);
  73. maxpos = pScrollBar->GetScrollLimit();
  74. // Get the current position of scroll box.
  75. int curpos = pScrollBar->GetScrollPos();
  76. // Determine the new position of scroll box.
  77. switch (nSBCode)
  78. {
  79. case SB_LEFT: // Scroll to far left.
  80. curpos = minpos;
  81. break;
  82. case SB_RIGHT: // Scroll to far right.
  83. curpos = maxpos;
  84. break;
  85. case SB_ENDSCROLL: // End scroll.
  86. break;
  87. case SB_LINELEFT: // Scroll left.
  88. if (curpos > minpos)
  89. curpos--;
  90. break;
  91. case SB_LINERIGHT: // Scroll right.
  92. if (curpos < maxpos)
  93. curpos++;
  94. break;
  95. case SB_PAGELEFT: // Scroll one page left.
  96. {
  97. // Get the page size.
  98. SCROLLINFO info;
  99. pScrollBar->GetScrollInfo(&info, SIF_ALL);
  100. if (curpos > minpos)
  101. curpos = max(minpos, curpos - (int) info.nPage);
  102. }
  103. break;
  104. case SB_PAGERIGHT: // Scroll one page right.
  105. {
  106. // Get the page size.
  107. SCROLLINFO info;
  108. pScrollBar->GetScrollInfo(&info, SIF_ALL);
  109. if (curpos < maxpos)
  110. curpos = min(maxpos, curpos + (int) info.nPage);
  111. }
  112. break;
  113. case SB_THUMBPOSITION: // Scroll to absolute position. nPos is the position
  114. curpos = nPos; // of the scroll box at the end of the drag
  115. // operation.
  116. break;
  117. case SB_THUMBTRACK: // Drag scroll box to specified position. nPos is
  118. // the
  119. curpos = nPos; // position that the scroll box has been dragged
  120. // to.
  121. break;
  122. }
  123. // Set the new position of the thumb (scroll box).
  124. pScrollBar->SetScrollPos( curpos );
  125. CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
  126. m_pReportDlg->LoadSiteDateTimeImage( TRUE, &m_ReportEvent );
  127. }
  128. void CLgSubScrollDlg::SetEvent( REPORT_EVENT_BASE *pEvent )
  129. {
  130. if( pEvent )
  131. m_ReportEvent = *pEvent;
  132. else
  133. memset( &m_ReportEvent, 0, sizeof(m_ReportEvent) );
  134. if( pEvent && pEvent->bImageCount )
  135. {
  136. m_ScrollBarVideo.SetScrollRange( 0, pEvent->bImageCount - 1 );
  137. m_ScrollBarVideo.SetScrollPos( 0 );
  138. m_ScrollBarVideo.EnableWindow( TRUE );
  139. }
  140. else
  141. m_ScrollBarVideo.EnableWindow( FALSE );
  142. }