home *** CD-ROM | disk | FTP | other *** search
/ CD World Haziran 1997 / CD World Haziran 1997.iso / Programlama ve Gelistirme / DTime / _SETUP.1 / dateDlg.cpp next >
Encoding:
C/C++ Source or Header  |  1996-11-04  |  5.4 KB  |  209 lines

  1. // datentryDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "dtime.h"
  6. #include "resource.h"
  7. #include "dateDlg.h"
  8.  
  9.  
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. CDatentryDlg::CDatentryDlg(CWnd* pParent /*=NULL*/)
  17.   : CDialog(CDatentryDlg::IDD, pParent)
  18. {
  19.   //{{AFX_DATA_INIT(CDatentryDlg)
  20.   //}}AFX_DATA_INIT
  21.   // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  22.   m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  23.  
  24.   m_CDate = CDate::CurrentDate();
  25.   m_CLTimeSpan = CLTimeSpan(1, 2, 3, 4);
  26.   m_CLTimeOfDay = CLTimeOfDay(1, 2, 3);
  27.   m_CLDate = CLDate::CurrentTime(LOCAL);
  28.  
  29.     m_LDNoSeconds = FALSE;
  30.     m_TODNoSeconds = FALSE;    
  31.     m_TSNoSeconds = FALSE;    
  32.  
  33.   m_LDNoUCT = FALSE;
  34.   m_LDNoET = FALSE;
  35.   m_LDNoLocal = FALSE;
  36. }
  37.  
  38. void CDatentryDlg::DoDataExchange(CDataExchange* pDX)
  39. {
  40.   CDialog::DoDataExchange(pDX);
  41.   //{{AFX_DATA_MAP(CDatentryDlg)
  42.     //}}AFX_DATA_MAP
  43.  
  44.   //connect to the controls
  45.   DDX_CDateControl(pDX, IDC_CDATE, m_ctrlCDate, 0);
  46.   DDX_CLTimeSpanControl(pDX, IDC_CLTIMESPAN, m_ctrlCLTimeSpan, m_TSNoSeconds ? DT_NOSECONDS : 0);
  47.   DDX_CLTimeOfDayControl(pDX, IDC_CLTIMEOFDAY, m_ctrlCLTimeOfDay, m_TODNoSeconds ? DT_NOSECONDS : 0);
  48.   DDX_CLDateControl(pDX, IDC_CLDATE, m_ctrlCLDate, GetLDFlags());
  49.  
  50.  
  51.   //retreive / set the actual values 
  52.   DDX_CDate(pDX, m_ctrlCDate, m_CDate);
  53.   DDX_CLTimeSpan(pDX, m_ctrlCLTimeSpan, m_CLTimeSpan);
  54.   DDX_CLTimeOfDay(pDX, m_ctrlCLTimeOfDay, m_CLTimeOfDay);
  55.   DDX_CLDate(pDX, m_ctrlCLDate, m_CLDate);
  56. }
  57.  
  58. BEGIN_MESSAGE_MAP(CDatentryDlg, CDialog)
  59.   //{{AFX_MSG_MAP(CDatentryDlg)
  60.   ON_WM_PAINT()
  61.   ON_WM_QUERYDRAGICON()
  62.     ON_BN_CLICKED(IDC_ABOUT, OnAbout)
  63.     ON_BN_CLICKED(IDC_LD_NOSECONDS, OnLdNoseconds)
  64.     ON_BN_CLICKED(IDC_TOD_NOSECONDS, OnTodNoseconds)
  65.     ON_BN_CLICKED(IDC_TS_NOSECONDS, OnTsNoseconds)
  66.     ON_BN_CLICKED(IDC_LD_NOET, OnLdNoet)
  67.     ON_BN_CLICKED(IDC_LD_NOLOCAL, OnLdNolocal)
  68.     ON_BN_CLICKED(IDC_LD_NOUCT, OnLdNouct)
  69.     //}}AFX_MSG_MAP
  70. END_MESSAGE_MAP()
  71.  
  72. /////////////////////////////////////////////////////////////////////////////
  73. // CDatentryDlg message handlers
  74.  
  75. BOOL CDatentryDlg::OnInitDialog()
  76. {
  77.   CDialog::OnInitDialog();
  78.  
  79.   // Set the icon for this dialog.  The framework does this automatically
  80.   //  when the application's main window is not a dialog
  81.   SetIcon(m_hIcon, TRUE);     // Set big icon
  82.   SetIcon(m_hIcon, FALSE);    // Set small icon
  83.   
  84.   return TRUE;  // return TRUE  unless you set the focus to a control
  85. }
  86.  
  87. // If you add a minimize button to your dialog, you will need the code below
  88. //  to draw the icon.  For MFC applications using the document/view model,
  89. //  this is automatically done for you by the framework.
  90.  
  91. void CDatentryDlg::OnPaint() 
  92. {
  93.   if (IsIconic())
  94.   {
  95.     CPaintDC dc(this); // device context for painting
  96.  
  97.     SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  98.  
  99.     // Center icon in client rectangle
  100.     int cxIcon = GetSystemMetrics(SM_CXICON);
  101.     int cyIcon = GetSystemMetrics(SM_CYICON);
  102.     CRect rect;
  103.     GetClientRect(&rect);
  104.     int x = (rect.Width() - cxIcon + 1) / 2;
  105.     int y = (rect.Height() - cyIcon + 1) / 2;
  106.  
  107.     // Draw the icon
  108.     dc.DrawIcon(x, y, m_hIcon);
  109.   }
  110.   else
  111.   {
  112.     CDialog::OnPaint();
  113.   }
  114. }
  115.  
  116. // The system calls this to obtain the cursor to display while the user drags
  117. //  the minimized window.
  118. HCURSOR CDatentryDlg::OnQueryDragIcon()
  119. {
  120.   return (HCURSOR) m_hIcon;
  121. }
  122.  
  123. void CDatentryDlg::OnAbout() 
  124. {
  125.     AboutDTime();
  126. }
  127.  
  128. void CDatentryDlg::OnTodNoseconds() 
  129. {
  130.     m_TODNoSeconds = !m_TODNoSeconds;    
  131.  
  132.   CDataExchange DX(this, TRUE);
  133.   DDX_CLTimeOfDayControl(&DX, IDC_CLTIMEOFDAY, m_ctrlCLTimeOfDay, m_TODNoSeconds ? DT_NOSECONDS : 0);
  134.  
  135.   CDataExchange DX2(this, FALSE);
  136.   DDX_CLTimeOfDay(&DX2, m_ctrlCLTimeOfDay, m_CLTimeOfDay);
  137. }
  138.  
  139. void CDatentryDlg::OnTsNoseconds() 
  140. {
  141.     m_TSNoSeconds = !m_TSNoSeconds;    
  142.  
  143.   CDataExchange DX(this, TRUE);
  144.   DDX_CLTimeSpanControl(&DX, IDC_CLTIMESPAN, m_ctrlCLTimeSpan, m_TSNoSeconds ? DT_NOSECONDS : 0);
  145.  
  146.   CDataExchange DX2(this, FALSE);
  147.   DDX_CLTimeSpan(&DX2, m_ctrlCLTimeSpan, m_CLTimeSpan);
  148. }
  149.  
  150. void CDatentryDlg::OnLdNoseconds() 
  151. {
  152.     m_LDNoSeconds = !m_LDNoSeconds;
  153.  
  154.   CDataExchange DX(this, TRUE);
  155.   DDX_CLDateControl(&DX, IDC_CLDATE, m_ctrlCLDate, GetLDFlags());
  156.  
  157.   CDataExchange DX2(this, FALSE);
  158.   DDX_CLDate(&DX2, m_ctrlCLDate, m_CLDate);
  159. }
  160.  
  161. void CDatentryDlg::OnLdNoet() 
  162. {
  163.   m_LDNoET = !m_LDNoET;
  164.  
  165.   CDataExchange DX(this, TRUE);
  166.   DDX_CLDateControl(&DX, IDC_CLDATE, m_ctrlCLDate, GetLDFlags());
  167.  
  168.   CDataExchange DX2(this, FALSE);
  169.   DDX_CLDate(&DX2, m_ctrlCLDate, m_CLDate);
  170. }
  171.  
  172. void CDatentryDlg::OnLdNolocal() 
  173. {
  174.   m_LDNoLocal = !m_LDNoLocal;    
  175.  
  176.   CDataExchange DX(this, TRUE);
  177.   DDX_CLDateControl(&DX, IDC_CLDATE, m_ctrlCLDate, GetLDFlags());
  178.  
  179.   CDataExchange DX2(this, FALSE);
  180.   DDX_CLDate(&DX2, m_ctrlCLDate, m_CLDate);
  181. }
  182.  
  183. void CDatentryDlg::OnLdNouct() 
  184. {
  185.     m_LDNoUCT = !m_LDNoUCT;
  186.  
  187.   CDataExchange DX(this, TRUE);
  188.   DDX_CLDateControl(&DX, IDC_CLDATE, m_ctrlCLDate, GetLDFlags());
  189.  
  190.   CDataExchange DX2(this, FALSE);
  191.   DDX_CLDate(&DX2, m_ctrlCLDate, m_CLDate);
  192. }
  193.  
  194.  
  195. DWORD CDatentryDlg::GetLDFlags() const
  196. {
  197.   DWORD dwFlags = 0;
  198.  
  199.   if (m_LDNoSeconds)
  200.     dwFlags |= DT_NOSECONDS;
  201.   if (m_LDNoLocal)
  202.     dwFlags |= DT_NOLOCAL_TIMEFRAME;
  203.   if (m_LDNoET)
  204.     dwFlags |= DT_NOET_TIMEFRAME;
  205.   if (m_LDNoUCT)
  206.     dwFlags |= DT_NOUCT_TIMEFRAME;
  207.  
  208.   return dwFlags;
  209. }