void CMy16View::OnInitialUpdate() {
CFormView::OnInitialUpdate(); GetParentFrame()->RecalcLayout(); ResizeParentToFit();
if(!page1.m_hWnd||!page2.m_hWnd||!page3.m_hWnd||!page4.m_hWnd) //第一
次初始化m_tab 控件和page页的建立
{
//初始化m_tab控件
m_tab.InsertItem(0,\通道1-4\ m_tab.InsertItem(1,\通道5-8\ m_tab.InsertItem(2,\通道9-12\
m_tab.InsertItem(3,\通道13-16\ //建立属性页各页
page1.Create(IDD_DIALOG1,GetDlgItem(IDC_TAB1)); page2.Create(IDD_DIALOG2,GetDlgItem(IDC_TAB1)); page3.Create(IDD_DIALOG3,GetDlgItem(IDC_TAB1)); page4.Create(IDD_DIALOG4,GetDlgItem(IDC_TAB1));
//设置页面的位置在m_tab控件范围内
CRect rs;
m_tab.GetClientRect(rs); rs.top+=20; rs.bottom-=4; rs.left+=4; rs.right-=4;
page1.MoveWindow(rs); page2.MoveWindow(rs); page3.MoveWindow(rs); page4.MoveWindow(rs);
- 35 -
page1.ShowWindow(TRUE); m_tab.SetCurSel(0);
}
CFont * f; f = new CFont; f->CreateFont(40, 12, // nWidth 0, // nEscapement 0, // nOrientation FW_BOLD, // nWeight FALSE, // bItalic FALSE, // bUnderline 0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision CLIP_DEFAULT_PRECIS, // nClipPrecision DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily _T(\
GetDlgItem(IDC_STATIC1)->SetFont(f); //IDC_STATIC1是静态文本框的ID
CFont * h; h= new CFont; h->CreateFont(20, 10, // nWidth 0, // nEscapement 0, // nOrientation FW_BOLD, // nWeight FALSE, // bItalic FALSE, // bUnderline 0, // cStrikeOut
- 36 -
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision CLIP_DEFAULT_PRECIS, // nClipPrecision DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily _T(\
GetDlgItem(IDC_STATIC2)->SetFont(h); //IDC_STATIC1是静态文本框的ID SetTimer(1, 1000, NULL); }
///////////////////////////////////////////////////////////////////// // CMy16View printing
BOOL CMy16View::OnPreparePrinting(CPrintInfo* pInfo) { }
void CMy16View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { }
void CMy16View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { }
void CMy16View::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/) { }
// TODO: add customized printing code here // TODO: add cleanup after printing
// TODO: add extra initialization before printing // default preparation
return DoPreparePrinting(pInfo);
- 37 -
///////////////////////////////////////////////////////////////////// // CMy16View diagnostics
#ifdef _DEBUG
void CMy16View::AssertValid() const { }
void CMy16View::Dump(CDumpContext& dc) const { }
CMy16Doc* CMy16View::GetDocument() // non-debug version is inline { }
#endif //_DEBUG
//////////////////////////////////////////////////////////////////// // CMy16View message handlers
void CMy16View::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult) {
// TODO: Add your control notification handler code here int CurSel;
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMy16Doc))); return (CMy16Doc*)m_pDocument; CFormView::Dump(dc); CFormView::AssertValid();
CurSel=m_tab.GetCurSel(); switch(CurSel) {
- 38 -
case 0:
page1.ShowWindow(TRUE); page2.ShowWindow(FALSE); page3.ShowWindow(FALSE); page4.ShowWindow(FALSE); break; case 1:
page1.ShowWindow(FALSE); page2.ShowWindow(TRUE); page3.ShowWindow(FALSE); page4.ShowWindow(FALSE); break; case 2:
page1.ShowWindow(FALSE); page2.ShowWindow(FALSE); page3.ShowWindow(TRUE); page4.ShowWindow(FALSE); break; case 3:
page1.ShowWindow(FALSE); page2.ShowWindow(FALSE); page3.ShowWindow(FALSE); page4.ShowWindow(TRUE); break; default: ; } }
void CMy16View::OnTimer(UINT nIDEvent)
{
*pResult = 0;
- 39 -
// TODO: Add your message handler code here and/or call default // TODO: Add your message handler code here and/or call default CTime time = CTime::GetCurrentTime();
m_ShowNowTime = time.Format(\ UpdateData(FALSE);
CFormView::OnTimer(nIDEvent);
}
- 40 -