Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - CXTCheckListBox Horizontal Scrolling
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTCheckListBox Horizontal Scrolling

 Post Reply Post Reply
Author
Message
devam View Drop Down
Groupie
Groupie
Avatar

Joined: 20 March 2008
Location: India
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote devam Quote  Post ReplyReply Direct Link To This Post Topic: CXTCheckListBox Horizontal Scrolling
    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
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
devam View Drop Down
Groupie
Groupie
Avatar

Joined: 20 March 2008
Location: India
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote devam Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
devam View Drop Down
Groupie
Groupie
Avatar

Joined: 20 March 2008
Location: India
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote devam Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post 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
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.141 seconds.