请好心人帮忙吧。

mmpp_langchao0920 2006-03-02 01:13:26
偶是vc新手,现在做项目。是这样的:我先将背景图已经加载到对话框了。但是框中有复选框没有颜色,很难看。请问如何可以将对话框中该区域的颜色给复选框,这样才可以保证背景图的完整性?急死我了。请好心人帮帮我吧。感激不尽。。。。。
...全文
60 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
mmpp_langchao0920 2006-03-02
  • 打赏
  • 举报
回复
对了,两位兄弟,还有问题呢,怎么我选了复选框之后,画面闪个不停呢?
mmpp_langchao0920 2006-03-02
  • 打赏
  • 举报
回复
恩。谢谢ydfivy。可以了。揭帖。再次感谢两位兄弟。搞定。
mmpp_langchao0920 2006-03-02
  • 打赏
  • 举报
回复
浪子兄,那如何设置字体大小呢?
一个傻冒 2006-03-02
  • 打赏
  • 举报
回复
HBRUSH CGgDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

// TODO: Change any attributes of the DC here
if((pWnd->GetDlgCtrlID()==IDC_CHECK1/*换成你的复选框的ID*/))
{
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(255, 255, 0)); //设置颜色
return HBRUSH(GetStockObject(HOLLOW_BRUSH));
}
// TODO: Return a different brush if the default is not desired
// TODO: Return a different brush if the default is not desired
return hbr;
}
字体大小:获得复选框的指针,然后SetFont()就可以吧.我没试过.
YufengShi 2006-03-02
  • 打赏
  • 举报
回复

HBRUSH CZilchDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
// Call the base class implementation first! Otherwise, it may
// undo what we're trying to accomplish here.
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

// Are we painting the IDC_CHECK1 control? We can use
// CWnd::GetDlgCtrlID() to perform the most efficient test.
if (pWnd->GetDlgCtrlID() == IDC_CHECK1)
{
// Set the text color to red
//pDC->SetTextColor(RGB(255, 0, 0));

// Set the background mode for text to transparent
// so background will show thru.
pDC->SetBkMode(TRANSPARENT);

// Return handle to our CBrush object
hbr = HBRUSH(::GetStockObject(NULL_BRUSH));
}

return hbr;
}
mmpp_langchao0920 2006-03-02
  • 打赏
  • 举报
回复
恩,谢谢楼上兄弟的热心帮助。后面的可以了。不好意思,我还想请兄弟告诉我,如何可以设置该复选框字体的大小和颜色阿。。。。
一个傻冒 2006-03-02
  • 打赏
  • 举报
回复
HBRUSH CGgDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

// TODO: Change any attributes of the DC here
if((pWnd->GetDlgCtrlID()==IDC_CHECK1/*换成你的复选框的ID*/))
{
pDC->SetBkMode(TRANSPARENT);
return HBRUSH(GetStockObject(HOLLOW_BRUSH));
}
// TODO: Return a different brush if the default is not desired
// TODO: Return a different brush if the default is not desired
return hbr;
}
我试了,这样应该是可以的.刚才发给你的,让你判断了CTLCOLOR_EDIT是没有必要的.对不起.
一个傻冒 2006-03-02
  • 打赏
  • 举报
回复
HBRUSH CXXXXXDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CScrollView::OnCtlColor(pDC, pWnd, nCtlColor);

// TODO: Change any attributes of the DC here
if(((pWnd->GetDlgCtrlID()==IDC_CHECK/*换成你的复选框的ID*/))
{
pDC->SetBkMode(TRANSPARENT);
return HBRUSH(GetStockObject(HOLLOW_BRUSH));
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
这样行不行?

一个傻冒 2006-03-02
  • 打赏
  • 举报
回复
我做编辑框透明的时候就是这么做的.
你把代码发给我吧.
ydfcom@sina.com
mmpp_langchao0920 2006-03-02
  • 打赏
  • 举报
回复
谢谢楼上的兄弟,可是我按你的东西不行啊。再次求救!
一个傻冒 2006-03-02
  • 打赏
  • 举报
回复
HBRUSH CXXXXXDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CScrollView::OnCtlColor(pDC, pWnd, nCtlColor);

// TODO: Change any attributes of the DC here
if((nCtlColor == CTLCOLOR_EDIT) && (pWnd->GetDlgCtrlID()==IDC_CHECK/*换成你的复选框的ID*/))
{
pDC->SetBkMode(TRANSPARENT);
return HBRUSH(GetStockObject(HOLLOW_BRUSH));
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
试试这样行不行.

15,979

社区成员

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

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