MFC中的CEdit和CStatic

时间:2020-12-29 00:06:12

类CEdit和CStatic的对象调用SetWindowText成员函数时要注意,CStatic的对象要先调用函数GetDlgItem(IDC_STATIC)后,再调用SetWindowText成员函数才能正确设置相应的值,而CEdit的对象则不需要。

[例]

......

wchar_t strTemp[INDEX] = L"";

CStatic * m_StatusIP = (CStatic *)GetDlgItem(IDC_STATIC5);

m_StatusIP->SetWindowText(strTemp);

 

[例]

......

CEdit m_AccessIP;

std::wstring strIP = L"192.168.0.1";

m_AccessIP.SetWindowText(strIP.c_str());