如何在MFC静态窗口中显示图片
CButtonm_Bmp;DDX_Control(pDX,IDC_BMP_1,m_Bmp);m_Bmp.ModifyStyle(0,SS_BITMAP);HBITMAPh...
CButton m_Bmp; DDX_Control(pDX, IDC_BMP_1, m_Bmp); m_Bmp.ModifyStyle(0,SS_BITMAP);
HBITMAP hBmp = (HBITMAP)::LoadImage(0, "D:\\1.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
m_Bmp.SetBitmap(hBmp); 可是就是不显示BMP图片为什么呢? 展开
HBITMAP hBmp = (HBITMAP)::LoadImage(0, "D:\\1.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
m_Bmp.SetBitmap(hBmp); 可是就是不显示BMP图片为什么呢? 展开
2013-07-18
展开全部
void CBirdDlg::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();
CRect rt;
GetClientRect(&rt);
CClientDC dc(this);
dc.FillSolidRect(&rt,RGB(22,88,12));
CDC* pDC=GetDC();
CDC memDC;
memDC.CreateCompatibleDC(pDC); //对其镂空。
CBitmap bitmap;
CBitmap* pOldBitmap;
bitmap.LoadBitmap(IDB_BITMAP2);
pOldBitmap = memDC.SelectObject(&bitmap); 我这个位图是自己绘的。并镂空处理了~ 所以你自己看看
{
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();
CRect rt;
GetClientRect(&rt);
CClientDC dc(this);
dc.FillSolidRect(&rt,RGB(22,88,12));
CDC* pDC=GetDC();
CDC memDC;
memDC.CreateCompatibleDC(pDC); //对其镂空。
CBitmap bitmap;
CBitmap* pOldBitmap;
bitmap.LoadBitmap(IDB_BITMAP2);
pOldBitmap = memDC.SelectObject(&bitmap); 我这个位图是自己绘的。并镂空处理了~ 所以你自己看看
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询