Print Page | Close Window

CMarkupListCtrl with checkboxes

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=15560
Printed Date: 21 June 2025 at 8:10pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CMarkupListCtrl with checkboxes
Posted By: markr
Subject: CMarkupListCtrl with checkboxes
Date 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?



Replies:
Posted By: markr
Date 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.  :-)




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net