我想在对话框里显示一个不规则的图片,并且让空白部分透明???!各位大哥帮帮忙啊!!

ww012 2004-10-15 10:17:11
如题
...全文
172 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
ww012 2004-10-18
  • 打赏
  • 举报
回复
谢谢大家!
ww012 2004-10-15
  • 打赏
  • 举报
回复
我图片的四角都是圆形的,不是矩形的,这个怎么实现啊!我一时找不到恰当的例子
lixiaosan 2004-10-15
  • 打赏
  • 举报
回复
http://www.codeguru.com/Cpp/G-M/bitmap/specialeffects/article.php/c1729/
DentistryDoctor 2004-10-15
  • 打赏
  • 举报
回复
http://www.codeguru.com/Cpp/G-M/bitmap/specialeffects/article.php/c1773/
DentistryDoctor 2004-10-15
  • 打赏
  • 举报
回复
http://www.codeguru.com/Cpp/G-M/bitmap/specialeffects/article.php/c1729/
快乐鹦鹉 2004-10-15
  • 打赏
  • 举报
回复
这好办。设置裁减就行了。
Meteorlet 2004-10-15
  • 打赏
  • 举报
回复
像素颜色自身异或就透明了
lygfqy 2004-10-15
  • 打赏
  • 举报
回复
www.vckbase.com上例子多的很,自己载一个看看
菜牛 2004-10-15
  • 打赏
  • 举报
回复
TransparentBlt();
jag1976 2004-10-15
  • 打赏
  • 举报
回复
OnPaint()

{
CDC * pDC = this->GetDC();
CRect rect;
GetWindowRect(&rect);
pDC->BitBlt(0,0,rect.Width(),rect.Height(),&m_DC,0,0,SRCCOPY);
}
jag1976 2004-10-15
  • 打赏
  • 举报
回复
.h中:
CBitmap * m_oldBitmap;
CDC m_DC;
.cpp OnInitDialog()
{
....

CBitmap bitmap;
BITMAP bitInfo;
bitmap.LoadBitmap(IDB_BACKGROUND);
//µÃµ½Í¼Æ¬´óС²¢µ÷Õû´°¿Ú´óСÊÊӦͼƬ
bitmap.GetBitmap(&bitInfo);
CRect rect;
GetWindowRect(&rect);
rect.right = rect.left + bitInfo.bmWidth;
rect.bottom = rect.top + bitInfo.bmHeight;
MoveWindow(rect);

m_DC.CreateCompatibleDC(GetDC());
m_oldBitmap = m_DC.SelectObject(&bitmap);

COLORREF maskColor = RGB(255,0,0);//背景色

#define LWA_COLORKEY 0x00000001
#define WS_EX_LAYERED 0x00080000

typedef BOOL (WINAPI *lpfnSetLayeredWindowAttributes)(HWND hWnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags);
lpfnSetLayeredWindowAttributes SetLayeredWindowAttributes;

HMODULE hUser32 = GetModuleHandle("user32.dll");
SetLayeredWindowAttributes = (lpfnSetLayeredWindowAttributes)GetProcAddress(hUser32,"SetLayeredWindowAttributes");
SetWindowLong(GetSafeHwnd(), GWL_EXSTYLE, GetWindowLong(GetSafeHwnd(), GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(GetSafeHwnd(), maskColor, 255, LWA_COLORKEY);
FreeLibrary(hUser32);
}
OnCancel()
{

CBitmap * bitmap = m_DC.SelectObject(m_oldBitmap);
m_DC.DeleteDC();
bitmap->DeleteObject();

CDialog::OnCancel();

}
nwpulipeng 2004-10-15
  • 打赏
  • 举报
回复
n多高手在这里呀!!

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧