Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem subclassing list of owner-drawn combobox

Problem subclassing list of owner-drawn combobox

Scheduled Pinned Locked Moved C / C++ / MFC
comgraphicsarchitecturehelpquestion
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Paul Vickery
    wrote on last edited by
    #1

    I have a ComboBox in which I am subclassing the list box (see my article Case-sensitive ComboBox[^]). I now have a requirement to make some of the items bold. This is easily done by using an owner-drawn combo box. However, when I subclass the list of an owner-drawn combo, the list itself becomes owner drawn. This is a problem as it means that the list would need to know about which items to bold, but the information is in the combo box (apart from the fact that it just makes the architecture messy). Has anyone come across this before? In a normal owner-drawn combo the drawing of the list items seems to be delegated to the combo, but I can't see a way of telling the subclassed list to do the same. Any ideas would be appreciated!


    "The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)

    P 1 Reply Last reply
    0
    • P Paul Vickery

      I have a ComboBox in which I am subclassing the list box (see my article Case-sensitive ComboBox[^]). I now have a requirement to make some of the items bold. This is easily done by using an owner-drawn combo box. However, when I subclass the list of an owner-drawn combo, the list itself becomes owner drawn. This is a problem as it means that the list would need to know about which items to bold, but the information is in the combo box (apart from the fact that it just makes the architecture messy). Has anyone come across this before? In a normal owner-drawn combo the drawing of the list items seems to be delegated to the combo, but I can't see a way of telling the subclassed list to do the same. Any ideas would be appreciated!


      "The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)

      P Offline
      P Offline
      Paul Vickery
      wrote on last edited by
      #2

      OK, I've sussed it. So, for everyone out there who is dying to know what the solution is, here it is: I have overridden OnChildNotify in my subclassed listbox (CListBoxCS). I have then added the following code:

      switch (message)
      {
      case WM_DRAWITEM:
      case WM_MEASUREITEM:
      case WM_COMPAREITEM:
      case WM_DELETEITEM:
      // don't allow owner-draw operations in the list, but handle them in the combo
      return FALSE;
      }
      return CListBox::OnChildNotify(message, wParam, lParam, pLResult);

      This then causes all the drawing to be handled by the combobox rather than by the subclassed listbox.


      "The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups