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. CDateTimeCtrl in MFC - How to Use?

CDateTimeCtrl in MFC - How to Use?

Scheduled Pinned Locked Moved C / C++ / MFC
c++questiontutorial
8 Posts 2 Posters 2 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.
  • L Offline
    L Offline
    Larry Mills Sr
    wrote on last edited by
    #1

    I have two   DateTime picker Controls in my dialog: (1) One is for collecting the Users selected date(style is: :spin Control) the other control is (2) simply collects the time the User selects. In (1) which selection do you select in the Property Page for the control, ie, DTN_DATETIMECHANGED, etc. And once you have made that selection what is the code (in MFC) for retrieving the data? In (2) which selection do you select in the Property Page for the control, ie, DTN_DATETIMECHANGED, etc. And once you have made that selection what is the code (in MFC) for retrieving the data? I want to insure the format recieved is hh:mm (no seconds).I need sample code for each control: (1) and (2). I need working examples; if you do not have such, don't bother responding, PLEASE!

    A C++ programming language novice, but striving to learn

    D 1 Reply Last reply
    0
    • L Larry Mills Sr

      I have two   DateTime picker Controls in my dialog: (1) One is for collecting the Users selected date(style is: :spin Control) the other control is (2) simply collects the time the User selects. In (1) which selection do you select in the Property Page for the control, ie, DTN_DATETIMECHANGED, etc. And once you have made that selection what is the code (in MFC) for retrieving the data? In (2) which selection do you select in the Property Page for the control, ie, DTN_DATETIMECHANGED, etc. And once you have made that selection what is the code (in MFC) for retrieving the data? I want to insure the format recieved is hh:mm (no seconds).I need sample code for each control: (1) and (2). I need working examples; if you do not have such, don't bother responding, PLEASE!

      A C++ programming language novice, but striving to learn

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

      Larry Mills Sr wrote:

      ...what is the code (in MFC) for retrieving the data?

      Use the GetTime() method.

      "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      L 1 Reply Last reply
      0
      • D David Crow

        Larry Mills Sr wrote:

        ...what is the code (in MFC) for retrieving the data?

        Use the GetTime() method.

        "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        L Offline
        L Offline
        Larry Mills Sr
        wrote on last edited by
        #3

        David, the first (1) picker has an assigned varable of m_cDate and the second (2) has an assigned varable of m_cTime. if I use CString str = m_cDate.GetTime() will it return a str with the value in the picker? and should this value be received in the DTN_DATETIMECHANGED notification function or what function should I select in the PropertyPage for the picker? I don't know, that's why I'm asking?

        A C++ programming language novice, but striving to learn

        D 1 Reply Last reply
        0
        • L Larry Mills Sr

          David, the first (1) picker has an assigned varable of m_cDate and the second (2) has an assigned varable of m_cTime. if I use CString str = m_cDate.GetTime() will it return a str with the value in the picker? and should this value be received in the DTN_DATETIMECHANGED notification function or what function should I select in the PropertyPage for the picker? I don't know, that's why I'm asking?

          A C++ programming language novice, but striving to learn

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

          Larry Mills Sr wrote:

          David, the first (1) picker has an assigned varable of m_cDate...if I use CString str = m_cDate.GetTime() will it return a str with the value in the picker?

          No, it "returns" a SYSTEMTIME pointer, a COleDateTime object, or a CTime object.

          "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          L 1 Reply Last reply
          0
          • D David Crow

            Larry Mills Sr wrote:

            David, the first (1) picker has an assigned varable of m_cDate...if I use CString str = m_cDate.GetTime() will it return a str with the value in the picker?

            No, it "returns" a SYSTEMTIME pointer, a COleDateTime object, or a CTime object.

            "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            L Offline
            L Offline
            Larry Mills Sr
            wrote on last edited by
            #5

            Simply put; how do I get the value the User has selected in the picker into a CString? simple code plese!

            A C++ programming language novice, but striving to learn

            D 1 Reply Last reply
            0
            • L Larry Mills Sr

              Simply put; how do I get the value the User has selected in the picker into a CString? simple code plese!

              A C++ programming language novice, but striving to learn

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

              Did you look at any of the three objects I referenced? Use one of those along with CString::Format().

              "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              L 1 Reply Last reply
              0
              • D David Crow

                Did you look at any of the three objects I referenced? Use one of those along with CString::Format().

                "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                L Offline
                L Offline
                Larry Mills Sr
                wrote on last edited by
                #7

                If you are talking about this: "No, it "returns" a SYSTEMTIME pointer, a COleDateTime object, or a CTime object." I still don't understand how what the User selects will be relayed to the instance of one of these " "returns" a SYSTEMTIME pointer, a COleDateTime object, or a CTime object." when You initialize the m_cDatew or m_cTime varables with one of those; how will it also retrieve the User's response?   Wouldn't you receive back the same initialization you inputed to the varables?

                A C++ programming language novice, but striving to learn

                D 1 Reply Last reply
                0
                • L Larry Mills Sr

                  If you are talking about this: "No, it "returns" a SYSTEMTIME pointer, a COleDateTime object, or a CTime object." I still don't understand how what the User selects will be relayed to the instance of one of these " "returns" a SYSTEMTIME pointer, a COleDateTime object, or a CTime object." when You initialize the m_cDatew or m_cTime varables with one of those; how will it also retrieve the User's response?   Wouldn't you receive back the same initialization you inputed to the varables?

                  A C++ programming language novice, but striving to learn

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

                  Larry Mills Sr wrote:

                  I still don't understand how what the User selects will be relayed to the instance of one of these " "returns" a SYSTEMTIME pointer, a COleDateTime object, or a CTime object."

                  By using the GetTime() method. It comes in three different flavors depending on what type of object you want in return.

                  "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

                  "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                  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