News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Listview grid lines color

Started by 2B||!2B, July 22, 2023, 07:18:29 AM

Previous topic - Next topic

2B||!2B

Hey there,

Is there a way to change the Windows Lisview control's grid lines color?
There doesn't seem to be any message setting this color. LVM_SETBKCOLOR only changes the background color but the grid lines still paints in white...
What options are available besides owner drawn?

jj2007

It's ownerdraw. Google "listview" "ODA_DRAWENTIRE"

NoCforMe

Assembly language programming should be fun. That's why I do it.

2B||!2B

WM_DRAWITEM won't help if you leave the default WM_PAINT as those lines are drawn after you handle WM_DRAWITEM. It's kinda flimsy design. By default, the grid lines color is a hardcoded of COLOR_BTNFACE color which maps to RGB 240 240 240 on my system. It's drawn inside uxtheme.dll if we use Common controls 6 manifest. That color is passed to an hDC by SetBkColor function. I've checked the owner drawn and it seems there is only one solution which is overriding the default painting in WM_PAINT because if you leave it to the system, it will just paint the grid lines using its own colors...

Here is a FillRect called on response to WM_DRAWITEM ODA_DRAWENTIRE
.elseif EAX == WM_DRAWITEM
MOV EDI,lParam
.if [EDI].DRAWITEMSTRUCT.itemAction == ODA_DRAWENTIRE
invoke CreateSolidBrush,10111114
invoke FillRect,[EDI].DRAWITEMSTRUCT.hdc,addr [EDI].DRAWITEMSTRUCT.rcItem,EAX

.endif

2B||!2B

Here is my attempt to draw them manually using custom draw mechanism in response to CDDS_POSTPAINT notification.

There is a problem with the paint. When you scroll vertically, lines won't draw correctly unless you minimize/restore the window. I've spent some time trying to figure out a fix for this but no go.

Any help would be appreciated.


Edit: Removed iGroupId reference.

jj2007

I'm afraid your code is not compatible with the Masm32 SDK.

Error A2063: Symbol not defined : LV_ITEMA.iGroupId

2B||!2B

Sorry, I had slightly modified LV_ITEMA/W to support for groups insertion as it's outdated but it's not necessary in this example.

LV_ITEMA STRUCT
  imask         DWORD      ?
  iItem         DWORD      ?
  iSubItem      DWORD      ?
  state         DWORD      ?
  stateMask     DWORD      ?
  pszText       DWORD      ?
  cchTextMax    DWORD      ?
  iImage        DWORD      ?
  lParam        DWORD      ?
  iIndent       DWORD      ?
  iGroupId DWORD    ?
  cColumns DWORD    ?
  puColumns     DWORD    ?
  piColFmt     DWORD    ?
  iGroup     DWORD    ?
 
LV_ITEMA ENDS

LV_ITEMW STRUCT
  imask         DWORD      ?
  iItem         DWORD      ?
  iSubItem      DWORD      ?
  state         DWORD      ?
  stateMask     DWORD      ?
  pszText       DWORD      ?
  cchTextMax    DWORD      ?
  iImage        DWORD      ?
  lParam        DWORD      ?
  iIndent       DWORD      ?
  iGroupId DWORD    ?
  cColumns DWORD    ?
  puColumns     DWORD    ?
  piColFmt     DWORD    ?
  iGroup     DWORD    ?
LV_ITEMW ENDS

zedd151

Quote from: 2B||!2B on September 08, 2023, 09:05:21 AMSorry, I had slightly modified LV_ITEMA/W to support for groups insertion as it's outdated but it's not necessary in this example.

If a new structure member is referenced in the code:
    MOV LVI.iGroupId,EAX
then the modified version of the structure should be included in the source or include file, since not everyone will have the modified version.  :smiley:

2B||!2B

Quote from: zedd151 on September 08, 2023, 09:13:00 AM
Quote from: 2B||!2B on September 08, 2023, 09:05:21 AMSorry, I had slightly modified LV_ITEMA/W to support for groups insertion as it's outdated but it's not necessary in this example.

If a new structure member is referenced in the code:
    MOV LVI.iGroupId,EAX
then the modified version of the structure should be included in the source or include file, since not everyone will have the modified version.  :smiley:


I would've included the modification had I remembered beforehand. I'll update the attached code to remove the reference.

zedd151

Quote from: 2B||!2B on September 08, 2023, 09:17:11 AMI would've included the modification had I remembered beforehand. I'll update the attached code to remove the reference.
:thumbsup:

jj2007

Quote from: 2B||!2B on September 08, 2023, 09:17:11 AMI'll update the attached code to remove the reference.

Tmp_File.asm(217) : Error A2210: Syntax error: ,
return(1)[macros.asm]

Apparently your Masm32 SDK is heavily modified. No good, especially not in The Campus.