CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: ComboBox

  1. #1
    Join Date
    May 1999
    Posts
    42

    ComboBox

    Hi

    I'd like to set my combo to read only like you can with a CEdit ie: SetReadOnly, so far I've just used EnableWindow(false), but the text is the grey. What should I do?
    Many Thanks


  2. #2
    Join Date
    May 1999
    Location
    Antwerp, Belgium
    Posts
    136

    Re: ComboBox

    When your combobox is a DROPDOWN then you can use the solution at :
    http://www.codeguru.com/combobox/col...ed_combo.shtml


  3. #3
    Join Date
    May 1999
    Location
    Paris, France
    Posts
    216

    Re: ComboBox

    put the WM_CTLCOLOR and do something like

    COptionCalcApp::s_ReadOnlyBrush; is a Static Brush of my Application
    CBrush COptionCalcApp::s_ReadOnlyBrush (RGB (255, 255, 255));

    HBRUSH COptionView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
    {
    HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
    int iId = pWnd->GetDlgCtrlID ();

    if (iId == IDC_MYCOMBOBOX)
    {
    //pDC->SetBkColor (RGB (0, 255, 255));
    return COptionCalcApp::s_ReadOnlyBrush;
    }
    else
    return hbr;
    }





  4. #4
    Join Date
    Jun 1999
    Posts
    319

    Re: ComboBox

    Instead of the other guy adress, try this :
    Make your own class CYourComboBox derived from CCOmboBox. Set a BOOL member whitch indicates you the read-only state. Override OnChar on this function. If the bool member is TRUE just return from OnChar (don't call the base class method).
    Please let me know if this is realy make you happy!
    Best regards,
    Faby


  5. #5
    Join Date
    May 1999
    Posts
    42

    Re: ComboBox

    Thanks but I thought of that...it's a DropList


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