News:

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

LVS_OWNERDRAWFIXED !!! SOS !!!

Started by xandaz, June 11, 2011, 09:47:41 AM

Previous topic - Next topic

xandaz

   Hi there. Does one need to combine LVS_REPORT with LVS_OWNERDRAWFIXED? I've tried it but it gives errors. When i don't mention the LVS_REPORT style it works but the items dont have the size that i mentioned and also it doesnt send the WM_MEASURETITEM msg. Does anyone have examples of this? thanks and bye

Custos

Hello.  Do you have any sample code you can post of what you are trying to do?  Also, when you combine both styles what kind of errors are you getting?

xandaz

   i dont understand .... i posted the example but it didn't come along. thanks

xandaz

   sorry.... i didn't post... it was in another thread. There's no problem with the styles. I was using itemData of DRARWITEMSTRUCT assuming it would be a LV_ITEM struct pointer but it wasnt and cause access violation when reading the address. But now i come across another problem. When processing the WM_DRAWITEM i use itemID as the index for the item and then fill an LV_ITEM struct in accoordance ( iItem, imask (LVIF_TEXT+LVIF_IMAGE) but only the iImage appears to be right. the pszText points to an empty string. Do you know why? Should i use LVS_OWNERDATA also and LVN_GETDISPINFO?
   I'll check by later for some answers. Bye and thanks lfor replying.
   best regards from X

Custos

OK some progress.  I got it working somewhat.  The only problem I see now is that it draws a bunch of blue boxes after the items.  Maybe you know what is wrong.  I haven't worked with the ownerdraw procedures before. 

Anyway, basically you need to set up a buffer for LVM_GETITEM.  Make sure if you declare a field in the mask that you actually initialize it with something.  If you are not going to use the field don't declare it in the mask.  What helped me was to turn off the LVS_OWNERDRAWFIXED style and see if the listview worked without processing the WM_DRAWITEM message.  Once I got that to work right I turned it back on.  I commented the changes I made to your code.

I hope this helps.  :bg

jj2007

Hi Custos,

Your code works perfectly, except that JWasm doesn't like it. ML.exe uses a simple leave before the ret, which works better. There might be a problem with the stack, though - 12 pushes but only 5 pops :wink

WndProc PROC    uses edi esi hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
LOCAL dummy  ; workaround to prevent JWasm from producing GPFs

Custos

Hey jj2007,

When you say works perfectly, do you not get the trailing blue boxes after the items in the listview?
I have to admit that I've downloaded Jwasm but have been too lazy to set up and use it yet.  I use WinAsm Studio IDE and it makes things so easy for MASM32 compiling.  I have migrated my code to the Jwasm includes though but that's as far as I've gotten.

jj2007

#7
Quote from: Custos on June 17, 2011, 07:57:09 PM
Hey jj2007,

When you say works perfectly, do you not get the trailing blue boxes after the items in the listview?
I have to admit that I've downloaded Jwasm but have been too lazy to set up and use it yet.  I use WinAsm Studio IDE and it makes things so easy for MASM32 compiling.  I have migrated my code to the Jwasm includes though but that's as far as I've gotten.

No blue boxes. The stack problem is present for Jwasm and masm - and it's massive, several hundred bytes off. - see below.

xandaz

   Well.... thanks a lot custos. How didn't i think of that? i was thinking that the system would take care of the buffer by itself. Thanks man.... very helpful.
   bye and i'll see if i can fix it. i'll post later

xandaz

   well... try this one custos. Just use -1 when drawing text. I didnt see the blue boxes, but the text extented farther than the size of the string because DrawText refered cchTextMax, and so went beyond zero. Thanks again

Custos

QuoteNo blue boxes. The stack problem is present for Jwasm and masm - and it's massive, several hundred bytes off.
Weird.  For me there were blue boxes that did extend way farther than the size of the string as xandaz said.
I'm curious, how exactly are you checking for the stack problem?  I assume you are using olly?

Glad I could help xandaz.  The latest code you posted works fine with the changes you made.  No more blue boxes for me. Hey btw, is your picture supposed to look like Frylock from ATHF?

jj2007

Quote from: Custos on June 17, 2011, 09:12:53 PM
QuoteNo blue boxes. The stack problem is present for Jwasm and masm - and it's massive, several hundred bytes off.
Weird.  For me there were blue boxes that did extend way farther than the size of the string as xandaz said.
I'm curious, how exactly are you checking for the stack problem?  I assume you are using olly?

Yes, I am using Olly. And the stack is actually off because inside WndProc calls to WndProc happen, especially for WM_NCACTIVATE - so this is actually not a bug but rather normal Windows behaviour. Sorry for the false alarm.

However, as a matter of fact JWasm does misbehave and crashes. My WndProcs always have some LOCALs, so I never stumbled over that problem before...
0040146D           ³.  5F                      pop edi
0040146E           ³.  8BE5                    mov esp, ebp  <<<<< missing if there are no local variables
00401470           ³.  5D                      pop ebp
00401471           À.  C2 1000                 retn 10


For comparison, Masm uses leave:
00401436           ³.  5F                      pop edi
00401437           ³.  C9                      leave
00401438           À.  C2 1000                 retn 10

xandaz

   i dont know who that is custos. i just made a drawing with paint to use. got tired of my own picture.

Custos

Interesting find jj2007.  Maybe someone should tell Japheth about this issue?

Xandaz, if you're curious have a look at http://aqua-teen-hunger-force.wikia.com/index.php?title=Frylock&image=AthfFrylock2-png.  Your pic kinda reminds me of him.  :toothy

jj2007

Quote from: Custos on June 17, 2011, 10:03:35 PM
Interesting find jj2007.  Maybe someone should tell Japheth about this issue?

Hi Custos,
Thanks for reporting this to Japheth. I added a comment, basically saying a pop is missing in line 157:
Quote            call    FillLV
           
POP edx      ; <<<<<<<<<<<<<<<<<< THE MISSING POP

JWasm uses pop ebp, masm uses leave before the ret. The latter tends to hide such bugs.