Print Page | Close Window

CXTCheckListBox Horizontal Scrolling

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=10678
Printed Date: 18 April 2024 at 5:37am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTCheckListBox Horizontal Scrolling
Posted By: devam
Subject: CXTCheckListBox Horizontal Scrolling
Date Posted: 19 May 2008 at 6:52am
Hi,
I have used CXTCheckListBox in my project and need horizontal scrollbars in the same.
While creating the list box I have specified the WS_HSCROLL property, but that is not enough for CXTCheckListBoxes. By surfing and a little research I came up with the following code which successfully adds a Horizontal scrollbar to my CXTCheckListBox :
 
    CString cstr;
    CSize   sz;
    int     iMaxLength = 0;
    CDC*    pDC = m_UnroutedTrailsList.GetDC();
    for (int i = 0; i < m_UnroutedTrailsList.GetCount(); i++)
    {
        m_UnroutedTrailsList.GetText(i, cstr);
        sz = pDC->GetTextExtent(cstr);
        if (sz.cx > iMaxLength)
        {
            iMaxLength = sz.cx;
        }
    }
    m_UnroutedTrailsList.ReleaseDC(pDC);
    // Set the horizontal extent so every character of all strings
    // can be scrolled to.
    m_UnroutedTrailsList.SetHorizontalExtent(iMaxLength);
But the problem is that when I scroll the list box horizontally, the strings are not displayed properly. I think there is some refresh problem. The strings are incorrectly drawn (overlap) as I scroll the listbox. The strings get correctly displayed when I click on any item within the CheckListBox.
 
Can anyone please help me to fix this display problem so that the horizontal scrollbar can behave normally with a CXTCheckListBox?
 
An early response is eagerly awaited...


-------------
DC



Replies:
Posted By: mgampi
Date Posted: 19 May 2008 at 11:03am
Hi;
what about adding a OnHScroll handler and after calling the base class implementation do a simple window refresh?


-------------
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017


Posted By: devam
Date Posted: 20 May 2008 at 1:22am
Thanks for the suggestion but I tried that as well. Problem is that I have a dialog on which the CCheckListBox is a control.
So, since I do not have a wrapper class over the control, I cannot handle WM_HSCROLL message. If I do, it will get handled for the dialog class and not the control.
Is there any way in which I can handle the message while keeping the CheckListBox as a control within a dialog?


-------------
DC


Posted By: mgampi
Date Posted: 20 May 2008 at 3:03am
Hi;
You have to derive from CXTPCheckListBox class and handle WM_HSCROLL there.
Then declare a dialog member variable of type of the derived class and in DoDataExchange do a DDX_Control().
 
HTH


-------------
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017


Posted By: devam
Date Posted: 20 May 2008 at 3:11am

What you are suggesting is to create a class of my own for the control that I am using. That is the correct approach, but is not feasible for my project currently due to lack of time and resources.

I was wondering if there is any workaround through which I could properly handle the horizontal scrollbar while keeping the CXTPCheckListBox as a control within the dialog, and not creating a class for it.

Thanks a lot for the suggestion, but a little insight on this workaround, if possible, would be greatly appreciated.



-------------
DC


Posted By: mgampi
Date Posted: 20 May 2008 at 3:13am
Hi;
 
you dont have to create your own class from scratch. Only derive it to handle WM_HSCROLL. This requires about 15 minutes to be realized...


-------------
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017



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