一个漂亮的界面

发表于:2007-07-01来源:作者:点击数: 标签:
主要代码如下: void CPageDlg::OnPaint(){ if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM)dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CX


主要代码如下:

void CPageDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM)dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { // CDialog::OnPaint(); //一定要去掉该句 CPaintDC dc(this); //对话框的dc CDC dcMem; dcMem.CreateCompatibleDC(&dc); //创建与对话框dc兼容的内存dc CRect rect; GetClientRect(&rect); BITMAP bitMap; m_bmpBackground.GetBitmap(&bitMap); CBitmap *pbmpOld = dcMem.SelectObject(&m_bmpBackground); //将背景位图选入内存dc中 dc.StretchBlt(0, 0, rect.Width(), rect.Height(), &dcMem, 0, 0, bitMap.bmWidth, bitMap.bmHeight, SRCCOPY); //dc.BitBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0,SRCCOPY); } }

原文转自:http://www.ltesting.net