Solved

Scrolling Child Windows In Subclassed CListCtrl

Posted on 1998-04-23
4
565 Views
Last Modified: 2013-11-19
I want to use a CListCtrl in Report View to display audio items in column one and their respective volumes as horizontal sliders in column two.  So I subclassed a CListCtrl and called it CSliderListCtrl.  I have overridden the InsertItem() method which calls CListCtrl::InsertItem() and then goes on to create a CSliderCtrl and displays it in the RECT beside the newly inserted list item, i.e. in column two.  But when the list needs to scroll, I have to explicitly call MoveWindow() for every slider in (and out of) view to get them to cleanly scroll alongside their correspondng list items.  If each slider is a child window of my derived list control, why won't Windows do the scrolling and redrawing for me?  My solution is a very clunky one and looks a bit sad on slower displays.  Is there an alternative way?  Maybe owner-drawn items?
0
Comment
Question by:sdynan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1301675
Owner drawn items needs the latest IE4 COMCTL32, and are not directly supported by MFC (yet).

You could try using 'icons' on each line that show your volume level .. the selection of which icon to disaply for each line can be done with a callback, so you could have a set of bar pictures in an image list, with one picture for each number of bars (eg. no bars, on bar, two bar etc).

Then the callback for the icon to use would select the approriate icon based on the volume level

0
 

Author Comment

by:sdynan
ID: 1301676
Well, my *real* question was why Windows doesn't correctly scroll my sliders when the list control scrolls.  Each slider has its own unique control ID and is a child window of the list control.  Windows makes an attempt to move the bitmap images of the sliders, so it initially looks like it almost works, but forcing a redraw of the list control reveals the sliders in their original positions.  It's almost like each slider needs to be a child window of a list ITEM rather than the list control itself.
0
 
LVL 10

Accepted Solution

by:
RONSLOW earned 50 total points
ID: 1301677
That is not how scrollbars work.  The scrollbar sends scroll info to the window (the list view) and the window repaints itself accordingly.  It doesn't even necessarily have to scroll - it can just repaint with the new info - it all depends on how the window responds to the messages.

For example, If you look at the code for CScrollView, it 'manually' scrolls all the child windows.

You have to scroll yourself.

But you might like to SetRedraw(false) before andSetRedraw(true);Invalidate() afterward to avoid flicker.

0
 

Author Comment

by:sdynan
ID: 1301678
Thanks.  That was what I was afraid of.

Sean.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question