1.添加串口控件。
1)project-add to project-components and controls-Registered ActiveX Controls-Microsoft Communications Control, version 6.0-insert
2)classwizard-message maps-IDC_MSCOMM-添加消息(接到数据有响应)
3)member variables(添加变量)
2.添加timer:
1)classwizard-message maps-***Dlg-WM_TIMER
2)在OnInitDialog()中添加SetTimer(10, 1000, NULL);
注:显示系统时间的参考程序(static的ID为IDC_STATIC_TIMER)
CTime time = CTime::GetCurrentTime(); //全局函数,取出当前的时间,放到ctime的累中
int y = time.GetYear();
int mon = time.GetMonth();
int d = time.GetDay();
int h = time.GetHour();
int min = time.GetMinute();
int s = time.GetSecond();
CString sy, smon, sd, sh, smin, ss, sTime;
sy.Format("%d", y);
smon.Format("%d", mon);
sd.Format("%d", d);
if (h < 10) //使小时是双位
{
sh.Format("0%d", h);
}
else
{
sh.Format("%d", h);
}
if (min < 10) //使分钟是双位
{
smin.Format("0%d", min);
}
else
{
smin.Format("%d", min);
}
if (s < 10) //使秒是双位
{
ss.Format("0%d", s);
}
else
{
ss.Format("%d", s);
}
sTime = sy + "-" +smon + "-" + sd + " " + sh + ":" + smin + ":" + ss;
CStatic *pDisplayTime;
pDisplayTime = (CStatic*)GetDlgItem(IDC_STATIC_TIMER);
pDisplayTime->SetWindowText(sTime); //在文本中显示当前时间
CDialog::OnTimer(nIDEvent);
VC中添加串口控件 添加timer
来源:博客 作者:dycuswine2 时间:2008-03-27 点击:342 次
相关文章:
文章搜索
推荐文章
推荐产品
|
VARCHART XGantt
全球知名的甘特图控件,能够实现如 Microsoft Project 般强大的项目管理功能。
|
|
TurboDemo 中文版
TurboDemo - 抓取屏幕截图并通过动态演示示例及手册解释软件、个人电脑应用程序、网站与产品。
|
|
BCGControlBar Library .NET Edition
该组件包含大量可自定义程度高、可设计性好的组件,使用户可创建精致美观的图形用户界面。
|
|
WebUI Studio.NET
WebUI Studio.NET 是一套用于开发专业 ASP.NET web 应用程序必不可少的控件。
|





