home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / mswindo / programm / misc / 1508 < prev    next >
Encoding:
Internet Message Format  |  1992-08-26  |  2.7 KB

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