对话框&中的COleDateTime/COleDateTimeSpan操纵 [英] COleDateTime/COleDateTimeSpan in dialogs & manipulation

查看:207
本文介绍了对话框&中的COleDateTime/COleDateTimeSpan操纵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直读到我的头开始旋转.我不知道COleDateTime如何与对话框一起工作.我可以将当​​前日期和时间添加到对话框中,但是我想知道如何操纵日期/时间(获取当前日期/时间并将其设置为另一个日期/时间,然后显示它).我该如何进行或在哪里可以学到呢?

解决方案

我不认为这是封装一个或什至是最好的方法.日期,但根据我的见解确实很简单.

http://msdn.microsoft.com/zh-CN/library/by5d3kb1 (v = VS.80).aspx [ 解决方案

I don''t think this is the only or even necessarily the best way to encapsulate a date, but it''s really straightforward from what I see.

http://msdn.microsoft.com/en-US/library/by5d3kb1(v=VS.80).aspx[^]

GetCurrentTime gets the current time. SetDateTime sets it. Operator +, -, +=, -=, means you can add them together. The Format method lets you build a formatted version for display.


I created a variable m_oleMyDate of type COleDateTime in my ...View.h file and then initialized it to (COleDateTime::GetCurrentTime()) in my View .cpp file.

Next, I created three variables of type int (nYear, nMonth, nDay) and then set the variables with the current month day and year as follows:

nYear = m_oleMyDate.GetYear();
nMonth = m_oleMyDate.GetMonth();
nDay = m_oleMyDate.GetDay();

I then created a function to manipulate the date for any purpose.

Finally, I used m_oleMyDate.SetDate(nYear, nMonth, nDay) to display my new date.

Thanks for the help


这篇关于对话框&中的COleDateTime/COleDateTimeSpan操纵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆