//获得当前日期和时间
//这种方法获取的时间,在显示0-9时只显示一位,没有0
/*CString data1,time1;
SYSTEMTIME sti;
GetLocalTime(&sti);
data1.Format(_T("%4d-%2d-%2d"),sti.wYear,sti.wMonth,sti.wDay);
CString str;
str=time.Format(("%H:%M:%S"));
str=time.Format("%Y/%m/%d %H:%M:%S");//月份和日期的格式,m和d需要小写
CFont *fond=new CFont;
fond->CreatePointFont(150,"黑体");//15号字体
CWnd *wnd=GetDlgItem(IDC_STATIC_Time);
wnd->SetFont(fond);
//设置颜色需要重载WM_CTLCOLOR函数
//这种方法获取的时间,在显示0-9时只显示一位,没有0
/*CString data1,time1;
SYSTEMTIME sti;
GetLocalTime(&sti);
data1.Format(_T("%4d-%2d-%2d"),sti.wYear,sti.wMonth,sti.wDay);
time1.Format(_T("%d-%d-%d"),sti.wHour,sti.wMinute,sti.wSecond);*/
CString str;
str=time.Format(("%H:%M:%S"));
str=time.Format("%Y/%m/%d %H:%M:%S");//月份和日期的格式,m和d需要小写
CFont *fond=new CFont;
fond->CreatePointFont(150,"黑体");//15号字体
CWnd *wnd=GetDlgItem(IDC_STATIC_Time);
wnd->SetFont(fond);
//设置颜色需要重载WM_CTLCOLOR函数
wnd->SetWindowTextA(m_time);
//把上面的代码放进定时器就行了
//重载WM_CTLCOLOR函数
HBRUSH C航向控制Dlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: 在此更改 DC 的任何特性
if (pWnd->GetDlgCtrlID()==IDC_STATIC_Time)
{
pDC->SetTextColor(RGB(255,0,0));
}
// TODO: 如果默认的不是所需画笔,则返回另一个画笔
return hbr;
}