How to know a Control Style code?; ListView background transparency new solution?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Renets
Posts: 36
Joined: 12 Jul 2018, 13:11

How to know a Control Style code?; ListView background transparency new solution?

26 Aug 2019, 18:15

So, after days researching how to make a ListView background transparent and no solution, I decided to use a Function from Lexicos to set a custom background (a not so flexible workaround because for my needs it's better to have a transparent ListView background) posted here:

https://autohotkey.com/board/topic/20588-adding-pictures-to-controls-eg-as-background/#entry135386

Everything works OK, but, I was re-reading ListView documentation and in the ExtendedStyle section they reference this page (A Microsoft documentation for ListView Styles). It turns out that from Windows Vista there is a ListView Extended Style called

LVS_EX_TRANSPARENTBKGND

Which seems to be an excellent solution for the ListView transparency. The problem is that I am searching everywhere and not able to find the code for that (the code set in AHK like 0x2000, LV0x10000, etc, which I am guessing that code is a code retrieved by some Windows OS documentation or so), and I am not even sure if that is called purely "code", it is a "hexidecimal code", "id code", "style code"?

So with any of this you can help me with:

1. How is that "code" exactly named (hex code? style code?, etc)
2. Where can I find/retrieve any of those "style codes" to use in AHK?
3. Where can I find/retrieve the code for LVS_EX_TRANSPARENTBKGND to use in AHK?

Thanks for your attention
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: How to know a Control Style code?; ListView background transparency new solution?

26 Aug 2019, 19:07

LVS_EX_TRANSPARENTBKGND := 0x400000

It's an extended window style, notice the 'EX'. The value is stated in hex (hexadecimal).
You commonly apply window styles/extended window styles to windows/controls.
AHK v2 has WinGetStyle/WinGetExStyle and ControlGetStyle/ControlGetExStyle, and Set equivalents.
AHK v1 has WinGet/ControlGet (with Style/ExStyle subcommands), and Set equivalents.

A search for: MSDN LVS_EX_TRANSPARENTBKGND, took me here:
Extended List-View Styles - Windows applications | Microsoft Docs
https://docs.microsoft.com/en-us/windows/win32/controls/extended-list-view-styles
The MSDN website is usually the best source for Windows API information.
(Hmm is it called MSDN any more? I search for MSDN anyhow.)

I found it here:
C:\Program Files (x86)\Windows Kits\8.1\Include\um\CommCtrl.h

The files were obtained after I installed the approx. 7 gig Visual Studio Express for Windows Desktop.
When I want to know the value for a constant, I look in .h files (header files) in this folder or a similar folder:
C:\Program Files (x86)\Windows Kits\8.1
The 8.1 indicates Windows 8.1.

Here are some other constants listed in CommCtrl.h:

Code: Select all

#define LVS_EX_GRIDLINES        0x00000001
#define LVS_EX_SUBITEMIMAGES    0x00000002
#define LVS_EX_CHECKBOXES       0x00000004
#define LVS_EX_TRACKSELECT      0x00000008
#define LVS_EX_HEADERDRAGDROP   0x00000010
#define LVS_EX_FULLROWSELECT    0x00000020 // applies to report mode only
#define LVS_EX_ONECLICKACTIVATE 0x00000040
#define LVS_EX_TWOCLICKACTIVATE 0x00000080
#define LVS_EX_FLATSB           0x00000100
#define LVS_EX_REGIONAL         0x00000200
#define LVS_EX_INFOTIP          0x00000400 // listview does InfoTips for you
#define LVS_EX_UNDERLINEHOT     0x00000800
#define LVS_EX_UNDERLINECOLD    0x00001000
#define LVS_EX_MULTIWORKAREAS   0x00002000
#define LVS_EX_LABELTIP         0x00004000 // listview unfolds partly hidden labels if it does not have infotip text
#define LVS_EX_BORDERSELECT     0x00008000 // border selection style instead of highlight
#if (NTDDI_VERSION >= NTDDI_WINXP)
#define LVS_EX_DOUBLEBUFFER     0x00010000
#define LVS_EX_HIDELABELS       0x00020000
#define LVS_EX_SINGLEROW        0x00040000
#define LVS_EX_SNAPTOGRID       0x00080000  // Icons automatically snap to grid.
#define LVS_EX_SIMPLESELECT     0x00100000  // Also changes overlay rendering to top right for icon mode.
#endif
#if (NTDDI_VERSION >= NTDDI_VISTA)
#define LVS_EX_JUSTIFYCOLUMNS   0x00200000  // Icons are lined up in columns that use up the whole view area.
#define LVS_EX_TRANSPARENTBKGND 0x00400000  // Background is painted by the parent via WM_PRINTCLIENT
#define LVS_EX_TRANSPARENTSHADOWTEXT 0x00800000  // Enable shadow text on transparent backgrounds only (useful with bitmaps)
#define LVS_EX_AUTOAUTOARRANGE  0x01000000  // Icons automatically arrange if no icon positions have been set
#define LVS_EX_HEADERINALLVIEWS 0x02000000  // Display column header in all view modes
#define LVS_EX_AUTOCHECKSELECT  0x08000000
#define LVS_EX_AUTOSIZECOLUMNS  0x10000000
#define LVS_EX_COLUMNSNAPPOINTS 0x40000000
#define LVS_EX_COLUMNOVERFLOW   0x80000000
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Renets
Posts: 36
Joined: 12 Jul 2018, 13:11

Re: How to know a Control Style code?; ListView background transparency new solution?

26 Aug 2019, 19:55

jeeswg wrote:
26 Aug 2019, 19:07
I found it here:
C:\Program Files (x86)\Windows Kits\8.1\Include\um\CommCtrl.h

The files were obtained after I installed the approx. 7 gig Visual Studio Express for Windows Desktop.
When I want to know the value for a constant, I look in .h files (header files) in this folder or a similar folder:
C:\Program Files (x86)\Windows Kits\8.1
The 8.1 indicates Windows 8.1.
Wooow I really appreciate your big help there, really!

Ok so after 5 mins you posted I was trying to apply that ExtendedStyle to the ListView (I am using AHK v1) using Control with ExStyle with different implementations of the code

A. First, I am not even able to change a common style using Control, Am I missing something? (I commented out all my tries).
Then I added it right in the "Add, ListView" line and it worked (see B.) (Maybe we can skip this part to focus on the background image)

Code: Select all

Gui, Color, Yellow
Gui, Add, ListView, w50 h100 vMyListView , Header

; Control, Style, ^0x400000, MyListView, Test-LV ; Not working 
; Control, Style, +0x400000, MyListView, Test-LV ; Not working 
; Control, ExStyle, -0x400000, MyListView, Test-LV ; Not working 
; Control, ExStyle, +0x400000, MyListView, Test-LV ; Not working 
; Control, ExStyle, ^0x400000, MyListView ; Not working 
; Control, Style, -hdr, MyListView ; or -Hdr to hide headers ; Not working 

Gui, Add, ListView, w50 h100 vMyListView LV0x400000, Header ; This does work only for Color in Background, not for an image

Gui, Show,, Test-LV
B. Now my problem is that I am using a custom background image and this method (LV0x400000) just don't work over an image :cry: , Maybe I am missing something?

Code: Select all

Gui, Add, Picture, w410 h540 +0x4000000, C:\App\images\bg.png ; Custom background image

Gui, Add, ListView, x10 y10 w50 h100 vMyListView LV0x400000, Header ; Not working, default greyish background color

Gui, Show,, Test-LV
Renets
Posts: 36
Joined: 12 Jul 2018, 13:11

Re: How to know a Control Style code?; ListView background transparency new solution?

26 Aug 2019, 20:10

teadrinker wrote:
26 Aug 2019, 19:32
https www.google.com /search?q=LVS_EX_TRANSPARENTBKGND+constant Broken Link for safety
Hey great insight thanks!
Ohhhh ook so those are called "Constants"

So apparently just Me had already a file with all of those constants in GitHub, here:
gist.github.com/AHK-just-me/6098109

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 341 guests