简单的调用系统API。

Windows NT/2000/XP: Included in Windows 2000 and later.
Windows 95/98/Me: Included in Windows 98 and later.
Header: Declared in Wingdi.h; include Windows.h.
Library: Use Msimg32.lib.

void CTransparentBltTestDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting

CDialog::OnPaint();
COLORREF crMask = RGB(0x00,0x00,0xff); // Mask color of bitmap
BITMAP bm;
m_bmp.GetBitmap(&bm);
int nWidth = bm.bmWidth;
int nHeight = bm.bmHeight;
CDC ImageDC;
ImageDC.CreateCompatibleDC(&dc);
CBitmap *pOldImageBMP = ImageDC.SelectObject(&m_bmp);
::TransparentBlt(dc.m_hDC,50,40,nWidth,nHeight,ImageDC.m_hDC,0,0,nWidth,nHeight,crMask);
ImageDC.SelectObject(pOldImageBMP);
}
}
TransparentBlt
The TransparentBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context.

Parameters
hdcDest
[in] Handle to the destination device context.
nXOriginDest
[in] Specifies the x-coordinate, in logical units, of the upper-left corner of the destination rectangle.
nYOriginDest
[in] Specifies the y-coordinate, in logical units, of the upper-left corner of the destination rectangle.
nWidthDest
[in] Specifies the width, in logical units, of the destination rectangle.
hHeightDest
[in] Handle to the height, in logical units, of the destination rectangle.
hdcSrc
[in] Handle to the source device context.
nXOriginSrc
[in] Specifies the x-coordinate, in logical units, of the source rectangle.
nYOriginSrc
[in] Specifies the y-coordinate, in logical units, of the source rectangle.
nWidthSrc
[in] Specifies the width, in logical units, of the source rectangle.
nHeightSrc
[in] Specifies the height, in logical units, of the source rectangle.
crTransparent
[in] The RGB color in the source bitmap to treat as transparent.
Return Values
If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE.
Windows NT/2000/XP: To get extended error information, call GetLastError .

http://blog.csdn.net/harbinzju/article/details/5844798

如何在VC中显示透明背景位图的更多相关文章

  1. VC中实现带有背景位图的树型控件

    当前许多应用程序都在使用树型控件时为其添加了背景位图,增强的控件的魅力,然而对于Visual C++编程爱好者来说,使用Visual C++MFC提供的树型控件(CTreeCtrl)本身就是一个难点, ...

  2. vc下打印透明背景图片

    一.前言 刚接到个任务,要把带有透明背景的章子图片打印出来,开始觉得不是很简单吗,直接用vc自动生成的打印功能不就ok了.不过问题却不是想像的那么简单! 二.窗口中显示透明图片 在窗口中显示图片,可以 ...

  3. 如何在VC++ 中调试MEX文件

    MEX文件对应的是将C/C++文件语言的编写之后 得到的相关文件加载到Matlab中运行的一种方式, 现对于Matlab 中的某些程序运行效率而言, C/C++ 代码某些算法的领域上面执行效率很高,若 ...

  4. 网页中PNG透明背景图片的完美应用

    PNG 图片在网站设计中是不可或缺的部分,最大的特点应该在于 PNG 可以无损压缩,而且还可以设置透明,对于增强网站的图片色彩效果有重要的作用. 但为什么 PNG 图片却没有 GIF 和 JPG 图片 ...

  5. 如何在VC中查询中文,及QT5的中文处理

    1,VC中查询所有含中文字符串 使用正则表达式,查询内容为: (".*[\u4E00-\u9FA5]+)|([\u4E00-\u9FA5]+.*") 这样,就可以把代码中的中文都查 ...

  6. DevExpress中barManager下的toolbar如何在panel中显示

    如题,我的Dev Toolbar需要在一个pannel中显示,并且居于最顶部.可是好像默认情况下toolbar都是在窗体的最顶部的,如何设置才能使其位于一个panel的最顶部呢? 解决方案:经过测试, ...

  7. 在VC中显示和处理图片的方法

    落鹤生 发布于 2011-10-21 09:12 点击:344次  来自:blog.csdn.net/mengaim_cn 几种用GDI画图的方法介绍. TAG: GDI   法1:这个方法其实用的是 ...

  8. java 显示透明背景png图片

    首先理由ps生成一个背景透明的png图片,然后设置JPanel面板的透明属性,也就是panel.setOpaque(false);设置为透明 class MyPanel extends JLayere ...

  9. 如何在UIAlertView中显示进度条

    今天这个问题是,在一个iPhone程序中,我要在后台做大量的数据处理,希望在界面上显示一个进度条(Progress Bar)使得用户了解处理进度.这个进度条应该是在一个模态的窗口中,使界 今天这个问题 ...

随机推荐

  1. js求指定时间的周一和周日

    /*计算指定时间的的周一和周日 return=>{mondy:Date,sundy:Date} parms:{ date:指定时间,如果不指定则取当前时间 } */ function getWe ...

  2. 汇总:Linux下10款即时通讯客户端,skype

    aMSN 是一款功能强大的MSN(WLM)的客户端,支持皮肤.插件.系统托盘图标.摄像头.多帐号登录.离线信息等. Pidgin 不用说了,是GNOME下的IM客户端,支持AIM, Google Ta ...

  3. Uva 10935 Throwing cards away I

    题目意思:有N张牌,标号为1~N,且牌以叠好,从上到小就是标号1-N的牌,只要牌堆数量大于等于2的时候,就采取如下操作:将最上面的牌扔掉(即离开牌堆).刚才那张牌离开后,再将新的最上面的牌放置于牌堆最 ...

  4. 最短路Dijkstra和Flyod

    Problem Description 在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt.但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要 ...

  5. swift菜鸟入门视频教程-07-闭包

    本人自己录制的swift菜鸟入门,欢迎大家拍砖.有什么问题能够在这里留言. 主要内容: 闭包表达式(Closure Expressions) 跟随闭包(Trailing Closures) 值捕获(C ...

  6. JavaScript+XML+VBA导出报表初步构想

    最近在做人事档案管理系统遇到的一个问题就是种类多.数量大的报表打印问题.这个系统的一个特点就是信函打印,各种介绍信.各种证明信.对于这样的重复性的功能,最好的方法就是所有的报表实现格式套用. 经过分析 ...

  7. CursorAdapter说明

    参考:http://www.bubuko.com/infodetail-734550.html和http://blog.csdn.net/yuzhiboyi/article/details/76548 ...

  8. c++,虚函数

    1.在声明函数时,在最前加上virtual,则该函数就是函虚数,基类的虚函数被派生类继承后仍是虚函数.2.派生类中可以重写基类的虚函数.3.用指针访问重写的虚函数时,被访问的虚函数是指针指向的对象所属 ...

  9. C语言,单链表操作(增删改查)(version 0.1)

    这天要面试,提前把链表操作重新写了一遍.备份一下,以备不时之需. 希望有人能看到这篇代码,并指正. // File Name : list.h #include "stdafx.h" ...

  10. iOS判断字符串是否包含表情字符

    - (BOOL)isContainsEmoji:(NSString *)string { __block BOOL isEomji = NO; [, [string length]) options: ...