请问msg结构中的wparam中在on—ctlcolor中包含有发送者的ID吗?

gotooker 2008-01-18 03:46:14
如题
新手,希望各位高手不吝赐教

我想知道wparam中一般包含什么信息,有没有发送控件的id信息??
...全文
98 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
菜牛 2008-01-19
  • 打赏
  • 举报
回复
你要判断是哪一个控件,用pWnd参数不就可以了?
if (pWnd->GetDlgCtrlID() == IDC_EDIT1)
....
gotooker 2008-01-19
  • 打赏
  • 举报
回复
多谢各位 不知道怎么加分,给完分回复就好了??试验下
gotooker 2008-01-18
  • 打赏
  • 举报
回复
TO yxz_lp


你好,我试验成功了,请问GetDlgItem()后面的,GetsafeHwnd()有什么用出?
gotooker 2008-01-18
  • 打赏
  • 举报
回复
m_hbr是类中定义的一个刷子,已经设为黄色
gotooker 2008-01-18
  • 打赏
  • 举报
回复
不好意思我忘记说了,我的edit是只读的,所以都为staic的
gotooker 2008-01-18
  • 打赏
  • 举报
回复
HBRUSH zdjc::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

if(nCtlColor==CTLCOLOR_STATIC)
{
const MSG *msg=GetCurrentMessage();
if(int((msg->lParam))==IDC_EDIT1)
pDC->SetBkColor(RGB(255,255,0));
return m_hbr;
}
// TODO: Change any attributes of the DC here

// TODO: Return a different brush if the default is not desired
return hbr;
}
这样的话背景全黄了,还是没有区分开IDC_EDIT!
yxz_lp 2008-01-18
  • 打赏
  • 举报
回复

HBRUSH zdjc::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

if(nCtlColor==CTLCOLOR_EDIT)
{
const MSG *msg=GetCurrentMessage();
if((HWND)msg-> lParam==GetDlgItem(IDC_EDIT1)->GetSafeHwnd())
pDC-> SetBkColor(RGB(255,255,0));



}
// TODO: Change any attributes of the DC here

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

shakaqrj 2008-01-18
  • 打赏
  • 举报
回复
hbr给各其他值
gotooker 2008-01-18
  • 打赏
  • 举报
回复
HBRUSH zdjc::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

if(nCtlColor==CTLCOLOR_STATIC)
{
const MSG *msg=GetCurrentMessage();
if(int(HIWORD(msg->lParam))==IDC_EDIT1)
pDC->SetBkColor(RGB(255,255,0));
}
// TODO: Change any attributes of the DC here

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

我想用上述方法让窗体内的指定控件改变背景色,为什么没有反应??
yxz_lp 2008-01-18
  • 打赏
  • 举报
回复
WM_CTLCOLOR
The WM_CTLCOLOR message is used in 16-bit versions of Windows to change the color scheme of list boxes, the list boxes of combo boxes, message boxes, button controls, edit controls, static controls, and dialog boxes.

Note For information related to this message and 32-bit versions of Windows, see Remarks.


SendMessage(
(HWND) hwnd,
WM_CTLCOLOR ,
(WPARAM) wParam,
(LPARAM) lParam
);

Parameters
hwnd
Handle to destination window.
wParam
Handle to a display context (DC).
lParam
Handle to a child window (control).

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

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