News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

colored listbox

Started by korte, September 06, 2010, 01:04:43 PM

Previous topic - Next topic

korte


Please help

I search, colored listbox (line to line)


ecube

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

Tedd

#2
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.
No snowflake in an avalanche feels responsible.

ToutEnMasm

#3
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


Tedd

No snowflake in an avalanche feels responsible.

ToutEnMasm


: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.
 

Tedd

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
No snowflake in an avalanche feels responsible.