16,472
社区成员
发帖
与我相关
我的任务
分享
m_bitmap = &bitmap;
Invalidate();
MyStatic::MyStatic()
{
m_bitmap = new CBitmap;
m_hbitmap = (HBITMAP)LoadImage(NULL, _T("d:/123.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
m_bitmap->Attach(m_hbitmap);
if (NULL == m_bitmap->m_hObject)
{
MessageBox(_T("Load image fail."), _T("fail"), MB_OK);
}
}
void MyStatic::MyCreate(CRect &rect, CWnd *pWnd, int ID)
{
CStatic::Create(_T(""), WS_CHILD | WS_VISIBLE | SS_BITMAP, rect, pWnd, ID);
}
CPaintDC dc(this);
CRect rect;
GetClientRect(rect);
CDC memDC;
memDC.CreateCompatibleDC(NULL);
memDC.SelectObject(m_bitmap);
//dc.BitBlt(0, 0, rect.Width(), rect.Height(), &memDC, 0, 0, SRCCOPY);
dc.StretchBlt(0, 0, rect.Width()-2, rect.Height()-2, &memDC, 0, 0, rect.Width(), rect.Height(), SRCCOPY);
void CCStaticBMPDlg::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
CRect rect;
GetClientRect(rect);
CRect rect1(rect.left+3, rect.top + 3, rect.right -3, rect.bottom -40);
m_mystatic = new MyStatic();
m_mystatic->MyCreate(rect1, this, 0x1100);
}
void CCStaticBMPDlg::OnBnClickedCancel()
{
// TODO: Add your control notification handler code here
CBitmap m_bitmap;
HBITMAP m_hmap;
m_hmap = (HBITMAP)LoadImage(NULL, _T("d:/share/122.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
m_bitmap.Attach(m_hmap);
m_mystatic->NextPic(m_bitmap);
//OnCancel();
}
memDC.DeleteDC();
m_bitmap.DeleteObject();