有一个按钮,原文本是StartTimer,希望按一次按钮后,文本变为StopTimer,再按一次变为StartTimer,
m_startbutton.GetWindowText(str);
if(str="StartTimer")
{
m_startbutton.SetWindowText("StopTimer");
}
else
{
m_startbutton.SetWindowText("StartTimer");
}
但第一次按后,文本就不改变了,为什么呀?
m_startbutton.GetWindowText(str);
if(str="StartTimer")
{
m_startbutton.SetWindowText("StopTimer");
}
else
{
m_startbutton.SetWindowText("StartTimer");
}
但第一次按后,文本就不改变了,为什么呀?
改成
if(str=="StartTimer")
希望以后写if语句的时候用如果格式:
if ("StartTimer" == str) {
//...
}