第二十七篇 -- 如何给静态文本设置成ico图标形式以及如何修改文本框中的内容
修改静态文本框内容:
CWnd* pWnd = GetDlgItem(IDC_STATIC1); pWnd->SetWindowText(_T("Server is on!"));
将静态文本框中显示图标
//添加红绿灰三种图标 DWORD dwStyle = WS_VISIBLE | WS_CHILD | SS_ICON; ::SetWindowLong(Icon_Static.m_hWnd, GWL_STYLE, dwStyle); ::SetWindowLong(Icon_Static_Green.m_hWnd, GWL_STYLE, dwStyle); //HICON hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON1)); //((CStatic *)GetDlgItem(IDC_STATIC5))->SetIcon(hIcon); HICON hIcon_red = (HICON)::LoadImage(AfxGetInstanceHandle(), 1 ? MAKEINTRESOURCE(IDI_ICON1) : MAKEINTRESOURCE(IDI_ICON2), IMAGE_ICON, 16, 16, LR_SHARED); HICON hIcon_gray = (HICON)::LoadImage(AfxGetInstanceHandle(), 0 ? MAKEINTRESOURCE(IDI_ICON1) : MAKEINTRESOURCE(IDI_ICON3), IMAGE_ICON, 16, 16, LR_SHARED); ((CStatic *)GetDlgItem(IDC_STATIC8))->SetIcon(hIcon_red); ((CStatic *)GetDlgItem(IDC_STATIC9))->SetIcon(hIcon_gray);