![]() |
CXTCheckListBox Horizontal Scrolling |
Post Reply ![]() |
Author | |
devam ![]() Groupie ![]() ![]() Joined: 20 March 2008 Location: India Status: Offline Points: 15 |
![]() ![]() ![]() ![]() ![]() 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
|
|
![]() |
|
mgampi ![]() Senior Member ![]() ![]() Joined: 14 July 2003 Status: Offline Points: 1201 |
![]() ![]() ![]() ![]() ![]() |
Hi;
what about adding a OnHScroll handler and after calling the base class implementation do a simple window refresh?
|
|
Martin Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0 Platform: Windows 10 v 22H2 (64bit) Language: VC++ 2022 |
|
![]() |
|
devam ![]() Groupie ![]() ![]() Joined: 20 March 2008 Location: India Status: Offline Points: 15 |
![]() ![]() ![]() ![]() ![]() |
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
|
|
![]() |
|
mgampi ![]() Senior Member ![]() ![]() Joined: 14 July 2003 Status: Offline Points: 1201 |
![]() ![]() ![]() ![]() ![]() |
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 22.1.0, new Projects v 24.0.0 Platform: Windows 10 v 22H2 (64bit) Language: VC++ 2022 |
|
![]() |
|
devam ![]() Groupie ![]() ![]() Joined: 20 March 2008 Location: India Status: Offline Points: 15 |
![]() ![]() ![]() ![]() ![]() |
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
|
|
![]() |
|
mgampi ![]() Senior Member ![]() ![]() Joined: 14 July 2003 Status: Offline Points: 1201 |
![]() ![]() ![]() ![]() ![]() |
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 22.1.0, new Projects v 24.0.0 Platform: Windows 10 v 22H2 (64bit) Language: VC++ 2022 |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |