wuruoyu 2 Posted February 11, 2020 (edited) Issue: Toolbar buttons cannot retain its size after switching user in Windows 10 To replicate the issue: 1. Run script 2. Switch user (Alt + F4 from Desktop) 3. Log in to the same account Thank you! expandcollapse popup#NoTrayIcon #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIToolbar.au3> #include <GUIImageList.au3> Opt("GUIOnEventMode", 1) _main() Func _main() $main = GUICreate("main", 268, 100) GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") GUISetState() $ToolbarGUI = GUICreate('', 250, 62, 1, 1, $WS_CHILD, 0, $main) $Toolbar = _GUICtrlToolbar_Create($ToolbarGUI, BitOR($BTNS_BUTTON, $BTNS_SHOWTEXT, $TBSTYLE_FLAT, $TBSTYLE_TOOLTIPS), $TBSTYLE_EX_DOUBLEBUFFER) $ToolbarImageList = _GUIImageList_Create(32, 32, 5, 3, 2) _GUIImageList_AddIcon($ToolbarImageList, "C:\Windows\System32\mmc.exe", 0, 1) _GUIImageList_AddIcon($ToolbarImageList, "C:\Windows\System32\cmd.exe", 0, 1) _GUICtrlToolbar_SetImageList($Toolbar, $ToolbarImageList) _GUICtrlToolbar_AddButton($Toolbar, 10000, 0, 0) _GUICtrlToolbar_AddButton($Toolbar, 10001, 1, 1) _GUICtrlToolbar_SetButtonSize($Toolbar, 62, 50) _GUICtrlToolbar_SetMetrics($Toolbar, 0, 0, 1, 0) _GUICtrlToolbar_SetIndent($Toolbar, 1) _SendMessage($Toolbar, $TB_AUTOSIZE) GUISwitch($main) GUICtrlCreateLabel('', 0, 63, 368, 2, $SS_ETCHEDHORZ) GUISetState(@SW_SHOWNOACTIVATE, $ToolbarGUI) GUISetState(@SW_SHOW, $main) While 1 Sleep(100) WEnd EndFunc ;==>_main Func _exit() Exit EndFunc ;==>_exit Edited February 16, 2020 by wuruoyu Share this post Link to post Share on other sites
Nine 934 Posted February 16, 2020 Sigh...It seems to be another idiosyncrasies (not to say bug) of Win 10. You will need to redraw the buttons when it is newly painted. Something like this seems to work fine : expandcollapse popup#NoTrayIcon #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIToolbar.au3> #include <GUIImageList.au3> Opt("GUIOnEventMode", 1) _main() Func _main() Global $main = GUICreate("main", 268, 100) GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") GUISetState() Global $ToolbarGUI = GUICreate('', 250, 62, 1, 1, $WS_CHILD, 0, $main) Global $Toolbar = _GUICtrlToolbar_Create($ToolbarGUI, BitOR($BTNS_BUTTON, $BTNS_SHOWTEXT, $TBSTYLE_FLAT, $TBSTYLE_TOOLTIPS), $TBSTYLE_EX_DOUBLEBUFFER) $ToolbarImageList = _GUIImageList_Create(32, 32, 5, 3, 2) _GUIImageList_AddIcon($ToolbarImageList, "C:\Windows\System32\mmc.exe", 0, 1) _GUIImageList_AddIcon($ToolbarImageList, "C:\Windows\System32\cmd.exe", 0, 1) _GUICtrlToolbar_SetImageList($Toolbar, $ToolbarImageList) _GUICtrlToolbar_AddButton($Toolbar, 10000, 0, 0) _GUICtrlToolbar_AddButton($Toolbar, 10001, 1, 1) _GUICtrlToolbar_SetButtonSize($Toolbar, 62, 50) _GUICtrlToolbar_SetMetrics($Toolbar, 0, 0, 1, 0) _GUICtrlToolbar_SetIndent($Toolbar, 1) _SendMessage($Toolbar, $TB_AUTOSIZE) GUISwitch($main) GUICtrlCreateLabel('', 0, 63, 368, 2, $SS_ETCHEDHORZ) GUISetState(@SW_SHOWNOACTIVATE, $ToolbarGUI) GUIRegisterMsg($WM_PAINT, "_WM_PAINT") GUISetState(@SW_SHOW, $main) While 1 Sleep(100) WEnd EndFunc ;==>_main Func _WM_PAINT($hWnd, $iMsg, $wParam, $lParam) If $hWnd = $ToolbarGUI Then _GUICtrlToolbar_SetButtonSize($Toolbar, 62, 50) _GUICtrlToolbar_SetMetrics($Toolbar, 0, 0, 1, 0) _GUICtrlToolbar_SetIndent($Toolbar, 1) _SendMessage($Toolbar, $TB_AUTOSIZE) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WM_PAINT Func _exit() Exit EndFunc ;==>_exit Not much of a signature, but working on it... Spoiler Block all input without UAC Save/Retrieve Images to/from Text Tool to search content in au3 files Date Range Picker Sudoku Game 2020 Overlapped Named Pipe IPC x64 Bitwise Operations Fast and simple WCD IPC GIF Animation (cached) Share this post Link to post Share on other sites
wuruoyu 2 Posted February 16, 2020 Works like a charm! Thanks @Nine! 😊 Share this post Link to post Share on other sites