News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Custom Draw ListBox... i made it work....not this time.

Started by xandaz, June 07, 2012, 03:06:06 AM

Previous topic - Next topic

xandaz

   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

#1
Hi xandaz,

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

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


Kole Feut un Nordenwind gift en krusen Büdel un en lütten Pint.

xandaz

    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