void CMainFrame::DrawTitleBar(CDC *pDC) { // TODO: 在此處添加消息處理程序代碼 // 不爲繪圖消息調用 CFrameWnd::OnNcPaint() pDC->SelectStockObject(NULL_BRUSH); pDC->SelectStockObject(NULL_PEN); CRect rtWnd, rtTitle, rtButtons; GetWindowRect(&rtWnd); //取得標題欄的位置 //SM_CXFRAME 窗口邊框的邊緣寬度 //SM_CYFRAME 窗口邊框的邊緣高度 //SM_CXSIZE 窗口標題欄寬度 //SM_CYSIZE 窗口標題欄高度 rtTitle.left = GetSystemMetrics(SM_CXFRAME); rtTitle.top = GetSystemMetrics(SM_CYFRAME); rtTitle.right = rtWnd.right - rtWnd.left - GetSystemMetrics(SM_CXFRAME); rtTitle.bottom = rtTitle.top + GetSystemMetrics(SM_CYSIZE); CPoint point; //填充頂部框架 point.x = rtWnd.Width(); point.y = GetSystemMetrics(SM_CYSIZE) + GetSystemMetrics(SM_CYFRAME) + 0; pDC->Rectangle(0, 0, point.x, point.y); //填充左側框架 point.x = GetSystemMetrics(SM_CXFRAME) -1; point.y = rtWnd.Height()- 1; pDC->Rectangle(0, 0, point.x, point.y); //填充底部框架 point.x = rtWnd.Width(); point.y = GetSystemMetrics(SM_CYFRAME); pDC->Rectangle(0, rtWnd.Height()-point.y, point.x, point.y); //填充右側框架 point.x = GetSystemMetrics(SM_CXFRAME); point.y = rtWnd.Height(); pDC->Rectangle(rtWnd.Width()-point.x, 0, point.x, point.y); }