Solved

Scrolling Child Windows In Subclassed CListCtrl

Posted on 1998-04-23
4
501 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
  • 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

758 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now