CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 1999
    Location
    Israel
    Posts
    1,793

    Need some help with OnCtlColor please...

    yoo gurus....
    can you please help me with lil something here?
    i have dialog base app and this is my OnCtlColor class..

    HBRUSH CDlgClass::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
    {
    HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
    //pDC->SetTextColor(RGB(0,0,255));

    if(pWnd==GetDlgItem(IDC_RADIO1))
    pDC->SetTextColor(RGB(255,0,0));//this dosent work why?

    return hbr;
    }




    now i wanna set diffrent colors for some controls
    but it dosent work...
    any ideas guys??

    and my second question is how can i change the color of the conrol (radio buttons and check boxes) when the mouse is over them??
    thanks in advance
    kishk91


    [email protected]
    http://www.path.co.il
    ICQ: 13610258

  2. #2
    Join Date
    Aug 1999
    Location
    Chicago, IL
    Posts
    43

    Re: Need some help with OnCtlColor please...

    HBRUSH CCHXServerConfig::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
    {
    switch(nCtlColor)
    {
    case CTLCOLOR_LISTBOX:
    case CTLCOLOR_EDIT:
    // Set color to green on black and return the backgroundbrush.
    pDC->SetTextColor(RGB(0, 255, 0));
    pDC->SetBkColor(RGB(96, 96, 96));
    return (HBRUSH)(m_pEditBackgroundColor->GetSafeHandle());
    case CTLCOLOR_STATIC:
    pDC->SetTextColor(RGB(255, 0, 0));
    pDC->SetBkColor(RGB(192, 192, 128));
    return (HBRUSH)(m_pDialogColor->GetSafeHandle());
    case CTLCOLOR_BTN:
    pDC->SetTextColor(RGB(255, 0, 0));
    pDC->SetBkColor(RGB(192, 192, 128));
    return (HBRUSH)(m_pButtoncolor->GetSafeHandle());
    case CTLCOLOR_DLG:
    return (HBRUSH)(m_pDialogColor->GetSafeHandle());
    }

    return (HBRUSH)(m_pButtoncolor->GetSafeHandle());
    }



  3. #3
    Join Date
    Jul 1999
    Location
    Israel
    Posts
    1,793

    Re: Need some help with OnCtlColor please...

    ok.. this will change all the static control to some color and so on..
    but what if i have IDC_RADIO1 IDC_RADIO2 and IDC_RADIO3
    how do i change the color of IDC_RADIO1 only..
    ?

    [email protected]
    http://www.path.co.il
    ICQ: 13610258

  4. #4
    Guest

    Re: Need some help with OnCtlColor please...

    Sounds to me like you should do owner draw for your radio buttons. That means handling owner draw and measure item messages.


  5. #5
    Join Date
    Jul 1999
    Location
    Israel
    Posts
    1,793

    Re: Need some help with OnCtlColor please...

    ok.. but i use the dialog boxes editor...
    and in the properties of the controls i dont have
    owner draw option...
    so how do i handle this??


    [email protected]
    http://www.path.co.il
    ICQ: 13610258

  6. #6
    Join Date
    Mar 2000
    Location
    Birmingham, England
    Posts
    2,520

    Re: Need some help with OnCtlColor please...

    Hi
    I have the same problem that you had here. Did you fix it ? Can you help me?

    Jase

    <no witty trailer supplied>

    Jase

    www.slideshowdesktop.com
    View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows.
    ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured