WildByDesign Posted 18 hours ago Posted 18 hours ago In GUIDarkTheme UDF we have the following styles for toolbar controls: Global Const $__DM_g_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']] In particular, I need to detect BTNS_SEP (which is equal to TBSTYLE_SEP) so that I can handle separators, which are technically a button. But I realize that we are missing styles that can likely be added to this list. I don't fully understand all of the values so I need some help with that part. There are many updated lists on Github. For example: Link pub const TBSTYLE_BUTTON: ::DWORD = 0x0000; pub const TBSTYLE_SEP: ::DWORD = 0x0001; pub const TBSTYLE_CHECK: ::DWORD = 0x0002; pub const TBSTYLE_GROUP: ::DWORD = 0x0004; pub const TBSTYLE_CHECKGROUP: ::DWORD = TBSTYLE_GROUP | TBSTYLE_CHECK; pub const TBSTYLE_DROPDOWN: ::DWORD = 0x0008; pub const TBSTYLE_AUTOSIZE: ::DWORD = 0x0010; pub const TBSTYLE_NOPREFIX: ::DWORD = 0x0020; pub const TBSTYLE_TOOLTIPS: ::DWORD = 0x0100; pub const TBSTYLE_WRAPABLE: ::DWORD = 0x0200; pub const TBSTYLE_ALTDRAG: ::DWORD = 0x0400; pub const TBSTYLE_FLAT: ::DWORD = 0x0800; pub const TBSTYLE_LIST: ::DWORD = 0x1000; pub const TBSTYLE_CUSTOMERASE: ::DWORD = 0x2000; pub const TBSTYLE_REGISTERDROP: ::DWORD = 0x4000; pub const TBSTYLE_TRANSPARENT: ::DWORD = 0x8000; pub const TBSTYLE_EX_DRAWDDARROWS: ::DWORD = 0x00000001; pub const BTNS_BUTTON: ::DWORD = TBSTYLE_BUTTON; pub const BTNS_SEP: ::DWORD = TBSTYLE_SEP; pub const BTNS_CHECK: ::DWORD = TBSTYLE_CHECK; pub const BTNS_GROUP: ::DWORD = TBSTYLE_GROUP; pub const BTNS_CHECKGROUP: ::DWORD = TBSTYLE_CHECKGROUP; pub const BTNS_DROPDOWN: ::DWORD = TBSTYLE_DROPDOWN; pub const BTNS_AUTOSIZE: ::DWORD = TBSTYLE_AUTOSIZE; pub const BTNS_NOPREFIX: ::DWORD = TBSTYLE_NOPREFIX; pub const BTNS_SHOWTEXT: ::DWORD = 0x0040; pub const BTNS_WHOLEDROPDOWN: ::DWORD = 0x0080; Then I have to figure out how to obtain the BTNS_SEP/TBSTYLE_SEP value. My first thought is to get a count of the buttons on the toolbar and loop through the button count to check their values until we hit a separator. But I'm not even sure if there is a function to get the button count. The best starting example would be a simple toolbar example from the help files which we know contains a separator: #include <GUIConstantsEx.au3> #include <GuiToolbar.au3> #include <WinAPIConstants.au3> Example() Func Example() ; Create GUI Local $hGUI = GUICreate("Toolbar Add Bitmao (v" & @AutoItVersion & ")", 400, 300) Local $hToolbar = _GUICtrlToolbar_Create($hGUI) GUISetState(@SW_SHOW) ; Set ANSI format ;~ _GUICtrlToolbar_SetUnicodeFormat($hToolbar, False) ; Add standard system bitmaps _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR) ; Add buttons Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW) _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN) _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE) _GUICtrlToolbar_AddButtonSep($hToolbar) _GUICtrlToolbar_AddButton($hToolbar, $e_idHelp, $STD_HELP) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>Example As always, I am still learning and reading helpfile stuff as I go. So I will update or post new comments as I figure out more. Could someone please help with the list of styles? I'm not very familiar with it and don't want to do it completely wrong. Thank you.
WildByDesign Posted 17 hours ago Author Posted 17 hours ago From what I can tell, _GUICtrlToolbar_GetButtonInfo should get what I need. Now I just have to get the CommandID for the separator(s).
WildByDesign Posted 16 hours ago Author Posted 16 hours ago It looks like getting CommandID won’t be a problem since that is contained in dwItemSpec within the NMTBCUSTOMDRAW structure.
Solution WildByDesign Posted 12 hours ago Author Solution Posted 12 hours ago (edited) Adding buttons to the toolbar adds a CmdID for each button to the button index. Separators are also technically buttons, however, adding separators to the toolbar does not assign a CmdID. But separators do get added to the button index though. Therefore, I had to make my own function which assigns a CmdID to separators. Once I have a CmdID, I can then check _GUICtrlToolbar_GetButtonInfo and obtain the styles to determine whether or not the button contains $BTNS_SEP in its style. Good news? The function works and solves the issue that I was seeking with this help topic. It assigns CmdID's to separators which I can then successfully verify the styles. Bad news? Well, my larger goal of hoping that the separators having a CmdID would allow me to access them within WM_NOTIFY was not successful. Separators simply just do not go through WM_NOTIFY. I may still need to do something with those separators as a part of the theming and therefore the function might still come in handy at some point. Regardless, I might as well share that part that was successful because it was an interesting challenge: expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiToolbar.au3> #include <WinAPIConstants.au3> #include <WindowsStylesConstants.au3> Example() Func Example() Local $hGUI, $hToolbar, $aButton Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp ; Create GUI $hGUI = GUICreate("Toolbar", 400, 300) $hToolbar = _GUICtrlToolbar_Create($hGUI) GUISetState(@SW_SHOW) ; Add standard system bitmaps Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar) Case 0 _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR) Case 2 _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR) EndSwitch ; Add buttons _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW) _GUICtrlToolbar_AddButton($hToolbar, 0, 10, 0, $BTNS_SEP) ; separator, no CmdID _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN) _GUICtrlToolbar_AddButton($hToolbar, 0, 10, 0, $BTNS_SEP) ; separator, no CmdID _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE) _GUICtrlToolbar_AddButtonSep($hToolbar) ; separator, no CmdID _GUICtrlToolbar_AddButton($hToolbar, $e_idHelp, $STD_HELP) ; lets give those separators a CmdID _ToolbarSepToCmdId($hToolbar) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>Example Func _ToolbarSepToCmdId($hToolbar) Local Static $iCount = 0 Local $iCmdId, $iRet, $iStyle ; loop through potential toolbar index For $i = 0 To 100 $iCmdId = _GUICtrlToolbar_IndexToCommand($hToolbar, $i) If $iCmdId = 0 Then $iRet = _GUICtrlToolbar_SetCmdID($hToolbar, $i, 2000 + $iCount) If $iRet Then $iStyle = _GUICtrlToolbar_GetButtonInfo($hToolbar, 2000 + $iCount)[2] If BitAND($iStyle, $BTNS_SEP) Then ConsoleWrite("BTNS_SEP detected!" & @CRLF) EndIf If Not $iRet Then Return $iCount += 1 EndIf Next EndFunc ;==>_ToolbarSepToCmdId Edited 12 hours ago by WildByDesign
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now