首页 > 解决方案 > 格式':不是'CStatic'计时器的成员

问题描述

void CTimersDlg::OnTimer(UINT_PTR nIDEvent)
{
    // TODO: Add your message handler code here and/or call default
    CTime curTime = CTime::GetCurrentTime();

    m_sTime.Format("%d:%d:%d",curTime.GetHour(),curTime.GetMinute(),curTime.GetSecond());
    
    // Update the dialog
    UpdateData(FALSE);
    CDialogEx::OnTimer(nIDEvent);
}

标签: c++visual-c++mfc

解决方案


使用 MFC,您可以创建两种与 a 关联的变量STATICcontrol类型为CStatic(如您所拥有)和value类型为CString.

您标记visual-studio-code了 - 那是您正在使用的吗?如果您正在使用Visual Studio,我建议使用向导:右键单击STATIC对话框中的控件(在资源编辑器中)并选择Add Variable.... 在Category下拉框中选择Value. 您将能够调用.Format()该变量。

您可以为同一个控件创建两种变量,不确定是否需要。


推荐阅读