TodayFormChild.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. // TodayFormChild.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "TodayFormChild.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // TodayFormChild dialog
  13. TodayFormChild::TodayFormChild(CWnd* pParent /*=NULL*/)
  14. : CDialog(TodayFormChild::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(TodayFormChild)
  17. // NOTE: the ClassWizard will add member initialization here
  18. List1array=NULL;
  19. pClientarray=NULL;
  20. pTxtypearray=NULL;
  21. //}}AFX_DATA_INIT
  22. }
  23. void TodayFormChild::DoDataExchange(CDataExchange* pDX)
  24. {
  25. CDialog::DoDataExchange(pDX);
  26. //{{AFX_DATA_MAP(TodayFormChild)
  27. DDX_Control(pDX, IDC_SCROLLBAR1, m_vScroll);
  28. // NOTE: the ClassWizard will add DDX and DDV calls here
  29. //}}AFX_DATA_MAP
  30. }
  31. BEGIN_MESSAGE_MAP(TodayFormChild, CDialog)
  32. //{{AFX_MSG_MAP(TodayFormChild)
  33. //}}AFX_MSG_MAP
  34. ON_WM_VSCROLL()
  35. ON_WM_MOUSEWHEEL()
  36. END_MESSAGE_MAP()
  37. /////////////////////////////////////////////////////////////////////////////
  38. // TodayFormChild message handlers
  39. void TodayFormChild::OnOK()
  40. {
  41. // TODO: Add extra validation here
  42. }
  43. void TodayFormChild::OnCancel()
  44. {
  45. // TODO: Add extra cleanup here
  46. }
  47. BOOL TodayFormChild::OnInitDialog()
  48. {
  49. CDialog::OnInitDialog();
  50. // TODO: Add extra initialization here
  51. // 显示滚动条;
  52. GetClientRect(rt_mvScroll);
  53. SCROLLINFO si;
  54. si.cbSize = sizeof(SCROLLINFO);;
  55. si.nMin = 0;
  56. si.nMax = 100;
  57. si.nPage = 5 ;
  58. si.fMask = SIF_POS|SIF_RANGE|SIF_PAGE;
  59. m_vScroll.SetScrollInfo(&si, TRUE);
  60. m_vScroll.GetWindowRect(rt_mvScroll);//滚动条所在的位置
  61. ScreenToClient(rt_mvScroll);
  62. m_vScroll.SetScrollRange(0, 256 * 10);
  63. m_vScroll.SetScrollPos(0);
  64. return TRUE;
  65. }
  66. void TodayFormChild::ShowTable()
  67. {
  68. CRect rc;
  69. GetClientRect(rc);
  70. m_table.m_pClientArray=pClientarray;
  71. m_table.pTxtypearray=pTxtypearray;
  72. m_table.m_pListArray=List1array;
  73. rt_mvScroll = rc;
  74. //rt_mvScroll.right -= 20;
  75. rt_mvScroll.left = rt_mvScroll.right - 20;
  76. rt_mvScroll.bottom -= 256 * 19 - 30;
  77. m_vScroll.MoveWindow(rt_mvScroll);
  78. rc.right -= 20;
  79. if(m_table.GetSafeHwnd()==NULL)
  80. m_table.Create(rc, this, WS_HSCROLL);
  81. m_table.Test ();
  82. }
  83. void TodayFormChild::DeleteCur()
  84. {
  85. m_table.DeleteCur();
  86. }
  87. void TodayFormChild::OtherDate()
  88. {
  89. m_table.OtherDate();
  90. }
  91. CString TodayFormChild::GetCurPhone(CString &name)
  92. {
  93. return m_table.GetCurPhone(name);
  94. }
  95. void TodayFormChild::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
  96. {
  97. // TODO: 在此添加消息处理程序代码和/或调用默认值
  98. SCROLLINFO si;
  99. si.cbSize = sizeof(si);
  100. m_vScroll.GetScrollInfo(&si, SIF_POS|SIF_PAGE|SIF_RANGE);
  101. nVscroll = si.nPos;
  102. switch(nSBCode)
  103. {
  104. case SB_LINEDOWN: nVscroll += 10;
  105. if (nVscroll > (si.nMax - si.nMin - si.nPage ))
  106. {
  107. nVscroll = si.nMax - si.nMin - si.nPage;
  108. }
  109. break;
  110. case SB_LINEUP: nVscroll -= 10;
  111. if (nVscroll < si.nMin)
  112. {
  113. nVscroll = 0;
  114. }
  115. break;
  116. case SB_PAGEDOWN: nVscroll += si.nPage;
  117. if (nVscroll > (si.nMax - si.nMin - si.nPage))
  118. {
  119. nVscroll = si.nMax - si.nMin - si.nPage;
  120. }
  121. break;
  122. case SB_PAGEUP: nVscroll -= si.nPage;
  123. if (nVscroll < si.nMin)
  124. {
  125. nVscroll = 0;
  126. }
  127. break;
  128. case SB_THUMBTRACK: nVscroll = nPos; break;
  129. }
  130. ScrollWindow(0, -(nVscroll -si.nPos) , NULL ,NULL);
  131. m_vScroll.MoveWindow(rt_mvScroll, TRUE);
  132. si.fMask = SIF_POS;
  133. si.nPos = nVscroll;
  134. m_vScroll.SetScrollInfo(&si, TRUE);
  135. CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
  136. }
  137. BOOL TodayFormChild::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
  138. {
  139. // TODO: 在此添加消息处理程序代码和/或调用默认值
  140. //向下滚
  141. if (zDelta == -120)
  142. {
  143. nVscroll += 10;
  144. OnVScroll(SB_PAGEDOWN, nVscroll, &m_vScroll);
  145. }
  146. else if (zDelta == 120)
  147. {
  148. nVscroll -= 10;
  149. OnVScroll(SB_PAGEUP, nVscroll, &m_vScroll);
  150. }
  151. m_vScroll.MoveWindow(rt_mvScroll, TRUE);
  152. return CDialog::OnMouseWheel(nFlags, zDelta, pt);
  153. }