这些是自己整理的一部分:
方法一:
//--隐藏应用、帮助、确定、取消 按钮 CWnd *pWnd = GetDlgItem (ID_APPLY_NOW); if(pWnd && pWnd->GetSafeHwnd()) pWnd->ShowWindow (FALSE); pWnd = GetDlgItem (IDHELP); if(pWnd && pWnd->GetSafeHwnd()) pWnd->ShowWindow (FALSE); pWnd = GetDlgItem (IDOK); if(pWnd && pWnd->GetSafeHwnd()) pWnd->ShowWindow (FALSE); pWnd = GetDlgItem (IDCANCEL); if(pWnd && pWnd->GetSafeHwnd()) pWnd->ShowWindow (FALSE);方法二:
GetDlgItem(IDOK)->ShowWindow(SW_HIDE); GetDlgItem(IDHELP)->ShowWindow(SW_HIDE); GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE); GetDlgItem(ID_APPLY_NOW)->ShowWindow(SW_HIDE);
首先先隐藏(去除)下方的按钮
//--隐藏应用、帮助、确定、取消 按钮 GetDlgItem(IDOK)->ShowWindow(SW_HIDE); GetDlgItem(IDHELP)->ShowWindow(SW_HIDE); GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE); GetDlgItem(ID_APPLY_NOW)->ShowWindow(SW_HIDE); //调整窗体位置 ::SetWindowPos(this->m_hWnd, HWND_TOP,100,100,0,0,SWP_SHOWWINDOW|SWP_NOSIZE);<span style="color:#ff0000;">//这一步不可缺</span>
设置文字Logo
//---在标签页右下角显示Logo CFont m_font; CRect rect; CString m_LogoName = L"What you see is What you mean"; CDC* pDC=GetDC(); GetWindowRect(rect); ScreenToClient(rect); LOGFONT logFont; ZeroMemory((void*)&logFont,sizeof(logFont)); lstrcpy(logFont.lfFaceName,L"宋体"); logFont.lfHeight = -12; logFont.lfWeight = 50; logFont.lfCharSet = GB2312_CHARSET; logFont.lfOutPrecision = 3; logFont.lfClipPrecision = 2; logFont.lfQuality = 1; logFont.lfPitchAndFamily = 2; m_font.CreateFontIndirect(&logFont); SetFont(&m_font); CFont *pOldFont = pDC->SelectObject(&m_font); rect.left += 6; rect.right -= 3; rect.bottom -= 1; rect.top = rect.bottom+50; //-ITEMBUTTON_HEIGHT + 1; CFont m_LogoFont; CString sLogoString; m_LogoFont.CreateFont(rect.Height()*2/5, 0, 0, 0, FW_BOLD, 1, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FIXED_PITCH | FF_ROMAN, L"楷体_GB2312"); sLogoString = m_LogoName; RECT m_rDataBox; CopyRect(&m_rDataBox,&rect); TEXTMETRIC tm; pDC->GetTextMetrics(&tm); CFont* oldFont = pDC->SelectObject(&m_LogoFont); CSize sz = pDC->GetTextExtent(sLogoString, sLogoString.GetLength()); //用GetTextExtent来计算字体logo大小,依靠于设备环境,使用logo位于右下角 m_rDataBox.left = m_rDataBox.right - sz.cx - tm.tmAveCharWidth/2; m_rDataBox.top = m_rDataBox.bottom - sz.cy - tm.tmHeight/5; pDC->SetBkMode(TRANSPARENT); //用3D字体显示,先黑后白,最后再用默认色 COLORREF oldColor = pDC->SetTextColor(GetSysColor(COLOR_3DDKSHADOW)); pDC->DrawText(sLogoString, sLogoString.GetLength(), &m_rDataBox, DT_VCENTER | DT_SINGLELINE | DT_CENTER); m_rDataBox.left -= tm.tmAveCharWidth; pDC->SetTextColor(GetSysColor(COLOR_3DHILIGHT)); pDC->DrawText(sLogoString, sLogoString.GetLength(), &m_rDataBox, DT_VCENTER | DT_SINGLELINE | DT_CENTER); m_rDataBox.left += 3*tm.tmAveCharWidth/5; pDC->SetTextColor(RGB(0,0,255)); pDC->DrawText(sLogoString, sLogoString.GetLength(), &m_rDataBox, DT_VCENTER | DT_SINGLELINE | DT_CENTER); //释放资源 pDC->SelectObject(oldFont); pDC->SetTextColor(oldColor); m_LogoFont.DeleteObject(); /////////////////////////////////////////////////////////////////////////
本人在VS2010中测试有效