Author Topic: Custom Draw ListBox... i made it work....not this time.  (Read 4308 times)

xandaz

  • Member
  • ***
  • Posts: 491
  • I luv you babe
    • My asm examples
Custom Draw ListBox... i made it work....not this time.
« on: June 07, 2012, 03:06:06 AM »
   Can someone tell me how it works for CD ListBoxes with LB_ADDSTRING? it send the WM_DRAWITEM the correct amount of times but itemData always has the same pointer. Look at the example. It made it work once but had reccour to memory allocations.

Greenhorn

  • Member
  • ***
  • Posts: 266
Re: Custom Draw ListBox... i made it work....not this time.
« Reply #1 on: June 07, 2012, 03:51:26 AM »
Hi xandaz,

you've never assigned something to the member itemData (cdlb.asm).
Try this in WM_DRAWITEM:

Code: [Select]
WndProc PROC    hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD

LOCAL szBuffer[260]:WORD

[...]
    .elseif uMsg==WM_DRAWITEM
        mov     edi,lParam
        assume  edi:PTR DRAWITEMSTRUCT               
        .if     [edi].itemAction==ODA_DRAWENTIRE
            invoke  SetTextColor,[edi].hdc,0ffh
    invoke  SendMessage, [edi].hwndItem, LB_GETTEXT, [edi].itemID, addr szBuffer
            invoke  DrawText,[edi].hdc,addr szBuffer,-1,addr [edi].rcItem,DT_LEFT
        .endif 
[...]
    .endif
    xor     eax,eax
    ret

WndProc     endp                                               


Regards
Greenhorn


« Last Edit: June 07, 2012, 04:57:23 AM by Greenhorn »

xandaz

  • Member
  • ***
  • Posts: 491
  • I luv you babe
    • My asm examples
Re: Custom Draw ListBox... i made it work....not this time.
« Reply #2 on: June 08, 2012, 11:30:00 AM »
    Thanks greenhorn.... it's just that i was presuming that by sending LB_ADDSTRING that itemData would point to it. Isn't it how it should work? Thanks

....Yeah....it works that way tho it need LBS_HASSTRINGS....thanks