|
-
May 23rd, 2005, 01:42 AM
#1
How can I display current Time in a Static text.
I have already a dialog with Static text, IDC_STATICTIME, I have created a variable using CString m_sTime and with this
COleDateTime m_strTime= COleDateTime::GetCurrentTime();
m_sTime = m_strTime.Format("%b %d %Y);
Question: How can i display it in a certain portion in the dialog? So, the IDC_STATICTIME, i've used should display:
Current Date: the date(say May 23 2005)
I have put the code in DoDataExchange(CDataExchange* pDX)
with DDX_Text(pDX, IDC_STATICTIME, m_sTime); and it display as it should be but any other option without using DDX_text to display it?
-
May 23rd, 2005, 01:48 AM
#2
Re: How can I display current Time in a Static text.
with the class wizard you can add a control variable to the control.
Then, m_sTime = m_strTime.Format("%b %d %Y); won't do anything.
you should use the function as m_strTime.Format("%b, %d, %Y", value1, value2, value3);
Then, if you added a control variable, you can use this:
m_lblMyStatic.SetWindowText(m_sTime);
-
May 23rd, 2005, 02:23 AM
#3
Re: How can I display current Time in a Static text.
thank you for the reply, but m_strTime.Format("%b, %d, %Y", value1, value2, value3); seems unclear to me, what is value1, value2, value3? I just want to display the current date, put it in a create STATIC TEXT. Sorry but I am new in Visual. Can i also put the code outside DDX
-
May 23rd, 2005, 02:30 AM
#4
Re: How can I display current Time in a Static text.
The easiest way is:
SetDlgItemText(IDC_STATICTIME, m_sTime);
-
May 23rd, 2005, 02:37 AM
#5
Re: How can I display current Time in a Static text.
Do you even understand the function Format?
Check out the function description in MSDN.
For every %d, %s or whatsoever, you should add values.
So, if you want to add integers and strings to a string, use this code:
Code:
CString sExample = "hello";
int iExample = 5;
CString sFinalString;
// Because the first % is a s, we should first add the sExample as parameter
sFinalString.Format("%s, how are you doing? This is a number: %d", sExample, iExample);
The value if sFinalString will be:
hello, how are you doing? This is a number: 5
Do you understand?
-
May 23rd, 2005, 02:57 AM
#6
Re: How can I display current Time in a Static text.
yes, i know that, we dont need the value1, value2, value3 since the Format function does that automatically i think in COleDateTime, because we are getting the Current Date of the system. Anyway, thank you all for the reply, I will try to figure it out myself.
-
May 23rd, 2005, 03:04 AM
#7
Re: How can I display current Time in a Static text.
 Originally Posted by Tischnoetentoet
Do you even understand the function Format?
I think scrapage_online is using COleDateTime's Format member, not CString's (despite the actual name of the object, m_strTime, would make you think it's a string).
-
May 23rd, 2005, 03:11 AM
#8
Re: How can I display current Time in a Static text.
 Originally Posted by puzzolino
I think scrapage_online is using COleDateTime's Format member, not CString's (despite the actual name of the object, m_strTime, would make you think it's a string).
sorry about the confusion, yes i am using the COleDateTime format, i just used the m_strTime object just for debug.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|