15,979
社区成员
发帖
与我相关
我的任务
分享
void Ctemp03Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<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);
RECT rcTotal;
::GetClientRect(m_hWnd, &rcTotal);
BITMAPINFOHEADER bih = { 0 };
bih.biSize = sizeof(BITMAPINFOHEADER);
bih.biWidth = rcTotal.right - rcTotal.left;
bih.biHeight = (rcTotal.bottom - rcTotal.top); // use screen axis
bih.biPlanes = 1;
bih.biBitCount = 32;
bih.biCompression = BI_RGB;
HDC hdcBack = CreateCompatibleDC ( 0 );
char *m_lpBitsOnly = 0;
HBITMAP bmpBack = CreateDIBSection( 0, (PBITMAPINFO)&bih, DIB_RGB_COLORS, (void **)&m_lpBitsOnly, NULL, 0x0);
HGDIOBJ hOldObj = ::SelectObject(hdcBack, bmpBack);
CDC hello;
hello.Attach(hdcBack);
PaintWindowlessControls(&hello);
BLENDFUNCTION blendFunc = {AC_SRC_OVER, 0, 0xFF, AC_SRC_ALPHA };
::AlphaBlend(dc.GetSafeHdc(), 0, 0, bih.biWidth, bih.biHeight, hdcBack, 0, 0, bih.biWidth, bih.biHeight, blendFunc );
::SelectObject(hdcBack, hOldObj);
::DeleteObject(bmpBack);
//FILE *f = fopen("d:\\b.bin", "wb");
//fwrite(m_lpBitsOnly, 1, bih.biWidth*bih.biHeight*4, f);
//fclose(f);
//}
}
}