YMTestDlg.cpp
上传用户:baiduw
上传日期:2007-01-01
资源大小:23k
文件大小:3k
源码类别:

界面编程

开发平台:

Visual C++

  1. // YMTestDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "YMTest.h"
  5. #include "YMTestDlg.h"
  6. #include "YMSelector.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CYMTestDlg dialog
  14. CYMTestDlg::CYMTestDlg(CWnd* pParent /*=NULL*/)
  15. : CDialog(CYMTestDlg::IDD, pParent)
  16. {
  17. //{{AFX_DATA_INIT(CYMTestDlg)
  18. //}}AFX_DATA_INIT
  19. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  20. }
  21. void CYMTestDlg::DoDataExchange(CDataExchange* pDX)
  22. {
  23. CDialog::DoDataExchange(pDX);
  24. //{{AFX_DATA_MAP(CYMTestDlg)
  25. DDX_Control(pDX, IDC_BUTTON_YMSELECT, m_btnStart);
  26. DDX_Control(pDX, IDC_BUTTON_YMSELECT2, m_btnEnd);
  27. //}}AFX_DATA_MAP
  28. }
  29. BEGIN_MESSAGE_MAP(CYMTestDlg, CDialog)
  30. //{{AFX_MSG_MAP(CYMTestDlg)
  31. ON_WM_PAINT()
  32. ON_WM_QUERYDRAGICON()
  33. ON_WM_MOUSEMOVE()
  34. //}}AFX_MSG_MAP
  35. END_MESSAGE_MAP()
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CYMTestDlg message handlers
  38. BOOL CYMTestDlg::OnInitDialog()
  39. {
  40. CDialog::OnInitDialog();
  41. SetIcon(m_hIcon, TRUE); // Set big icon
  42. SetIcon(m_hIcon, FALSE); // Set small icon
  43. // TODO: Add extra initialization here
  44.     m_btnStart.SetYear(1970);
  45.     m_btnStart.SetMonth(1);
  46.     //m_btnEnd.SetYear(2000);
  47.     //m_btnEnd.SetMonth(12);
  48. return TRUE;  // return TRUE  unless you set the focus to a control
  49. }
  50. // If you add a minimize button to your dialog, you will need the code below
  51. //  to draw the icon.  For MFC applications using the document/view model,
  52. //  this is automatically done for you by the framework.
  53. void CYMTestDlg::OnPaint() 
  54. {
  55. if (IsIconic())
  56. {
  57. CPaintDC dc(this); // device context for painting
  58. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  59. // Center icon in client rectangle
  60. int cxIcon = GetSystemMetrics(SM_CXICON);
  61. int cyIcon = GetSystemMetrics(SM_CYICON);
  62. CRect rect;
  63. GetClientRect(&rect);
  64. int x = (rect.Width() - cxIcon + 1) / 2;
  65. int y = (rect.Height() - cyIcon + 1) / 2;
  66. // Draw the icon
  67. dc.DrawIcon(x, y, m_hIcon);
  68. }
  69. else
  70. {
  71. CDialog::OnPaint();
  72. }
  73. }
  74. HCURSOR CYMTestDlg::OnQueryDragIcon()
  75. {
  76. return (HCURSOR) m_hIcon;
  77. }
  78. void CYMTestDlg::OnOK() 
  79. {
  80.     CString buffer;
  81.     buffer.Format("Start = %s, %dnEnd = %s,%d", 
  82.                    m_btnStart.GetMonthString(),
  83.                    m_btnStart.GetYear(),
  84.                    m_btnEnd.GetMonthString(),
  85.                    m_btnEnd.GetYear());
  86.     AfxMessageBox(buffer);
  87.     
  88. }
  89. void CYMTestDlg::OnMouseMove(UINT nFlags, CPoint point) 
  90. {
  91. // TODO: Add your message handler code here and/or call default
  92. CDialog::OnMouseMove(nFlags, point);
  93. }