The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: korte on September 06, 2010, 01:04:43 PM

Title: colored listbox
Post by: korte on September 06, 2010, 01:04:43 PM

Please help

I search, colored listbox (line to line)

Title: Re: colored listbox
Post by: ecube on September 06, 2010, 02:56:34 PM
what you want to do is subclass the listbox, this example should help http://www.masm32.com/board/index.php?topic=8397.0if not google subclass listbox color or something
Title: Re: colored listbox
Post by: Tedd on September 08, 2010, 01:52:39 PM
WM_CTLCOLORLISTBOX is sent to the parent by the listbox purposely, it isn't (and doesn't require) subclassing.
However, it applies to all items.

If you want to set different colours for different items, you'll need to use owner-draw.
Title: Re: colored listbox
Post by: ToutEnMasm on September 21, 2011, 05:38:08 AM
Quote
WM_CTLCOLORLISTBOX is sent to the parent by the listbox purposely, it isn't (and doesn't require) subclassing.
However, it applies to all items.
here is a sample.
Quote
;In the window loop
.if uMsg == WM_CREATE
                    ;create the listbox
                    mov Hlistbox,eax
                    ;create a brush
      invoke CreateSolidBrush,00E1E1E1h
       mov brushListbox,eax
.elseif uMsg == WM_CTLCOLORLISTBOX
      mov eax, lParam
      .if eax == Hlistbox
         invoke SetTextColor,wParam,0h            ;text is black
         invoke SetBkColor,wParam,00E1E1E1h  ;background of text
         mov eax,brushListbox                             ;return the brush (background of listbox)
         ret
      .endif   
   .ELSEIF uMsg == WM_CLOSE ;return zero
      invoke DeleteObject,brushListbox         
      INVOKE     DestroyWindow, hwnd                      

There is also
   WM_CTLCOLORMSGBOX,WM_CTLCOLOREDIT,WM_CTLCOLORLISTBOX,WM_CTLCOLORBTN
   WM_CTLCOLORDLG,WM_CTLCOLORSCROLLBAR,WM_CTLCOLORSTATIC

Title: Re: colored listbox
Post by: Tedd on September 21, 2011, 02:06:03 PM
...one year later :eek
Title: Re: colored listbox
Post by: ToutEnMasm on September 21, 2011, 02:22:19 PM

:wink
It is something I have searched a little time and i said to me that it was not too late to do good things.
If someone can put a little code to have each lines in a different color,that will be good.I haven't find one.
 
Title: Re: colored listbox
Post by: Tedd on September 21, 2011, 02:47:20 PM
Listbox doesn't allow you to do that easily, but I posted a listview example some time ago..
With one column and no headers, it's effectively the same as a listbox.

http://www.masm32.com/board/index.php?topic=15064.msg122128#msg122128