Jump to content

DarkMode UDF for AutoIt's Win32GUIs


Recommended Posts

Not confusing at all. Quite enlightening for me, even as an untested concept. It makes a lot of sense comparing the notes MSDN has.
Now, setting an error of 10 to a success, ..there is a lot of code from back in the day and from many different coders. In hopes to not bring "script braking" code, it got dragged along. My 2 cents.

Thanks for posting @SmOke_N

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

..how to discern if the button class is a button a radio button or, something else.
So I shamelessly took the code from ControlViewer to use in your code.
You'd add:
ConsoleWrite(@CRLF & 'Class:' & _WinAPI_GetClassName($vCtrl) & ' Theme:' & $sThemeName & '::' & $sThemeList & @TAB & hWnd2Styles($vCtrl) )
This is just an idea. You can cook code it without the strings.

The 2 files are: GUIStyles.inc.au3

Spoiler
#include-once

Global Const $Style_Gui[32][2] = _
   [[0x80000000, 'WS_POPUP'], _
    [0x40000000, 'WS_CHILD'], _
    [0x20000000, 'WS_MINIMIZE'], _
    [0x10000000, 'WS_VISIBLE'], _
    [0x08000000, 'WS_DISABLED'], _
    [0x04000000, 'WS_CLIPSIBLINGS'], _
    [0x02000000, 'WS_CLIPCHILDREN'], _
    [0x01000000, 'WS_MAXIMIZE'], _
    [0x00CF0000, 'WS_OVERLAPPEDWINDOW'], _ ; (WS_CAPTION | WS_SYSMENU | WS_SIZEBOX | WS_MINIMIZEBOX | WS_MAXIMIZEBOX) aka 'WS_TILEDWINDOW'
    [0x00C00000, 'WS_CAPTION'], _          ; (WS_BORDER | WS_DLGFRAME)
    [0x00800000, 'WS_BORDER'], _
    [0x00400000, 'WS_DLGFRAME'], _
    [0x00200000, 'WS_VSCROLL'], _
    [0x00100000, 'WS_HSCROLL'], _
    [0x00080000, 'WS_SYSMENU'], _
    [0x00040000, 'WS_SIZEBOX'], _
    [0x00020000, '! WS_MINIMIZEBOX ! WS_GROUP'], _   ; ! GUI ! Control
    [0x00010000, '! WS_MAXIMIZEBOX ! WS_TABSTOP'], _ ; ! GUI ! Control
    [0x00002000, 'DS_CONTEXTHELP'], _
    [0x00001000, 'DS_CENTERMOUSE'], _
    [0x00000800, 'DS_CENTER'], _
    [0x00000400, 'DS_CONTROL'], _
    [0x00000200, 'DS_SETFOREGROUND'], _
    [0x00000100, 'DS_NOIDLEMSG'], _
    [0x00000080, 'DS_MODALFRAME'], _
    [0x00000040, 'DS_SETFONT'], _
    [0x00000020, 'DS_LOCALEDIT'], _
    [0x00000010, 'DS_NOFAILCREATE'], _
    [0x00000008, 'DS_FIXEDSYS'], _
    [0x00000004, 'DS_3DLOOK'], _
    [0x00000002, 'DS_SYSMODAL'], _
    [0x00000001, 'DS_ABSALIGN']]
    ;
    ; [0x80880000, 'WS_POPUPWINDOW']
    ; [0x20000000, 'WS_ICONIC']
    ; [0x00040000, 'WS_THICKFRAME']
    ;
    ; [0x00000000, 'WS_OVERLAPPED'] ; also named 'WS_TILED'


Global Const $Style_GuiExtended[21][2] = _
   [[0x08000000, 'WS_EX_NOACTIVATE'], _
    [0x02000000, 'WS_EX_COMPOSITED'], _
    [0x00400000, 'WS_EX_LAYOUTRTL'], _
    [0x00100000, '! WS_EX_NOINHERITLAYOUT ! GUI_WS_EX_PARENTDRAG'], _ ; ! GUI ! Control (label or pic, AutoIt "draggable" feature on 2 controls)
    [0x00080000, 'WS_EX_LAYERED'], _
    [0x00040000, 'WS_EX_APPWINDOW'], _
    [0x00020000, 'WS_EX_STATICEDGE'], _
    [0x00010000, 'WS_EX_CONTROLPARENT'], _ ; AutoIt adds a "draggable" feature to this GUI extended style behavior
    [0x00004000, 'WS_EX_LEFTSCROLLBAR'], _
    [0x00002000, 'WS_EX_RTLREADING'], _
    [0x00001000, 'WS_EX_RIGHT'], _
    [0x00000400, 'WS_EX_CONTEXTHELP'], _
    [0x00000200, 'WS_EX_CLIENTEDGE'], _
    [0x00000100, 'WS_EX_WINDOWEDGE'], _
    [0x00000080, 'WS_EX_TOOLWINDOW'], _
    [0x00000040, 'WS_EX_MDICHILD'], _
    [0x00000020, 'WS_EX_TRANSPARENT'], _
    [0x00000010, 'WS_EX_ACCEPTFILES'], _
    [0x00000008, 'WS_EX_TOPMOST'], _
    [0x00000004, 'WS_EX_NOPARENTNOTIFY'], _
    [0x00000001, 'WS_EX_DLGMODALFRAME']]
    ;
    ; [0x00000300, 'WS_EX_OVERLAPPEDWINDOW']
    ; [0x00000188, 'WS_EX_PALETTEWINDOW']
    ;
    ; [0x00000000, 'WS_EX_LEFT']
    ; [0x00000000, 'WS_EX_LTRREADING']
    ; [0x00000000, 'WS_EX_RIGHTSCROLLBAR']


Global Const $Style_Avi[5][2] = _
   [[0x0010, 'ACS_NONTRANSPARENT'], _
    [0x0008, 'ACS_TIMER'], _
    [0x0004, 'ACS_AUTOPLAY'], _
    [0x0002, 'ACS_TRANSPARENT'], _
    [0x0001, 'ACS_CENTER']]


Global Const $Style_Button[20][2] = _
   [[0x8000, 'BS_FLAT'], _
    [0x4000, 'BS_NOTIFY'], _
    [0x2000, 'BS_MULTILINE'], _
    [0x1000, 'BS_PUSHLIKE'], _
    [0x0C00, 'BS_VCENTER'], _
    [0x0800, 'BS_BOTTOM'], _
    [0x0400, 'BS_TOP'], _
    [0x0300, 'BS_CENTER'], _
    [0x0200, 'BS_RIGHT'], _
    [0x0100, 'BS_LEFT'], _
    [0x0080, 'BS_BITMAP'], _
    [0x0040, 'BS_ICON'], _
    [0x0020, 'BS_RIGHTBUTTON'], _
    [0x0009, 'BS_AUTORADIOBUTTON'] , _
    [0x0007, 'BS_GROUPBOX'], _
    [0x0006, 'BS_AUTO3STATE'], _
    [0x0005, 'BS_3STATE'], _
    [0x0003, 'BS_AUTOCHECKBOX'], _
    [0x0002, 'BS_CHECKBOX'], _
    [0x0001, 'BS_DEFPUSHBUTTON']]


Global Const $Style_Combo[13][2] = _
   [[0x4000, 'CBS_LOWERCASE'], _
    [0x2000, 'CBS_UPPERCASE'], _
    [0x0800, 'CBS_DISABLENOSCROLL'], _
    [0x0400, 'CBS_NOINTEGRALHEIGHT'], _
    [0x0200, 'CBS_HASSTRINGS'], _
    [0x0100, 'CBS_SORT'], _
    [0x0080, 'CBS_OEMCONVERT'], _
    [0x0040, 'CBS_AUTOHSCROLL'], _
    [0x0020, 'CBS_OWNERDRAWVARIABLE'], _
    [0x0010, 'CBS_OWNERDRAWFIXED'], _
    [0x0003, 'CBS_DROPDOWNLIST'], _
    [0x0002, 'CBS_DROPDOWN'], _
    [0x0001, 'CBS_SIMPLE']]


Global Const $Style_Common[12][2] = _ ; "for rebar controls, toolbar controls, and status windows (msdn)"
   [[0x0083, 'CCS_RIGHT'], _
    [0x0082, 'CCS_NOMOVEX'], _
    [0x0081, 'CCS_LEFT'], _
    [0x0080, 'CCS_VERT'], _
    [0x0040, 'CCS_NODIVIDER'], _
    [0x0020, 'CCS_ADJUSTABLE'], _
    [0x0010, 'CCS_NOHILITE'], _
    [0x0008, 'CCS_NOPARENTALIGN'], _
    [0x0004, 'CCS_NORESIZE'], _
    [0x0003, 'CCS_BOTTOM'], _
    [0x0002, 'CCS_NOMOVEY'], _
    [0x0001, 'CCS_TOP']]


Global Const $Style_DateTime[7][2] = _
   [[0x0020, 'DTS_RIGHTALIGN'], _
    [0x0010, 'DTS_APPCANPARSE'], _
    [0x000C, 'DTS_SHORTDATECENTURYFORMAT'], _
    [0x0009, 'DTS_TIMEFORMAT'], _
    [0x0004, 'DTS_LONGDATEFORMAT'], _
    [0x0002, 'DTS_SHOWNONE'], _
    [0x0001, 'DTS_UPDOWN']]
    ;
    ; [0x0000, 'DTS_SHORTDATEFORMAT']


Global Const $Style_Edit[13][2] = _
   [[0x2000, 'ES_NUMBER'], _
    [0x1000, 'ES_WANTRETURN'], _
    [0x0800, 'ES_READONLY'], _
    [0x0400, 'ES_OEMCONVERT'], _
    [0x0100, 'ES_NOHIDESEL'], _
    [0x0080, 'ES_AUTOHSCROLL'], _
    [0x0040, 'ES_AUTOVSCROLL'], _
    [0x0020, 'ES_PASSWORD'], _
    [0x0010, 'ES_LOWERCASE'], _
    [0x0008, 'ES_UPPERCASE'], _
    [0x0004, 'ES_MULTILINE'], _
    [0x0002, 'ES_RIGHT'], _
    [0x0001, 'ES_CENTER']]


Global Const $Style_Header[10][2] = _
   [[0x1000, 'HDS_OVERFLOW'], _
    [0x0800, 'HDS_NOSIZING'], _
    [0x0400, 'HDS_CHECKBOXES'], _
    [0x0200, 'HDS_FLAT'], _
    [0x0100, 'HDS_FILTERBAR'], _
    [0x0080, 'HDS_FULLDRAG'], _
    [0x0040, 'HDS_DRAGDROP'], _
    [0x0008, 'HDS_HIDDEN'], _
    [0x0004, 'HDS_HOTTRACK'], _
    [0x0002, 'HDS_BUTTONS']]
    ;
    ; [0x0000, '$HDS_HORZ']


Global Const $Style_ListBox[16][2] = _
   [[0x8000, 'LBS_COMBOBOX'], _
    [0x4000, 'LBS_NOSEL'], _
    [0x2000, 'LBS_NODATA'], _
    [0x1000, 'LBS_DISABLENOSCROLL'], _
    [0x0800, 'LBS_EXTENDEDSEL'], _
    [0x0400, 'LBS_WANTKEYBOARDINPUT'], _
    [0x0200, 'LBS_MULTICOLUMN'], _
    [0x0100, 'LBS_NOINTEGRALHEIGHT'], _
    [0x0080, 'LBS_USETABSTOPS'], _
    [0x0040, 'LBS_HASSTRINGS'], _
    [0x0020, 'LBS_OWNERDRAWVARIABLE'], _
    [0x0010, 'LBS_OWNERDRAWFIXED'], _
    [0x0008, 'LBS_MULTIPLESEL'], _
    [0x0004, 'LBS_NOREDRAW'], _
    [0x0002, 'LBS_SORT'], _
    [0x0001, 'LBS_NOTIFY']]
    ;
    ; [0xA00003, 'LBS_STANDARD'] ; i.e. (LBS_NOTIFY | LBS_SORT | WS_VSCROLL | WS_BORDER) help file correct, ListBoxConstants.au3 incorrect


Global Const $Style_ListView[17][2] = _
   [[0x8000, 'LVS_NOSORTHEADER'], _
    [0x4000, 'LVS_NOCOLUMNHEADER'], _
    [0x2000, 'LVS_NOSCROLL'], _
    [0x1000, 'LVS_OWNERDATA'], _
    [0x0800, 'LVS_ALIGNLEFT'], _
    [0x0400, 'LVS_OWNERDRAWFIXED'], _
    [0x0200, 'LVS_EDITLABELS'], _
    [0x0100, 'LVS_AUTOARRANGE'], _
    [0x0080, 'LVS_NOLABELWRAP'], _
    [0x0040, 'LVS_SHAREIMAGELISTS'], _
    [0x0020, 'LVS_SORTDESCENDING'], _
    [0x0010, 'LVS_SORTASCENDING'], _
    [0x0008, 'LVS_SHOWSELALWAYS'], _
    [0x0004, 'LVS_SINGLESEL'], _
    [0x0003, 'LVS_LIST'], _
    [0x0002, 'LVS_SMALLICON'], _
    [0x0001, 'LVS_REPORT']]
    ;
    ; [0x0000, 'LVS_ICON']
    ; [0x0000, 'LVS_ALIGNTOP']


Global Const $Style_ListViewExtended[20][2] = _
   [[0x00100000, 'LVS_EX_SIMPLESELECT'], _
    [0x00080000, 'LVS_EX_SNAPTOGRID'], _
    [0x00020000, 'LVS_EX_HIDELABELS'], _
    [0x00010000, 'LVS_EX_DOUBLEBUFFER'], _
    [0x00008000, 'LVS_EX_BORDERSELECT'], _
    [0x00004000, 'LVS_EX_LABELTIP'], _
    [0x00002000, 'LVS_EX_MULTIWORKAREAS'], _
    [0x00001000, 'LVS_EX_UNDERLINECOLD'], _
    [0x00000800, 'LVS_EX_UNDERLINEHOT'], _
    [0x00000400, 'LVS_EX_INFOTIP'], _
    [0x00000200, 'LVS_EX_REGIONAL'], _
    [0x00000100, 'LVS_EX_FLATSB'], _
    [0x00000080, 'LVS_EX_TWOCLICKACTIVATE'], _
    [0x00000040, 'LVS_EX_ONECLICKACTIVATE'], _
    [0x00000020, 'LVS_EX_FULLROWSELECT'], _
    [0x00000010, 'LVS_EX_HEADERDRAGDROP'], _
    [0x00000008, 'LVS_EX_TRACKSELECT'], _
    [0x00000004, 'LVS_EX_CHECKBOXES'], _
    [0x00000002, 'LVS_EX_SUBITEMIMAGES'], _
    [0x00000001, 'LVS_EX_GRIDLINES']]


Global Const $Style_MonthCal[8][2] = _
   [[0x0100, 'MCS_NOSELCHANGEONNAV'], _
    [0x0080, 'MCS_SHORTDAYSOFWEEK'], _
    [0x0040, 'MCS_NOTRAILINGDATES'], _
    [0x0010, 'MCS_NOTODAY'], _
    [0x0008, 'MCS_NOTODAYCIRCLE'], _
    [0x0004, 'MCS_WEEKNUMBERS'], _
    [0x0002, 'MCS_MULTISELECT'], _
    [0x0001, 'MCS_DAYSTATE']]


Global Const $Style_Pager[3][2] = _
   [[0x0004, 'PGS_DRAGNDROP'], _
    [0x0002, 'PGS_AUTOSCROLL'], _
    [0x0001, 'PGS_HORZ']]
    ;
    ; [0x0000, 'PGS_VERT']


Global Const $Style_Progress[4][2] = _
   [[0x0010, 'PBS_SMOOTHREVERSE'], _
    [0x0008, 'PBS_MARQUEE'], _
    [0x0004, 'PBS_VERTICAL'], _
    [0x0001, 'PBS_SMOOTH']]


Global Const $Style_Rebar[8][2] = _
   [[0x8000, 'RBS_DBLCLKTOGGLE'], _
    [0x4000, 'RBS_VERTICALGRIPPER'], _
    [0x2000, 'RBS_AUTOSIZE'], _
    [0x1000, 'RBS_REGISTERDROP'], _
    [0x0800, 'RBS_FIXEDORDER'], _
    [0x0400, 'RBS_BANDBORDERS'], _
    [0x0200, 'RBS_VARHEIGHT'], _
    [0x0100, 'RBS_TOOLTIPS']]


Global Const $Style_RichEdit[8][2] = _      ; will also use plenty (not all) of Edit styles
   [[0x01000000, 'ES_SELECTIONBAR'], _
    [0x00400000, 'ES_VERTICAL'], _          ; Asian-language support only (msdn)
    [0x00080000, 'ES_NOIME'], _             ; ditto
    [0x00040000, 'ES_SELFIME'], _           ; ditto
    [0x00008000, 'ES_SAVESEL'], _
    [0x00004000, 'ES_SUNKEN'], _
    [0x00002000, 'ES_DISABLENOSCROLL'], _   ; same value as 'ES_NUMBER' => issue ?
    [0x00000008, 'ES_NOOLEDRAGDROP']]       ; same value as 'ES_UPPERCASE' but RichRdit controls do not support 'ES_UPPERCASE' style (msdn)


Global Const $Style_Scrollbar[5][2] = _
   [[0x0010, 'SBS_SIZEGRIP'], _
    [0x0008, 'SBS_SIZEBOX'], _
    [0x0004, 'SBS_RIGHTALIGN or SBS_BOTTOMALIGN'], _ ; i.e. use SBS_RIGHTALIGN with SBS_VERT, use SBS_BOTTOMALIGN with SBS_HORZ (msdn)
    [0x0002, 'SBS_LEFTALIGN or SBS_TOPALIGN'], _     ; i.e. use SBS_LEFTALIGN  with SBS_VERT, use SBS_TOPALIGN    with SBS_HORZ (msdn)
    [0x0001, 'SBS_VERT']]
    ;
    ; [0x0000, 'SBS_HORZ']


Global Const $Style_Slider[13][2] = _ ; i.e. trackbar
   [[0x1000, 'TBS_TRANSPARENTBKGND'], _
    [0x0800, 'TBS_NOTIFYBEFOREMOVE'], _
    [0x0400, 'TBS_DOWNISLEFT'], _
    [0x0200, 'TBS_REVERSED'], _
    [0x0100, 'TBS_TOOLTIPS'], _
    [0x0080, 'TBS_NOTHUMB'], _
    [0x0040, 'TBS_FIXEDLENGTH'], _
    [0x0020, 'TBS_ENABLESELRANGE'], _
    [0x0010, 'TBS_NOTICKS'], _
    [0x0008, 'TBS_BOTH'], _
    [0x0004, 'TBS_LEFT or TBS_TOP'], _ ; i.e. TBS_LEFT tick marks when vertical slider, or TBS_TOP tick marks when horizontal slider
    [0x0002, 'TBS_VERT'], _
    [0x0001, 'TBS_AUTOTICKS']]
    ;
    ; [0x0000, 'TBS_RIGHT']
    ; [0x0000, 'TBS_BOTTOM']
    ; [0x0000, 'TBS_HORZ']


Global Const $Style_Static[18][2] = _
   [[0x1000, 'SS_SUNKEN'], _
    [0x0400, 'SS_RIGHTJUST'], _
    [0x0200, 'SS_CENTERIMAGE'], _
    [0x0100, 'SS_NOTIFY'], _
    [0x0080, 'SS_NOPREFIX'], _
    [0x0012, 'SS_ETCHEDFRAME'], _
    [0x0011, 'SS_ETCHEDVERT'], _
    [0x0010, 'SS_ETCHEDHORZ'], _
    [0x000C, 'SS_LEFTNOWORDWRAP'], _
    [0x000B, 'SS_SIMPLE'], _
    [0x0009, 'SS_WHITEFRAME'], _
    [0x0008, 'SS_GRAYFRAME'], _
    [0x0007, 'SS_BLACKFRAME'], _
    [0x0006, 'SS_WHITERECT'], _
    [0x0005, 'SS_GRAYRECT'], _
    [0x0004, 'SS_BLACKRECT'], _
    [0x0002, 'SS_RIGHT'], _
    [0x0001, 'SS_CENTER']]
    ;
    ; [0x0000, 'SS_LEFT']


Global Const $Style_StatusBar[2][2] = _
   [[0x0800, 'SBARS_TOOLTIPS'], _
    [0x0100, 'SBARS_SIZEGRIP']]
    ;
    ; [0x0800, 'SBT_TOOLTIPS']


Global Const $Style_Tab[17][2] = _
   [[0x8000, 'TCS_FOCUSNEVER'], _
    [0x4000, 'TCS_TOOLTIPS'], _
    [0x2000, 'TCS_OWNERDRAWFIXED'], _
    [0x1000, 'TCS_FOCUSONBUTTONDOWN'], _
    [0x0800, 'TCS_RAGGEDRIGHT'], _
    [0x0400, 'TCS_FIXEDWIDTH'], _
    [0x0200, 'TCS_MULTILINE'], _
    [0x0100, 'TCS_BUTTONS'], _
    [0x0080, 'TCS_VERTICAL'], _
    [0x0040, 'TCS_HOTTRACK'], _
    [0x0020, 'TCS_FORCELABELLEFT'], _
    [0x0010, 'TCS_FORCEICONLEFT'], _
    [0x0008, 'TCS_FLATBUTTONS'], _
    [0x0004, 'TCS_MULTISELECT'], _
    [0x0002, 'TCS_RIGHT'], _
    [0x0002, 'TCS_BOTTOM'], _
    [0x0001, 'TCS_SCROLLOPPOSITE']]
    ;
    ; [0x0000, 'TCS_TABS']
    ; [0x0000, 'TCS_SINGLELINE']
    ; [0x0000, 'TCS_RIGHTJUSTIFY']


Global Const $Style_Toolbar[8][2] = _
   [[0x8000, 'TBSTYLE_TRANSPARENT'], _
    [0x4000, 'TBSTYLE_REGISTERDROP'], _
    [0x2000, 'TBSTYLE_CUSTOMERASE'], _
    [0x1000, 'TBSTYLE_LIST'], _
    [0x0800, 'TBSTYLE_FLAT'], _
    [0x0400, 'TBSTYLE_ALTDRAG'], _
    [0x0200, 'TBSTYLE_WRAPABLE'], _
    [0x0100, 'TBSTYLE_TOOLTIPS']]


Global Const $Style_TreeView[16][2] = _
   [[0x8000, 'TVS_NOHSCROLL'], _
    [0x4000, 'TVS_NONEVENHEIGHT'], _
    [0x2000, 'TVS_NOSCROLL'], _
    [0x1000, 'TVS_FULLROWSELECT'], _
    [0x0800, 'TVS_INFOTIP'], _
    [0x0400, 'TVS_SINGLEEXPAND'], _
    [0x0200, 'TVS_TRACKSELECT'], _
    [0x0100, 'TVS_CHECKBOXES'], _
    [0x0080, 'TVS_NOTOOLTIPS'], _
    [0x0040, 'TVS_RTLREADING'], _
    [0x0020, 'TVS_SHOWSELALWAYS'], _
    [0x0010, 'TVS_DISABLEDRAGDROP'], _
    [0x0008, 'TVS_EDITLABELS'], _
    [0x0004, 'TVS_LINESATROOT'], _
    [0x0002, 'TVS_HASLINES'], _
    [0x0001, 'TVS_HASBUTTONS']]


Global Const $Style_UpDown[9][2] = _
   [[0x0100, 'UDS_HOTTRACK'], _
    [0x0080, 'UDS_NOTHOUSANDS'], _
    [0x0040, 'UDS_HORZ'], _
    [0x0020, 'UDS_ARROWKEYS'], _
    [0x0010, 'UDS_AUTOBUDDY'], _
    [0x0008, 'UDS_ALIGNLEFT'], _
    [0x0004, 'UDS_ALIGNRIGHT'], _
    [0x0002, 'UDS_SETBUDDYINT'], _
    [0x0001, 'UDS_WRAP']]

 

and GUIStyles.au3

Spoiler
#include-once
#include "GUIStyles.inc.au3"
#include <WindowsConstants.au3>
#include <WinAPISysWin.au3>

Func hWnd2Styles($hWnd)
    Return _GetCtrlStyleString(_WinAPI_GetWindowLong($hWnd, $GWL_STYLE), _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE), _WinAPI_GetClassName($hWnd))
EndFunc

Func _GetStyleString($iStyle, $fExStyle)
    ConsoleWrite('+ Func _GetStyleString(' & $iStyle & ', ' & $fExStyle & ')' & @CRLF)
    Local $Text = '', $Data = $fExStyle ? $Style_GuiExtended : $Style_Gui

    For $i = 0 To UBound($Data) - 1
        If BitAND($iStyle, $Data[$i][0]) = $Data[$i][0] Then
            $iStyle = BitAND($iStyle, BitNOT($Data[$i][0]))
            If StringLeft($Data[$i][1], 1) <> "!" Then
                $Text &= $Data[$i][1] & ', '
            Else
                ; ex. '! WS_MINIMIZEBOX ! WS_GROUP'  =>  'WS_MINIMIZEBOX, '
                $Text &= StringMid($Data[$i][1], 3, StringInStr($Data[$i][1], "!", 2, 2) - 4) & ', '
            EndIf
        EndIf
    Next

    If $iStyle Then $Text = '0x' & Hex($iStyle, 8) & ', ' & $Text

    Return StringRegExpReplace($Text, ',\s\z', '')
EndFunc   ;==>_GetStyleString

Func _GetCtrlStyleString($iStyle, $fExStyle, $sClass, $iLVExStyle = 0)

    If $sClass = "AutoIt v3 GUI" Or $sClass = "#32770" Or $sClass = "MDIClient" Then ; control = child GUI, dialog box (msgbox) etc...
        Return _GetStyleString($iStyle, 0)
    EndIf

    If StringLeft($sClass, 8) = "RichEdit" Then $sClass = "RichEdit" ; RichEdit, RichEdit20A, RichEdit20W, RichEdit50A, RichEdit50W

    Local $Text = ''

    _GetCtrlStyleString2($iStyle, $Text, $sClass, $iLVExStyle) ; 4th param. in case $sClass = "Ex_SysListView32" (special treatment)

    If $sClass = "ReBarWindow32" Or $sClass = "ToolbarWindow32" Or $sClass = "msctls_statusbar32" Then
        $sClass = "Common" ; "for rebar controls, toolbar controls, and status windows" (msdn)
        _GetCtrlStyleString2($iStyle, $Text, $sClass)
    ElseIf $sClass = "RichEdit" Then
        $sClass = "Edit" ; "Richedit controls also support many edit control styles (not all)" (msdn)
        _GetCtrlStyleString2($iStyle, $Text, $sClass)
    EndIf

    Local $Data = $fExStyle ? $Style_GuiExtended : $Style_Gui

    For $i = 0 To UBound($Data) - 1
        If BitAND($iStyle, $Data[$i][0]) = $Data[$i][0] Then
            If (Not BitAND($Data[$i][0], 0xFFFF)) Or ($fExStyle) Then
                $iStyle = BitAND($iStyle, BitNOT($Data[$i][0]))
                If StringLeft($Data[$i][1], 1) <> "!" Then
                    $Text &= $Data[$i][1] & ', '
                Else
                    ; ex. '! WS_MINIMIZEBOX ! WS_GROUP'  =>  'WS_GROUP, '
                    $Text &= StringMid($Data[$i][1], StringInStr($Data[$i][1], "!", 2, 2) + 2) & ', '
                EndIf
            EndIf
        EndIf
    Next

    If $iStyle Then $Text = '0x' & Hex($iStyle, 8) & ', ' & $Text

    Return StringRegExpReplace($Text, ',\s\z', '')
EndFunc   ;==>_GetCtrlStyleString

;=====================================================================
Func _GetCtrlStyleString2(ByRef $iStyle, ByRef $Text, $sClass, $iLVExStyle = 0)

    Local $Data

    Switch $sClass  ; $Input[16]
        Case "Button"
            $Data = $Style_Button
        Case "ComboBox", "ComboBoxEx32"
            $Data = $Style_Combo
        Case "Common"
            $Data = $Style_Common ; "for rebar controls, toolbar controls, and status windows (msdn)"
        Case "Edit"
            $Data = $Style_Edit
        Case "ListBox"
            $Data = $Style_ListBox
        Case "msctls_progress32"
            $Data = $Style_Progress
        Case "msctls_statusbar32"
            $Data = $Style_StatusBar
        Case "msctls_trackbar32"
            $Data = $Style_Slider
        Case "msctls_updown32"
            $Data = $Style_UpDown
        Case "ReBarWindow32"
            $Data = $Style_Rebar
        Case "RichEdit"
            $Data = $Style_RichEdit
        Case "Scrollbar"
            $Data = $Style_Scrollbar
        Case "Static"
            $Data = $Style_Static
        Case "SysAnimate32"
            $Data = $Style_Avi
        Case "SysDateTimePick32"
            $Data = $Style_DateTime
        Case "SysHeader32"
            $Data = $Style_Header
        Case "SysListView32"
            $Data = $Style_ListView
        Case "Ex_SysListView32" ; special treatment below
            $Data = $Style_ListViewExtended
        Case "SysMonthCal32"
            $Data = $Style_MonthCal
        Case "SysPager"
            $Data = $Style_Pager
        Case "SysTabControl32", "SciTeTabCtrl"
            $Data = $Style_Tab
        Case "SysTreeView32"
            $Data = $Style_TreeView
        Case "ToolbarWindow32"
            $Data = $Style_Toolbar
        Case Else
            Return
    EndSwitch

    If $sClass <> "Ex_SysListView32" Then
        For $i = 0 To UBound($Data) - 1
            If BitAND($iStyle, $Data[$i][0]) = $Data[$i][0] Then
                $iStyle = BitAND($iStyle, BitNOT($Data[$i][0]))
                $Text = $Data[$i][1] & ', ' & $Text
            EndIf
        Next
    Else
        For $i = 0 To UBound($Data) - 1
            If BitAND($iLVExStyle, $Data[$i][0]) = $Data[$i][0] Then
                $iLVExStyle = BitAND($iLVExStyle, BitNOT($Data[$i][0]))
                $Text = $Data[$i][1] & ', ' & $Text
                If BitAND($iStyle, $Data[$i][0]) = $Data[$i][0] Then
                    $iStyle = BitAND($iStyle, BitNOT($Data[$i][0]))
                EndIf
            EndIf
        Next
        If $iLVExStyle Then $Text = 'LVex: 0x' & Hex($iLVExStyle, 8) & ', ' & $Text
        ; next test bc LVS_EX_FULLROWSELECT (default AutoIt LV ext style) and WS_EX_TRANSPARENT got both same value 0x20 (hard to solve in some cases)
        If BitAND($iStyle, $WS_EX_TRANSPARENT) = $WS_EX_TRANSPARENT Then ; note that $WS_EX_TRANSPARENT has nothing to do with listview
            $iStyle = BitAND($iStyle, BitNOT($WS_EX_TRANSPARENT))
        EndIf
    EndIf
EndFunc   ;==>_GetCtrlStyleString2

 

then you'll get something like:

Class:Static Theme:::   SS_CENTER, SS_RIGHT, SS_NOTIFY, WS_CHILD, WS_VISIBLE, WS_TABSTOP
Class:Static Theme:::   SS_NOTIFY, WS_CHILD, WS_VISIBLE
Class:Button Theme:::   BS_GROUPBOX, WS_CHILD, WS_VISIBLE, WS_GROUP
Class:Button Theme:::   BS_AUTORADIOBUTTON, WS_CHILD, WS_VISIBLE, WS_TABSTOP
Class:Button Theme:::   BS_AUTORADIOBUTTON, WS_CHILD, WS_VISIBLE
Class:Button Theme:::   BS_GROUPBOX, WS_CHILD, WS_VISIBLE, WS_GROUP
Class:Static Theme:::   SS_NOTIFY, WS_CHILD, WS_VISIBLE

Hope it helps

Edited by argumentum
fixed oops

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

  • Moderators

Geeze, I don't know why I did it, but I went on a tangent with the button type while I was eating my pop-tart.

I didn't research it much or do extensive testing but it seems to work.

Func _ctrl_Button_isType($hWnd, $iStyle = Default)

    If Not IsHWnd($hWnd) Then
        $hWnd = GUICtrlGetHandle($hWnd)
    EndIf

    Local Const $BS_PUSHBUTTON = 0x0008 ; hmm, why isn't this in the constants?

    If ($iStyle == Default) Then $iStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)
    
    ; I'm probably missing some but I got lazy
    Local $iRetVal = BitAND($iStyle, BitOR( _
                                        $BS_BITMAP, _
                                        $BS_DEFPUSHBUTTON, _
                                        $BS_DEFSPLITBUTTON, _
                                        $BS_FLAT, _
                                        $BS_ICON, _
                                        $BS_NOTIFY, _
                                        $BS_OWNERDRAW, _
                                        $BS_PUSHBUTTON, _
                                        $BS_SPLITBUTTON))

    Switch $iRetVal
        Case $BS_BITMAP, $BS_DEFPUSHBUTTON, $BS_DEFSPLITBUTTON, _
                $BS_FLAT, $BS_ICON, $BS_NOTIFY, $BS_OWNERDRAW, _
                $BS_PUSHBUTTON, $BS_SPLITBUTTON
            Return SetExtended($iRetVal, "PUSHBUTTON")
    EndSwitch

    $iRetVal = BitAND($iStyle, BitOR( _
                                    $BS_3STATE, _
                                    $BS_AUTO3STATE, _
                                    $BS_AUTOCHECKBOX, _
                                    $BS_CHECKBOX))
    Switch $iRetVal
        Case $BS_3STATE, $BS_AUTO3STATE, $BS_AUTOCHECKBOX, $BS_CHECKBOX
            Return SetExtended($iRetVal, "CHECKBOX")
    EndSwitch

    $iRetVal = BitAND($iStyle, BitOR($BS_AUTORADIOBUTTON, $BS_RADIOBUTTON))
    If $iRetVal = $BS_AUTORADIOBUTTON Or $iRetVal = $BS_RADIOBUTTON Then
        Return SetExtended($iRetVal, "RADIOBUTTON")
    EndIf

    $iRetVal = BitAND($iStyle, $BS_GROUPBOX)
    If $iRetVal = $BS_GROUPBOX Then
        Return SetExtended($iRetVal, "GROUPBOX")
    EndIf

    $iRetVal = BitAND($iStyle, BitOR($BS_COMMANDLINK, $BS_DEFCOMMANDLINK))
    If $iRetVal = $BS_COMMANDLINK Or $iRetVal = $BS_DEFCOMMANDLINK Then
        Return SetExtended($iRetVal, "LINKBUTTON")
    EndIf

    Return SetError(1, $iRetVal, "")
EndFunc

 

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

17 hours ago, SmOke_N said:

Geeze, I don't know why I did it, but I went on a tangent with the button type while I was eating my pop-tart.

I didn't research it much or do extensive testing but it seems to work.

Func _ctrl_Button_isType($hWnd, $iStyle = Default)

    If Not IsHWnd($hWnd) Then
        $hWnd = GUICtrlGetHandle($hWnd)
    EndIf

    Local Const $BS_PUSHBUTTON = 0x0008 ; hmm, why isn't this in the constants?

    If ($iStyle == Default) Then $iStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)
    
    ; I'm probably missing some but I got lazy
    Local $iRetVal = BitAND($iStyle, BitOR( _
                                        $BS_BITMAP, _
                                        $BS_DEFPUSHBUTTON, _
                                        $BS_DEFSPLITBUTTON, _
                                        $BS_FLAT, _
                                        $BS_ICON, _
                                        $BS_NOTIFY, _
                                        $BS_OWNERDRAW, _
                                        $BS_PUSHBUTTON, _
                                        $BS_SPLITBUTTON))

    Switch $iRetVal
        Case $BS_BITMAP, $BS_DEFPUSHBUTTON, $BS_DEFSPLITBUTTON, _
                $BS_FLAT, $BS_ICON, $BS_NOTIFY, $BS_OWNERDRAW, _
                $BS_PUSHBUTTON, $BS_SPLITBUTTON
            Return SetExtended($iRetVal, "PUSHBUTTON")
    EndSwitch

    $iRetVal = BitAND($iStyle, BitOR( _
                                    $BS_3STATE, _
                                    $BS_AUTO3STATE, _
                                    $BS_AUTOCHECKBOX, _
                                    $BS_CHECKBOX))
    Switch $iRetVal
        Case $BS_3STATE, $BS_AUTO3STATE, $BS_AUTOCHECKBOX, $BS_CHECKBOX
            Return SetExtended($iRetVal, "CHECKBOX")
    EndSwitch

    $iRetVal = BitAND($iStyle, BitOR($BS_AUTORADIOBUTTON, $BS_RADIOBUTTON))
    If $iRetVal = $BS_AUTORADIOBUTTON Or $iRetVal = $BS_RADIOBUTTON Then
        Return SetExtended($iRetVal, "RADIOBUTTON")
    EndIf

    $iRetVal = BitAND($iStyle, $BS_GROUPBOX)
    If $iRetVal = $BS_GROUPBOX Then
        Return SetExtended($iRetVal, "GROUPBOX")
    EndIf

    $iRetVal = BitAND($iStyle, BitOR($BS_COMMANDLINK, $BS_DEFCOMMANDLINK))
    If $iRetVal = $BS_COMMANDLINK Or $iRetVal = $BS_DEFCOMMANDLINK Then
        Return SetExtended($iRetVal, "LINKBUTTON")
    EndIf

    Return SetError(1, $iRetVal, "")
EndFunc

 

Hi @SmOke_N,

is it okay if i use ur Script for the UDF?

Regards
NoNameCode

Link to comment
Share on other sites

  • Moderators

If I wrote it and posted it, it's free to use (unless there's real royalties, then thank you in advance 😂).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Little update of what im doing right now, for those who are intrested.

Im working right now on writing a DLL in C++ to hoock the OpenNcThemeData to make the change that the Folowing code in the C++ FixDarkScrollBari func dose
(https://github.com/ysc3839/win32-darkmode/blob/master/win32-darkmode/DarkMode.h)

Ill use a differen method to realise the hoockup but it will make the same changes.
 

auto MyOpenThemeData = [](HWND hWnd, LPCWSTR classList) -> HTHEME {
	if (wcscmp(classList, L"ScrollBar") == 0)
	{
		hWnd = nullptr;
		classList = L"Explorer::ScrollBar";
	}
	return _OpenNcThemeData(hWnd, classList);
};


P.s. but since I'm doing this for the first time... it takes some time and nerves :3

Edited by NoNameCode
Link to comment
Share on other sites

  • NoNameCode changed the title to DarkMode UDF for AutoIt's Win32GUIs
  • 4 weeks later...
  • 2 months later...
Posted (edited)
On 2/9/2024 at 8:12 AM, NoNameCode said:

Todos / Challenges:

* Redrawing of the Menu to Black

Nice work, all of you!

Just 1 remark: menus (i.e. GUICtrlCreateMenu) aside, you did manage to make menuitems (i.e. GUICtrlCreateMenuItem) dark, but it seems all of you used code that affects the entire operating system to get it done:

$help = GUICtrlCreateMenu("Help")
GUICtrlCreateMenuItem("Command line syntax", $help)
local $PREFERREDAPPMODE = 2 ; or 1 which is FORCEDARK VS ALLOWDARK
local $fnSetPreferredAppMode = 135
DllCall('uxtheme.dll', 'int', $fnSetPreferredAppMode, 'int', $PREFERREDAPPMODE) ; via _WinAPI_SetPreferredAppMode($fnSetPreferredAppMode)
Local $fnRefreshImmersiveColorPolicyState = 104
DllCall('uxtheme.dll', 'none', $fnRefreshImmersiveColorPolicyState) ; via _WinAPI_RefreshImmersiveColorPolicyState()

Is there a way to utilize hwnd in those DLLCall commands so they'll affect just a specific GUICreate?
And what are actually the effects on other programs and on the OS itself?

dark mode menuitem.png

Edited by LWC
Link to comment
Share on other sites

@argumentumI don't know how you can color the updown in black and also the left part of the Tab control

a coloring of the date control can be a good improvement  too.

I implement a GUISetDarkTheme($hGui) which working the same , no need to use a callback

I hope somebody can help.

image.png.1778c55a0b95e274be3407c8f1088c30.png

Link to comment
Share on other sites

4 hours ago, jpm said:

@argumentumI don't know how you can color the updown in black and also the left part of the Tab control

that file attached above has all that I scrapped from @NoNameCode's v0.02. Other than what is in that zip file, I have nothing more :( 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...