Hello experts,
How to clear text of static text mfc? I don’t know how to perform this kind of clearing text. I need your guidance or step by step instruction to get this done properly. There are some instances that it will not be cleared but I hope this time it will.
How to clear text of static text mfc?
Â
Hi Debra,Â
You can use following method to clear the text.
First get the item by calling GetDlgItem method. For example
  CWnd* pWindow = GetDlgItem(IDC_Label_STATIC);
Then Setting its text my using the following code
 pWindow->SetDlgItemTextW(IDC_Label_STATIC, _T(""));
Other way to do this is to declare the variable as static, then initializing it as static control and then changing the value.
CStatic *Static_text; Â
Static_text = new CStatic;Â
Static_text->Create("I'm a static", WS_CHILD | WS_VISIBLE,
     CRect(3, 4, 11, 18), this, 900);Â
 void CPlotDlg::OnBnClickedButton1()
{
Static_text->SetWindowText("I'm changed");
}
I hope it will help you.
Thank you