Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - CMarkupListCtrl with checkboxes
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CMarkupListCtrl with checkboxes

 Post Reply Post Reply
Author
Message
markr View Drop Down
Senior Member
Senior Member


Joined: 01 August 2004
Status: Offline
Points: 443
Post Options Post Options   Thanks (0) Thanks(0)   Quote markr Quote  Post ReplyReply Direct Link To This Post Topic: CMarkupListCtrl with checkboxes
    Posted: 06 November 2009 at 11:40am
Hello,

In the MarkupSample MFC sample project, there is a class called CMarkupListCtrl that is quite interesting indeed.

In an effort to add support for checkboxes, I changed the derivation of CMarkupListCtrl from CXTListBox to CXTCheckListBox. This seems to work just fine, but I can't help notice that the appearance of the checkboxes themselves are altered as a result. More specifically, the checkboxes lose their 3D appearance and become flattened (which, in turn, makes them appear larger).

Is there any way to implement checkboxes within CMarkupListCtrl without altering their standard appearance?
Back to Top
markr View Drop Down
Senior Member
Senior Member


Joined: 01 August 2004
Status: Offline
Points: 443
Post Options Post Options   Thanks (0) Thanks(0)   Quote markr Quote  Post ReplyReply Direct Link To This Post Posted: 06 November 2009 at 2:09pm
I was able to figure this out on my own.

The trick is that the Init() method within CXTCheckListBox needs to be called in order to initialize theme support.

The CMarkupListCtrl class overrides Init() and returns true, so first I tried calling Init() in the base class. This fails because eventually Init() gets called in CXTListBox (which is the base class for CXTCheckListBox), which in turn *enforces* application of the LBS_HASSTRINGS style flag. This style flag is not compatible with the way that CMarkupListCtrl is designed.

So, the solution I found is to defer the Init() call and then toggle the style back, like this:

bool CMarkupListCtrl::Init()
{
    bool bres = __super::Init();

    this->ModifyStyle(LBS_HASSTRINGS, 0, 0);

    return bres;
}

So far, this seems to be working nicely. Still testing to see if I somehow broke something else.  :-)

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.