Hello

I'm new to masm and I want to color ListBox text.

Not the same color for all the line, sometimes in red,sometimes in blue... it depend.

I've tried
invoke SendMessage,hLst1,LVM_SETTEXTCOLOR,0,0800000h
invoke SendMessage,hLst1,LVM_SETBKCOLOR,0,0C0FFFFh
invoke SendMessage,hLst1,LB_ADDSTRING,NULL,String


But no success, the text is always black...

Could someone help me.

Thanks in advance
Posted on 2007-01-07 09:26:27 by Bros
Bros,

Not the same color for all the line, sometimes in red,sometimes in blue... it depend.



    I tried using Listboxes and found them hopeless.  I use Listviews instead.  They are much more flexible.  You have got to get hip on CUSTOMDRAW, whose structure is shown here. http://msdn2.microsoft.com/en-gb/library/ms931627.aspx .

     Here is a snippet of code I use which works fine.  Ratch

 
    .IF == NM_CUSTOMDRAW
      .IF == CDDS_PREPAINT
        MOV EAX,CDRF_NOTIFYITEMDRAW
        JMP MAINCBRET
      .ENDIF

      .IF == CDDS_ITEMPREPAINT
        .IF == 1       ;care state
           MOV ,RGB(255,255,0)   ;yellow text
           MOV ,RGB(0,0,255)   ;blue text background
        .ELSE                                                ;don't care state
           MOV ,RGB(0,0,255)     ;blue text
           MOV ,RGB(255,255,0) ;yellow text background
        .ENDIF

        MOV EAX,CDRF_NEWFONT
        JMP MAINCBRET
      .ENDIF
    .ENDIF
Posted on 2007-01-07 10:49:51 by Ratch
Its actually really easy, If someone else has already done the work for you. :)

The way i do it is to use an owner drawn listbox (fixed hieght). I use the contents of LB_ADDITEMDATA to determine the color.

Look for my torrent RSS reader on either this forum or the other place.
There I used a listbox as a switch list.
Its used to  turn rss sources on and off using green and red markers to signify the state.

(btw. on masm forum my name is still asmrixstar)
or try this http://www.asmcommunity.net/board/index.php?topic=5054.msg187420;topicseen#new
Posted on 2007-01-07 16:44:37 by Nice Eddie