PDA

Click to See Complete Forum and Search --> : Time


VB7
Aug 7th, 2001, 01:31 PM
How i can display the time in TEXTBOX or LABEL ?

Megatron
Aug 7th, 2001, 02:37 PM
Try this:

LPSTR lpTime;
wsprintf(lpTime, "%s", __TIME__);
SetWindowText(hwndStatic, lpTime);

parksie
Aug 7th, 2001, 02:49 PM
Don't you need a buffer?char pcTime[100];

kedaman
Aug 7th, 2001, 04:18 PM
How can you be sure it won't write beyond the buffer array?

VB7
Aug 7th, 2001, 05:42 PM
Thanx a lot.

I want to display date and time in lable using MFC.

parksie
Aug 8th, 2001, 03:00 AM
Kedaman - use snprintf then (I think that's a function, otherwise just fake it with _vsnprintf ;)).

VB7 - look at the class documentation for the class your lable is derived from.

kedaman
Aug 8th, 2001, 07:48 AM
Hey, parksie, I don't get it, why would you implement a function that might crash your system without warning?

HarryW
Aug 8th, 2001, 08:04 AM
If you're worried about it, just use a very big buffer :)

kedaman
Aug 8th, 2001, 08:15 AM
Nah, I'd never be that stupid :p