Code:
void CblaDlg::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);
}
CPaintDC dc(this);
CBitmap Bitmap;
CDC MemDC;
Bitmap.LoadBitmap(IDB_BITMAP1);
MemDC.CreateCompatibleDC(&dc);
MemDC.SelectObject(&Bitmap);
//Draw sides
dc.StretchBlt(16,0,m_CX-32,16,&MemDC,16,0,16,16,SRCCOPY);
dc.StretchBlt(0,16,16,m_CY-32,&MemDC,0,16,16,16,SRCCOPY);
dc.StretchBlt(m_CX-16,16,16,m_CY-32,&MemDC,32,16,16,16,SRCCOPY);
dc.StretchBlt(16,m_CY-16,m_CX-32,16,&MemDC,16,32,16,16,SRCCOPY);
//Draw corners
dc.StretchBlt(0,0,16,16,&MemDC,0,0,16,16,SRCCOPY);
dc.StretchBlt(m_CX-16,0,16,16,&MemDC,32,0,16,16,SRCCOPY);
dc.StretchBlt(0,m_CY-16,16,16,&MemDC,0,32,16,16,SRCCOPY);
dc.StretchBlt(m_CX-16,m_CY-16,16,16,&MemDC,32,32,16,16,SRCCOPY);
//Draw center
dc.StretchBlt(16,16,m_CX-32,m_CY-32,&MemDC,16,16,16,16,SRCCOPY);
MemDC.DeleteDC();
Bitmap.DeleteObject();
}
hope you can understand what it does