如何将位图设置为对话框的背景图像 [英] how to set bitmap as background image of dialog box

查看:97
本文介绍了如何将位图设置为对话框的背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从事基于(win32)对话框的项目.
有什么方法可以用图像更改对话框的背景.
我不想使用mfc实现,只能在win32中使用.

解决方案

在OnPaint功能下,在其他位置添加此

 其他
{

    CPaintDC dc();
    CRect rect;
    GetClientRect(& rect);
    //  ScreenToClient(rect); 
    位图bmp;
    HBITMAP hBmp = :: LoadBitmap(:: AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP2));
    :: GetObject(hBmp, sizeof (bmp),& bmp);
    HDC hDC = :: CreateCompatibleDC(NULL);
    SelectObject(hDC,hBmp);
    :: BitBlt(dc.m_hDC, 0  0 ,rect.Width(),rect.Height( ),hDC, 0  0 ,SRCCOPY);
    CDialog :: OnPaint();
}


此处的链接可以以-开始使用MFC [ ^ ]

我不记得要更改背景的任何Win32 API.但是如何在WM_PAINT消息中的对话框上绘制图像

您将在此链接 [ 解决方案

In the OnPaint funtion under else add this

else
{

    CPaintDC dc(this);
    CRect rect;
    GetClientRect(&rect);
    //ScreenToClient(rect);
    BITMAP bmp;
    HBITMAP hBmp = ::LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP2));
    ::GetObject(hBmp, sizeof(bmp), &bmp);
    HDC hDC = ::CreateCompatibleDC(NULL);
    SelectObject(hDC, hBmp);
    ::BitBlt(dc.m_hDC, 0, 0, rect.Width(), rect.Height(), hDC, 0, 0, SRCCOPY);
    CDialog::OnPaint();
}


Here a link you can start with - Using Skins Without MFC[^]


I cannot remember any Win32 API to Change the background. But How about drawing an image on the dialog in the WM_PAINT message

You will gel help on this link[^] on how to load BITMAP


这篇关于如何将位图设置为对话框的背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆