News:

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

List View multi-color

Started by ossama, December 17, 2007, 11:10:47 AM

Previous topic - Next topic

ossama

hello  :bg
how can i make a listview (in the details view) with diffrent background colors in each line ?
ie, for example the first line has the backround color ==RED,the second line with background color ==BLUE,and so on...


the same question but columns in place of lines,

thank you in advance  :U

Jackal

this will do it but you will need to play with the hex numbers to get your colors..



    cmp uMsg, WM_NOTIFY
    jne @F
      push edi
      mov edi,lParam
      assume edi:ptr NMHDR
      mov eax,[edi].hwndFrom
      .if eax==hList   
        .if [edi].code == NM_CUSTOMDRAW
          mov ecx,edi
          ASSUME ecx:ptr NMLVCUSTOMDRAW
          .if [ecx].nmcd.dwDrawStage == CDDS_PREPAINT
            mov eax,CDRF_NOTIFYITEMDRAW
            ret
          .elseif [ecx].nmcd.dwDrawStage == CDDS_ITEMPREPAINT
            mov eax, [ecx].nmcd.dwItemSpec
            and eax, 1
            dec eax
            and eax, (00C5C5C5h - 00D6D8D3h)
            add eax, 00787878h
            mov [ecx].clrTextBk, eax
            mov eax, CDRF_NEWFONT
            ret
            ASSUME ecx:nothing
          .endif
        .endif
      .endif
      pop edi

ossama

Jackal ,thank you for the help :U

ossama

hi Jackal,
your code can change the color of items,but how to change the color of a specific column?or is it possible?

donkey

I have not looked at his code but when drawing the text into the listview you have to have the bounding rect of each column so you can paint individual backgrounds then. The attached example paints the columns separate colors when a line is selected...

Note that this is written for RadASM and in GoAsm syntax, you will need my headers to compile it, they are available from my website. Don't bother asking to translate it, I don't have MASM available nor am I likely to download it.

Donkey

[attachment deleted by admin]
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Jackal

i understood the question as being the way he gave an example of.

donkey

Quote from: Jackal on January 01, 2008, 11:54:01 PM
i understood the question as being the way he gave an example of.

Hi Jackal,

No problem with your code at all, the question wasn't clear. I just modified an old listview example I did a few years back to paint the columns separately.

Edgar
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Jupiter

EnJoy!

ragdog

hi

i have problems with draw color to my listview i uses Jackal source
can your help me please

greets
ragdog

[attachment deleted by admin]

Jackal

I dont believe you are ever getting the message CDDS_ITEMPREPAINT. It does get CDDS_PREPAINT however and works down to that point.

ragdog

   
I have been to this forum to ask for a color listview I do not in my app
I have something in the resource change?

http://www.masm32.com/board/index.php?action=dlattach;topic=7858.0;id=4151

ragdog

[attachment deleted by admin]

ossama

the code of donky shows multi colors of columns , yes , but is is colored only when selecting an item,what i need is how to show items (and sub items) with different colors always (not when selected only)
thank you

Jackal

#12
@ragdog.
  I am not sure if its something in the resource or if its something with using a dialog. I myself do not use dialogs for my windows. I use the createwindowex api.

@ossama
  Following the link that jupiter posted there is an example that shows what it is you want. If are able to translate the code then it will work fine. If not then maybe when i get the time i will sit down and do it.

ossama

QuoteIf not then maybe when i get the time i will sit down and do it
thank you for help  :U

ossama

Quote from: Jupiter on January 02, 2008, 03:24:01 PM
Article at CodeProject: Neat Stuff to Do in List Controls Using Custom Draw
yes this is what i want,i will look in the source code and try to translate what i need to masm, i will post an example in masm later,
thank you Jupiter, and Jakal and all of you who had tried to help
REGARDS OSSAMA