home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!lax.pe-nelson.com!lax!twbrown
- From: twbrown@PE-Nelson.COM (Tom W. Brown)
- Newsgroups: comp.os.ms-windows.programmer.misc
- Subject: Re: OwnerDraw ListBoxes - Misc.
- Message-ID: <597@lax.lax.pe-nelson.com>
- Date: 25 Aug 92 18:51:35 GMT
- References: <1992Aug24.221410.10712@ods.com>
- Sender: news@lax.pe-nelson.com
- Organization: PE-Nelson
- Lines: 55
-
- In article <1992Aug24.221410.10712@ods.com>, scott@ods.com (Scott Harper) writes:
- |> I have some questions relating to OWNERDRAW list boxes. I'm using
- |> MSC 6.0 with SDK 3.1. My list box is created (via CreateWindow) with
- |> the following style:
- |>
- |> WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL |
- |> LBS_OWNERDRAWFIXED | LBS_NOINTEGRALHEIGHT |
- |> LBS_WANTKEYBOARDINPUT | LBS_NOTIFY
- |>
- |> 1. It appears that whenever I send a LB_ADDSTRING (or LB_INSERTSTRING)
- |> the entire background of the list box is getting erased prior to
- |> the WM_DRAWITEM for the new item. The effect of this is that I actually
- |> get (at least) one WM_DRAWITEM for each item in the list box, not just
- |> the new one. This results in a very noticeable flicker, especially as
- |> the list gets longer. How can I prevent this?
-
- Before adding all the items to your listbox send the following message:
-
- SendDlgItemMessage(hDlg, IDLIST, WM_SETREDRAW, 0, 0L);
-
- This tells the control not to redraw itself, ever, when other messages
- are received that would affect the display. After you have added the
- items you need to then do this:
-
- SendDlgItemMessage(hDlg, IDLIST, WM_SETREDRAW, 1, 0L);
- InvalidateRect(GetDlgItem(hDlg, IDLIST), NULL, TRUE);
-
- This is pretty standard when filling a listbox in a loop. If you still
- get the flicker, try changing the last parameter to InvalidateRect to
- FALSE (don't erase the background). This may do unwanted things if your
- routine to draw an item works in "transparent" mode.
-
-
- |>
- |> 2. WM_VKEYTOITEM vs WM_CHARTOITEM question
-
- Curious, I have a couple of listboxes where I do the same thing and everything
- appears to function as described in the reference -- I use LBS_HASSTRINGS
- because I want the VKEYTOITEM message. If you're getting a message you can
- use I'd say you're OK and there's probably no reason to worry.
-
- |>
- |> 3. Can anyone give me a quick and sure way to force the list box to be
- |> scrolled to the bottom?
-
- See the LB_SETTOPINDEX message.
-
-
-
- ----------------------------------------------------------------------------
- Tom Brown | "Strange women, lying in ponds, distributing
- PE Nelson Systems | swords is no basis for a system of government."
- twbrown@pe-nelson.com | Monty Python and the Holy Grail
- ----------------------------------------------------------------------------
-
-