Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem with DatePicker

Problem with DatePicker

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    M_Menon
    wrote on last edited by
    #1

    Hi Friends I am not able to get the Selected Date from the DatePicker. It is showing me the Current DateTime always. I am new with VC++. //Initializing , m_Date( CTime::GetCurrentTime()) DDX_DateTimeCtrl(pDX, IDC_DATE, m_Date); And then i am Changing the Date in DatePicker, and on Button Click Event, i have the below instruction, where i need the Selected Date but instead it is showing me CurrentDateTime() SELECT Polhsh_ID FROM Polhsh WHERE Installation_ID = %d AND Pelaths_ID = %d AND ActionType = '%s'AND Hmeromhnia= #%s# "), Installation_ID, m_Promhtheytes.GetItemData( m_Promhtheytes.GetCurSel()), ActionType, m_Date.Format( _T("%Y/%m/%d")) ); But i am always getting the Current DateTime. I know it must be something simple, But i am completely new with VC++. I hope if anybody gets time, give me some help. Thanks

    Cheers Menon

    L D 2 Replies Last reply
    0
    • M M_Menon

      Hi Friends I am not able to get the Selected Date from the DatePicker. It is showing me the Current DateTime always. I am new with VC++. //Initializing , m_Date( CTime::GetCurrentTime()) DDX_DateTimeCtrl(pDX, IDC_DATE, m_Date); And then i am Changing the Date in DatePicker, and on Button Click Event, i have the below instruction, where i need the Selected Date but instead it is showing me CurrentDateTime() SELECT Polhsh_ID FROM Polhsh WHERE Installation_ID = %d AND Pelaths_ID = %d AND ActionType = '%s'AND Hmeromhnia= #%s# "), Installation_ID, m_Promhtheytes.GetItemData( m_Promhtheytes.GetCurSel()), ActionType, m_Date.Format( _T("%Y/%m/%d")) ); But i am always getting the Current DateTime. I know it must be something simple, But i am completely new with VC++. I hope if anybody gets time, give me some help. Thanks

      Cheers Menon

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      See UpdateData()[^] Also if your beginning you should be using a book or tutorials. If they have not covered UpdateData then they aren't any good so find another.

      M 1 Reply Last reply
      0
      • L led mike

        See UpdateData()[^] Also if your beginning you should be using a book or tutorials. If they have not covered UpdateData then they aren't any good so find another.

        M Offline
        M Offline
        M_Menon
        wrote on last edited by
        #3

        Hi mike Thank you. Well i generally work on C#.NET web applications. And there is some modifications to be done on project made by someone else. After whole day coding in C#.NET i make mistakes while writing VC++. And again, thanks

        Cheers Menon

        1 Reply Last reply
        0
        • M M_Menon

          Hi Friends I am not able to get the Selected Date from the DatePicker. It is showing me the Current DateTime always. I am new with VC++. //Initializing , m_Date( CTime::GetCurrentTime()) DDX_DateTimeCtrl(pDX, IDC_DATE, m_Date); And then i am Changing the Date in DatePicker, and on Button Click Event, i have the below instruction, where i need the Selected Date but instead it is showing me CurrentDateTime() SELECT Polhsh_ID FROM Polhsh WHERE Installation_ID = %d AND Pelaths_ID = %d AND ActionType = '%s'AND Hmeromhnia= #%s# "), Installation_ID, m_Promhtheytes.GetItemData( m_Promhtheytes.GetCurSel()), ActionType, m_Date.Format( _T("%Y/%m/%d")) ); But i am always getting the Current DateTime. I know it must be something simple, But i am completely new with VC++. I hope if anybody gets time, give me some help. Thanks

          Cheers Menon

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          This works fine for me:

          void CMyDlg::DoDataExchange(CDataExchange* pDX)
          {
          CDialog::DoDataExchange(pDX);
          //{{AFX_DATA_MAP(CMyDlg)
          DDX_Control(pDX, IDC_DATETIMEPICKER1, m_date); // m_date is CDateTimeCtrl object
          //}}AFX_DATA_MAP
          }

          BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
          //{{AFX_MSG_MAP(CDbcDlg)
          ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETIMEPICKER1, OnChangeDateTimePicker)
          //}}AFX_MSG_MAP
          END_MESSAGE_MAP()

          void CMyDlg::OnChangeDateTimePicker(NMHDR* pNMHDR, LRESULT* pResult)
          {
          COleDateTime t;
          m_date.GetTime(t);
          TRACE("%s\n", t.Format("%Y/%m/%d"));

          \*pResult = 0;
          

          }

          Note there is no UpdateData() call.


          "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          M 1 Reply Last reply
          0
          • D David Crow

            This works fine for me:

            void CMyDlg::DoDataExchange(CDataExchange* pDX)
            {
            CDialog::DoDataExchange(pDX);
            //{{AFX_DATA_MAP(CMyDlg)
            DDX_Control(pDX, IDC_DATETIMEPICKER1, m_date); // m_date is CDateTimeCtrl object
            //}}AFX_DATA_MAP
            }

            BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
            //{{AFX_MSG_MAP(CDbcDlg)
            ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETIMEPICKER1, OnChangeDateTimePicker)
            //}}AFX_MSG_MAP
            END_MESSAGE_MAP()

            void CMyDlg::OnChangeDateTimePicker(NMHDR* pNMHDR, LRESULT* pResult)
            {
            COleDateTime t;
            m_date.GetTime(t);
            TRACE("%s\n", t.Format("%Y/%m/%d"));

            \*pResult = 0;
            

            }

            Note there is no UpdateData() call.


            "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            M Offline
            M Offline
            M_Menon
            wrote on last edited by
            #5

            Thanks David My mistake or so called foolishness was i forgot the UpdateData(True) :-D:) Still Thanks

            Cheers Menon

            D 1 Reply Last reply
            0
            • M M_Menon

              Thanks David My mistake or so called foolishness was i forgot the UpdateData(True) :-D:) Still Thanks

              Cheers Menon

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              M_Menon wrote:

              i forgot the UpdateData(True)...

              It's not necessary when you use control variables (e.g., CDateTimeCtrl instead of CTime).


              "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups