哪位大哥会透明按钮?(实现了马上给分)

SlayerCarrier 2004-01-26 02:10:20
我从CButton派生了一个CButtonX类,在DrawItem中写字。而主窗口的背景是贴上去的Bitmap,按钮是动态Create的。可是按钮不透明(一个灰色的方框,难看)。哪位大哥指点一下,感激不尽!!!
...全文
119 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
DebugXP 2004-02-01
  • 打赏
  • 举报
回复
参考CButtonST
yintongshun 2004-02-01
  • 打赏
  • 举报
回复
CButtonST:
http://www.vckbase.com/document/viewdoc.asp?id=518

http://www.vckbase.com/document/viewdoc.asp?id=519

http://www.vckbase.com/document/viewdoc.asp?id=647

http://www.vckbase.com/document/viewdoc.asp?id=521

http://www.vckbase.com/document/viewdoc.asp?id=520

http://www.vckbase.com/document/viewdoc.asp?id=517


DotLSong 2004-02-01
  • 打赏
  • 举报
回复
up,参考CButtonST
去http://www.vckbase.com/ 看看
zhangcrony 2004-01-31
  • 打赏
  • 举报
回复
void CXxxButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{

// TODO: Add your code to draw the specified item
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CRect btnRect;
btnRect.CopyRect(&lpDrawItemStruct->rcItem);
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,80));
pDC->DrawText( "XButton",btnRect,DT_CENTER);
}
BOOL CXxxButton::OnEraseBkgnd(CDC* pDC)
{
return 0; ////不行的话就改成1
}
无我无人 2004-01-31
  • 打赏
  • 举报
回复
你是要求位图的背景不透明,而不是按钮本身透明吧?也就是要像ICON那样是吗?
dTianx 2004-01-27
  • 打赏
  • 举报
回复
HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
// HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

switch (nCtlColor)
{
case CTLCOLOR_STATIC:
pDC->SetTextColor(RGB(0, 0, 0));
pDC->SetBkColor(RGB(255,255,255));
case CTLCOLOR_EDIT:
pDC->SetTextColor(RGB(0, 0, 0));
pDC->SetBkColor(RGB(255,255,255));
case CTLCOLOR_LISTBOX:
pDC->SetTextColor(RGB(0, 0, 0));
pDC->SetBkColor(RGB(255,255,255));
case CTLCOLOR_SCROLLBAR:
pDC->SetTextColor(RGB(0, 0, 0));
pDC->SetBkColor(RGB(255,255,255));
case CTLCOLOR_BTN:
pDC->SetTextColor(RGB(0, 0, 0));
pDC->SetBkColor(RGB(255,255,255));
case CTLCOLOR_DLG:
return m_Brush;
}

// TODO: Return a different brush if the default is not desired
return m_Brush;
}

//现在懂了么??

wmzlq 2004-01-27
  • 打赏
  • 举报
回复
搜索一下CQiuXPButton
nonocast 2004-01-26
  • 打赏
  • 举报
回复
HOHO

看看CButtonST
zhangcrony 2004-01-26
  • 打赏
  • 举报
回复
void CXxxButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{

// TODO: Add your code to draw the specified item
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CRect btnRect;
btnRect.CopyRect(&lpDrawItemStruct->rcItem);
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,80));
pDC->DrawText( "XButton",btnRect,DT_CENTER);
}
BOOL CXxxButton::OnEraseBkgnd(CDC* pDC)
{
return 0; ////不行的话就改成1
}
zhjie374 2004-01-26
  • 打赏
  • 举报
回复
lingfeng8888(棱枫):YEAH!
zhangcrony 2004-01-26
  • 打赏
  • 举报
回复
同意lingfeng8888(棱枫) ,試試先﹗
ok1234567 2004-01-26
  • 打赏
  • 举报
回复
重载:
void CXxxButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{

// TODO: Add your code to draw the specified item
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CRect btnRect;
btnRect.CopyRect(&lpDrawItemStruct->rcItem);
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,80));
pDC->DrawText( "XButton",btnRect,DT_CENTER);
}
BOOL CXxxButton::OnEraseBkgnd(CDC* pDC)
{
return FALSE;
}
lingfeng8888 2004-01-26
  • 打赏
  • 举报
回复
在你的派生CButtonX类中,映射WM_ERASEBKGND消息,在该消息处理函数中
BOOL C_your_Dlg::OnEraseBkgnd(CDC* pDC)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值

return CDialog::OnEraseBkgnd(pDC); //将这句改为返回1(或0),然后试试
}
SlayerCarrier 2004-01-26
  • 打赏
  • 举报
回复
我就是自己绘的啊。我没有画的部分都是灰色!我想没有画的部分是透明的,即是背景的bitmap.
帮帮忙饿!
ok1234567 2004-01-26
  • 打赏
  • 举报
回复
自己绘制一个图形按钮
网上有很多这样的现成的类(CXxxButton)
建议你到codeguru去下载一个

15,978

社区成员

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

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