如题
  新手,希望各位高手不吝赐教我想知道wparam中一般包含什么信息,有没有发送控件的id信息??

解决方案 »

  1.   

    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 Res.
     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). 
      

  2.   

    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;
    }我想用上述方法让窗体内的指定控件改变背景色,为什么没有反应??
      

  3.   


    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; 
      

  4.   

    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!
      

  5.   

    不好意思我忘记说了,我的edit是只读的,所以都为staic的
      

  6.   

    m_hbr是类中定义的一个刷子,已经设为黄色
      

  7.   

    TO yxz_lp
    你好,我试验成功了,请问GetDlgItem()后面的,GetsafeHwnd()有什么用出?
      

  8.   

    你要判断是哪一个控件,用pWnd参数不就可以了?
    if (pWnd->GetDlgCtrlID() == IDC_EDIT1)
      ....