Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

facing problem in visual c++, can help me?

Status
Not open for further replies.

wccheok

Member level 1
Member level 1
Joined
Jul 29, 2005
Messages
39
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,673
Hi,
May i know how to program/put/set clock in Microsoft Visual C++ 6.0?
Can the Microsoft Visual C++ do it?

Example:
In my program, i want it alway show out the Time. How i can do it?

Thx
 

Hi to all,
yes of course visual c++ can do it. Just declare a structure of type SYSTEMTIME and call ::GetLocalTime(), as shown below:
...
SYSTEMTIME time;
::GetLocalTime(&time); //here GetLocalTime() fills the structure with the current system time :)
...

in order to show the time, you should call it repeatedly, for example from calls of WM_TIMER messages (every 500ms)
 

I am not very good in VC++, but know how to do it. here is the steps.

Create a Dialog based application

Add a member function to the dialog for WM_TIMER message using class wizard

In OnInitDialog function start a timer for every 500ms
Code:
SetTimer(1,500,NULL);

In OnTimer function get the local time, format a string in the way you want
and update the control's text for display
Code:
SYSTEMTIME sTim;
GetLocalTime(&sTim);
CString sTemp;
sTemp.Format("%4d/%2d/%2d :: %2d:%2d:%2d",sTim.wYear,sTim.wMonth,sTim.wDay,
   	    sTim.wHour, sTim.wMinute,sTim.wSecond);
m_strTime = sTemp;
UpdateData(FALSE);

I am attaching a sample application, Hope it helps you.

have a niceday
SivaC
 

Hi all, can look over my program? I hv attaching it.
Can the program be improve?
Cos my VC++ standard is very low. But i will go do find some VC book too learn and do research.

I m using a "simple way" to write it only. Cos i hv no idea to write other method.
>.<
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top