Re: scroll-wheel problems with an owner-draw ListBox
From: Doug Harrison [MVP] (dsh_at_mvps.org)
Date: 01/15/05
- Next message: Chris: "Re: Porting Problem between VC6 and VC7"
- Previous message: Stan: "RFX_Text converts empty strings to NULL when using ODBC and MFC"
- In reply to: me: "scroll-wheel problems with an owner-draw ListBox"
- Next in thread: me: "Re: scroll-wheel problems with an owner-draw ListBox"
- Reply: me: "Re: scroll-wheel problems with an owner-draw ListBox"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 14 Jan 2005 19:57:09 -0600
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++
- Next message: Chris: "Re: Porting Problem between VC6 and VC7"
- Previous message: Stan: "RFX_Text converts empty strings to NULL when using ODBC and MFC"
- In reply to: me: "scroll-wheel problems with an owner-draw ListBox"
- Next in thread: me: "Re: scroll-wheel problems with an owner-draw ListBox"
- Reply: me: "Re: scroll-wheel problems with an owner-draw ListBox"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|