Re: scroll-wheel problems with an owner-draw ListBox

From: me (me_at_here.com)
Date: 01/15/05


Date: Sat, 15 Jan 2005 18:14:08 +0000 (UTC)

Doug, you've diagnosed my problem exactly!

Many thanks,

Karl.

"Doug Harrison [MVP]" <dsh@mvps.org> wrote in message
news:edtgu01mefi41u9m4qf5ke0vil86ivrutq@4ax.com...
> me wrote:
>
>>Hi, i've written an owner-draw ListBox but I get some strange effects when
>>using the scroll-wheel to scroll the window.
>>
>>If I set the type to "Fixed" the scroll-wheel causes the window to scroll
>>correctly but for some reason my MeasureItem function never gets called
>>and
>>the items in the listbox are the wrong height (they just use some kind of
>>default value).
>>
>>If I set the type to "Variable" the MeasureItem function gets called for
>>every item as expected and the listbox looks correct (all items are the
>>correct height). But when I use the scroll-wheel to scroll the window it
>>always scrolls downwards one whole page before stopping at the correct
>>window position.
>>
>>A friend said that he might have seen this scroll behavior on some other
>>windows applications - is this a known problem? How come my MeasureItem
>>function doesn't get called (not even once) when the owner-draw type is
>>set
>>to "Fixed"?
>>
>>Is there a function I can call to set the "fixed" height manually?
>>
>>Any help greatly appreciated!
>
> Below are excerpts from some past messages I've written on these topics:
>
> ***** About LBS_OWNERDRAWFIXED
>
> You can set LBS_OWNERDRAWFIXED in the
> resource editor, ignore the initial WM_MEASUREITEM sent to your dialog
> box, and fix things up in OnInitDialog with CListBox::SetItemHeight.
> Windows appears to reliably provide a default height for
> WM_MEASUREITEM, but if you feel really strongly about setting it, you
> can override your dialog class's WindowProc and handle the message
> there.
>
> In my OnInitDialog handlers, I have code that sets the height using that
> SetItemHeight and follows it by a function that resizes the listbox if the
> "integral height" style is set. So I need to use two extra function calls
> to
> make LBS_OWNERDRAWFIXED work right.
>
> ***** About funky listbox animation
>
> I'd avoid LBS_OWNERDRAWVARIABLE if possible, as it suffers a weird bug in
> Win2K and XP, when "smooth scrolling of listboxes" is activated (TweakUI
> calls it "Enable list box animation"), in which rolling the wheel causes
> the listbox to visually scroll in the "opposite" direction though the
> right
> item is brought into view. A user reported this in one of my apps, and I
> cured it by switching to LBS_OWNERDRAWFIXED. See this message for another
> report by a C# user:
>
> http://groups.google.com/groups?selm=v8n7sqjq14k41a%40corp.supernews.com
>
> --
> Doug Harrison
> Microsoft MVP - Visual C++



Relevant Pages

  • Re: scroll-wheel problems with an owner-draw ListBox
    ... >every item as expected and the listbox looks correct (all items are the ... But when I use the scroll-wheel to scroll the window it ...
    (microsoft.public.vc.mfc)
  • scroll-wheel problems with an owner-draw ListBox
    ... i've written an owner-draw ListBox but I get some strange effects when ... If I set the type to "Fixed" the scroll-wheel causes the window to scroll ... If I set the type to "Variable" the MeasureItem function gets called for ...
    (microsoft.public.vc.mfc)
  • Re: Owner Draw STATIC Window with XP Themes
    ... >> created and close the handle when the window is destroyed. ... open the theme data everytime you are redrawing the window. ... open it only once (even though opening it each time seems to work just ... But I might be with Doug here. ...
    (microsoft.public.vc.mfc)
  • Re: Owner Draw STATIC Window with XP Themes
    ... >> created and close the handle when the window is destroyed. ... open the theme data everytime you are redrawing the window. ... open it only once (even though opening it each time seems to work just ... But I might be with Doug here. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: .gifs no longer animated since upgrade
    ... Also, Doug Knox's script is not for use with XP, which is my ... >> not in my browser window, ...
    (microsoft.public.windows.inetexplorer.ie6.browser)