├── .github └── FUNDING.yml ├── DarkListView.ahk ├── LICENSE └── README.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 12 | polar: # Replace with a single Polar username 13 | buy_me_a_coffee: nklprvcp 14 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 15 | -------------------------------------------------------------------------------- /DarkListView.ahk: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * @description Apply dark theme to the ListView control. Note: This script requires AutoHotkey version 2.1-alpha.10 or later. 3 | * @file DarkListView.ahk 4 | * @author Nikola Perovic 5 | * @see https://github.com/nperovic/DarkThemeListView 6 | * @date 13 MAY 2024 7 | * @version 1.0.1 8 | ***********************************************************************/ 9 | 10 | #requires AutoHotkey v2.1-alpha.10 11 | 12 | class RECT { 13 | left: i32, top: i32, right: i32, bottom: i32 14 | } 15 | 16 | class NMHDR { 17 | hwndFrom: uptr 18 | idFrom : uptr 19 | code : i32 20 | } 21 | 22 | class NMCUSTOMDRAW { 23 | hdr : NMHDR 24 | dwDrawStage: u32 25 | hdc : uptr 26 | rc : RECT 27 | dwItemSpec : uptr 28 | uItemState : u32 29 | lItemlParam: iptr 30 | } 31 | 32 | /** 33 | * Apply a dark theme to the ListView control. 34 | * @example 35 | * myGui := Gui() 36 | * lv := myGui.AddListView("Count100 R10 W400 cWhite Background" (myGui.BackColor := 0x202020), ["Select", "Number", "Description"]) 37 | * lv.SetDarkMode() 38 | */ 39 | class _DarkListView extends Gui.ListView 40 | { 41 | static __New() 42 | { 43 | static LVM_GETHEADER := 0x101F 44 | 45 | super.Prototype.GetHeader := SendMessage.Bind(LVM_GETHEADER, 0, 0) 46 | super.Prototype.SetDarkMode := this.SetDarkMode.Bind(this) 47 | } 48 | 49 | /** 50 | * @param {Gui.ListView} lv "This" object. 51 | */ 52 | static SetDarkMode(lv, style := "Explorer") 53 | { 54 | static LVS_EX_DOUBLEBUFFER := 0x10000 55 | static NM_CUSTOMDRAW := -12 56 | static UIS_SET := 1 57 | static UISF_HIDEFOCUS := 0x1 58 | static WM_CHANGEUISTATE := 0x0127 59 | static WM_NOTIFY := 0x4E 60 | static WM_THEMECHANGED := 0x031A 61 | 62 | lv.Header := lv.GetHeader() 63 | 64 | ; Prevent the ListView control from displaying vertical grid line and other rendering issues. 65 | lv.OnMessage(WM_THEMECHANGED, (*) => 0) 66 | 67 | ; Set Header texts color 68 | lv.OnMessage(WM_NOTIFY, (lv, wParam, lParam, Msg) { 69 | static CDDS_ITEMPREPAINT := 0x10001 70 | static CDDS_PREPAINT := 0x1 71 | static CDRF_DODEFAULT := 0x0 72 | static CDRF_NOTIFYITEMDRAW := 0x20 73 | 74 | if (StructFromPtr(NMHDR, lParam).Code != NM_CUSTOMDRAW) 75 | return 76 | 77 | nmcd := StructFromPtr(NMCUSTOMDRAW, lParam) 78 | 79 | if (nmcd.hdr.hWndFrom != lv.Header) 80 | return 81 | 82 | switch nmcd.dwDrawStage { 83 | case CDDS_PREPAINT : return CDRF_NOTIFYITEMDRAW 84 | case CDDS_ITEMPREPAINT: SetTextColor(nmcd.hdc, 0xFFFFFF) 85 | } 86 | 87 | return CDRF_DODEFAULT 88 | }) 89 | 90 | lv.Opt("+LV" LVS_EX_DOUBLEBUFFER) 91 | 92 | ; Hide focus dots 93 | SendMessage(WM_CHANGEUISTATE, (UIS_SET << 8) | UISF_HIDEFOCUS, 0, lv) 94 | 95 | SetWindowTheme(lv.Header, "DarkMode_ItemsView") 96 | SetWindowTheme(lv.Hwnd, "DarkMode_" style) 97 | 98 | ;;{ WINAPI 99 | SetTextColor(hdc, color) => DllCall("SetTextColor", "Ptr", hdc, "UInt", color) 100 | 101 | SetWindowTheme(hwnd, appName, subIdList?) => DllCall("uxtheme\SetWindowTheme", "ptr", hwnd, "ptr", StrPtr(appName), "ptr", subIdList ?? 0) 102 | ;;} 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Nikola 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DarkThemeListView 2 | An AutoHotkey script that applies a dark theme to the `ListView` control. This script is compatible with AutoHotkey v2.1-alpha.9 or later. 3 | 4 | ## Features 5 | - Applies a dark theme to the ListView control. 6 | - Compatible with [AutoHotkey v2.1-alpha.9](https://github.com/AutoHotkey/AutoHotkeyDocs/tree/alpha) or later. 7 | - Learn more about the ahk v2.1-alpha: [Click here](https://github.com/AutoHotkey/AutoHotkeyDocs/tree/alpha) 8 | 9 | ![UIAViewer.ahk applied dark theme](https://github.com/nperovic/DarkThemeListView/assets/122501303/6f84f932-ca64-45d7-853c-939e33b8fea5) 10 | 11 | 12 | ## Usage 13 | 1. Download the [DarkListView.ahk](DarkListView.ahk) file. 14 | 2. Include the [DarkListView.ahk](DarkListView.ahk) file in your script. 15 | 3. Implement dark theme by using the `SetDarkMode` method. 16 | 17 | ## Example 18 | ```HS 19 | #requires AutoHotkey v2.1-alpha.9 20 | #include 21 | 22 | myGui := Gui(, "My ListView"), myGui.BackColor := 0x202020 23 | lv := myGui.AddListView("Count100 LV0x8000 R10 W400 cWhite Background" myGui.BackColor, ["Select", "Number", "Description"]) 24 | lv.SetDarkMode() 25 | ``` 26 | 27 | ## License 28 | This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details. 29 | 30 | --------------------------------------------------------------------------------