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. subclassed mfc control

subclassed mfc control

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialc++comhelpquestion
2 Posts 2 Posters 1 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.
  • T Offline
    T Offline
    Tym
    wrote on last edited by
    #1

    I am attempting to develop an ActiveX control subclassed from the MFC Listbox. Following the MSDN tutorial, I set everything up through the Control Wizard, including setting LISTBOX as the subclassed windows control. The problem is, the tutorials (I have read several) all say "If you want your subclassed control to keep the same appearance as the corresponding Windows control, the OnDraw member function for the control should contain only a call to the DoSuperclassPaint member function, as in the following example: void CSampleCtrl::OnDraw( CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid ) { DoSuperclassPaint( pdc, rcBounds ); } " Which is what the Control Wizard automatically does and which is how I left it. I was thinking that if I just leave it like so, when I add it to a new project, it will draw me a standard-looking listbox. Instead, I get a plain white box. I also tried calling AddString in my project and was informed by the compiler that the method does not exist. So far I see no evidence of my ActiveX control being subclassed form LISTBOX (I have the following as well provided by class wizard: BOOL CSampleCtrl::PreCreateWindow( CREATESTRUCT& cs ) { cs.lpszClass = _T("BUTTON"); return COleControl::PreCreateWindow(cs); } BOOL CSampleCtrl::IsSubclassedControl( ) { return TRUE; } ) Why am I just getting a white box?? Are there some message handlers I need to address first?? As for the AddString not working, I'm still a little rusty on subclassing... do I have to add methods for all listbox methods I want to use in my control and just call CListbox::Addstring(blah, blah, blah) in order to use the Listbox Functionality??? I have read a lot of articles and tutorials on subclassing and activex controls and mfc controls and there seems to be something that I don't know that is overlooked or assumed to be obvious. Any ideas?? Tym!

    N 1 Reply Last reply
    0
    • T Tym

      I am attempting to develop an ActiveX control subclassed from the MFC Listbox. Following the MSDN tutorial, I set everything up through the Control Wizard, including setting LISTBOX as the subclassed windows control. The problem is, the tutorials (I have read several) all say "If you want your subclassed control to keep the same appearance as the corresponding Windows control, the OnDraw member function for the control should contain only a call to the DoSuperclassPaint member function, as in the following example: void CSampleCtrl::OnDraw( CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid ) { DoSuperclassPaint( pdc, rcBounds ); } " Which is what the Control Wizard automatically does and which is how I left it. I was thinking that if I just leave it like so, when I add it to a new project, it will draw me a standard-looking listbox. Instead, I get a plain white box. I also tried calling AddString in my project and was informed by the compiler that the method does not exist. So far I see no evidence of my ActiveX control being subclassed form LISTBOX (I have the following as well provided by class wizard: BOOL CSampleCtrl::PreCreateWindow( CREATESTRUCT& cs ) { cs.lpszClass = _T("BUTTON"); return COleControl::PreCreateWindow(cs); } BOOL CSampleCtrl::IsSubclassedControl( ) { return TRUE; } ) Why am I just getting a white box?? Are there some message handlers I need to address first?? As for the AddString not working, I'm still a little rusty on subclassing... do I have to add methods for all listbox methods I want to use in my control and just call CListbox::Addstring(blah, blah, blah) in order to use the Listbox Functionality??? I have read a lot of articles and tutorials on subclassing and activex controls and mfc controls and there seems to be something that I don't know that is overlooked or assumed to be obvious. Any ideas?? Tym!

      N Offline
      N Offline
      Navin
      wrote on last edited by
      #2

      You might want to check your listbox styles. It should "Have Strings" and not be "Owner Draw". You can pick your friends, and you can pick your nose, but you can't pick your friend's nose.

      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