// TodayFormChild.cpp : implementation file // #include "stdafx.h" #include "ylgl.h" #include "TodayFormChild.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // TodayFormChild dialog TodayFormChild::TodayFormChild(CWnd* pParent /*=NULL*/) : CDialog(TodayFormChild::IDD, pParent) { //{{AFX_DATA_INIT(TodayFormChild) // NOTE: the ClassWizard will add member initialization here List1array=NULL; pClientarray=NULL; pTxtypearray=NULL; //}}AFX_DATA_INIT } void TodayFormChild::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(TodayFormChild) DDX_Control(pDX, IDC_SCROLLBAR1, m_vScroll); // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(TodayFormChild, CDialog) //{{AFX_MSG_MAP(TodayFormChild) //}}AFX_MSG_MAP ON_WM_VSCROLL() ON_WM_MOUSEWHEEL() END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // TodayFormChild message handlers void TodayFormChild::OnOK() { // TODO: Add extra validation here } void TodayFormChild::OnCancel() { // TODO: Add extra cleanup here } BOOL TodayFormChild::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here // 显示滚动条; GetClientRect(rt_mvScroll); SCROLLINFO si; si.cbSize = sizeof(SCROLLINFO);; si.nMin = 0; si.nMax = 100; si.nPage = 5 ; si.fMask = SIF_POS|SIF_RANGE|SIF_PAGE; m_vScroll.SetScrollInfo(&si, TRUE); m_vScroll.GetWindowRect(rt_mvScroll);//滚动条所在的位置 ScreenToClient(rt_mvScroll); m_vScroll.SetScrollRange(0, 256 * 10); m_vScroll.SetScrollPos(0); return TRUE; } void TodayFormChild::ShowTable() { CRect rc; GetClientRect(rc); m_table.m_pClientArray=pClientarray; m_table.pTxtypearray=pTxtypearray; m_table.m_pListArray=List1array; rt_mvScroll = rc; //rt_mvScroll.right -= 20; rt_mvScroll.left = rt_mvScroll.right - 20; rt_mvScroll.bottom -= 256 * 19 - 30; m_vScroll.MoveWindow(rt_mvScroll); rc.right -= 20; if(m_table.GetSafeHwnd()==NULL) m_table.Create(rc, this, WS_HSCROLL); m_table.Test (); } void TodayFormChild::DeleteCur() { m_table.DeleteCur(); } void TodayFormChild::OtherDate() { m_table.OtherDate(); } CString TodayFormChild::GetCurPhone(CString &name) { return m_table.GetCurPhone(name); } void TodayFormChild::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { // TODO: 在此添加消息处理程序代码和/或调用默认值 SCROLLINFO si; si.cbSize = sizeof(si); m_vScroll.GetScrollInfo(&si, SIF_POS|SIF_PAGE|SIF_RANGE); nVscroll = si.nPos; switch(nSBCode) { case SB_LINEDOWN: nVscroll += 10; if (nVscroll > (si.nMax - si.nMin - si.nPage )) { nVscroll = si.nMax - si.nMin - si.nPage; } break; case SB_LINEUP: nVscroll -= 10; if (nVscroll < si.nMin) { nVscroll = 0; } break; case SB_PAGEDOWN: nVscroll += si.nPage; if (nVscroll > (si.nMax - si.nMin - si.nPage)) { nVscroll = si.nMax - si.nMin - si.nPage; } break; case SB_PAGEUP: nVscroll -= si.nPage; if (nVscroll < si.nMin) { nVscroll = 0; } break; case SB_THUMBTRACK: nVscroll = nPos; break; } ScrollWindow(0, -(nVscroll -si.nPos) , NULL ,NULL); m_vScroll.MoveWindow(rt_mvScroll, TRUE); si.fMask = SIF_POS; si.nPos = nVscroll; m_vScroll.SetScrollInfo(&si, TRUE); CDialog::OnVScroll(nSBCode, nPos, pScrollBar); } BOOL TodayFormChild::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) { // TODO: 在此添加消息处理程序代码和/或调用默认值 //向下滚 if (zDelta == -120) { nVscroll += 10; OnVScroll(SB_PAGEDOWN, nVscroll, &m_vScroll); } else if (zDelta == 120) { nVscroll -= 10; OnVScroll(SB_PAGEUP, nVscroll, &m_vScroll); } m_vScroll.MoveWindow(rt_mvScroll, TRUE); return CDialog::OnMouseWheel(nFlags, zDelta, pt); }