rootx Posted March 11, 2017 Posted March 11, 2017 (edited) How I can also change the color of the text? Thx $hStatus = _GUICtrlStatusBar_Create($Form1) _WinAPI_SetWindowTheme($hStatus, "", "") _GUICtrlStatusBar_SetBkColor($hStatus, 0xFFFFFF) Edited March 17, 2017 by rootx
rootx Posted March 12, 2017 Author Posted March 12, 2017 (edited) Any advice is welcome. THX. Edited March 14, 2017 by rootx
KaFu Posted March 14, 2017 Posted March 14, 2017 Based on this excellent example by funkey... expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global $hGUI, $hStatus Global $aParts[3] = [75, 150, -1] $hGUI = GUICreate("StatusBar Set BkColor", 400, 300) GUIRegisterMsg($WM_DRAWITEM, "_WM_DRAWITEM") $hStatus = _GUICtrlStatusBar_Create($hGUI) GUISetState() ;~ _GUICtrlStatusBar_SetBkColor($hStatus, 0x5555DD) _GUICtrlStatusBar_SetParts($hStatus, $aParts) _GUICtrlStatusBar_SetText($hStatus, "Part 1", 0, $SBT_OWNERDRAW) _GUICtrlStatusBar_SetText($hStatus, "Part 2", 1, $SBT_OWNERDRAW) _GUICtrlStatusBar_SetText($hStatus, "Part 3", 2, $SBT_OWNERDRAW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() Func _WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $tDRAWITEMSTRUCT = DllStructCreate("uint CtlType;uint CtlID;uint itemID;uint itemAction;uint itemState;HWND hwndItem;HANDLE hDC;long rcItem[4];ULONG_PTR itemData", $lParam) Local $itemID = DllStructGetData($tDRAWITEMSTRUCT, "itemID") ;part number Local $hDC = DllStructGetData($tDRAWITEMSTRUCT, "hDC") Local $tRect = DllStructCreate("long left;long top;long right; long bottom", DllStructGetPtr($tDRAWITEMSTRUCT, "rcItem")) Local $iTop = DllStructGetData($tRect, "top") Local $iLeft = DllStructGetData($tRect, "left") Local $hBrush Switch $itemID Case 0 $hBrush = _WinAPI_CreateSolidBrush(0x0000FF) ; Backgound Color _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrush) _WinAPI_SetTextColor($hDC, 0x00FF00) ; Font Color _WinAPI_SetBkMode($hDC, $TRANSPARENT) DllStructSetData($tRect, "top", $iTop + 1) DllStructSetData($tRect, "left", $iLeft + 1) _WinAPI_DrawText($hDC, "Part 1", $tRect, $DT_LEFT) _WinAPI_DeleteObject($hBrush) Case 1 $hBrush = _WinAPI_CreateSolidBrush(0x00FF00) _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrush) _WinAPI_SetBkMode($hDC, $TRANSPARENT) DllStructSetData($tRect, "top", $iTop + 1) DllStructSetData($tRect, "left", $iLeft + 1) _WinAPI_DrawText($hDC, "Part 2", $tRect, $DT_LEFT) _WinAPI_DeleteObject($hBrush) Case 2 $hBrush = _WinAPI_CreateSolidBrush(0xABCDEF) _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrush) _WinAPI_SetBkMode($hDC, $TRANSPARENT) DllStructSetData($tRect, "top", $iTop + 1) DllStructSetData($tRect, "left", $iLeft + 1) _WinAPI_DrawText($hDC, "Part 3", $tRect, $DT_LEFT) _WinAPI_DeleteObject($hBrush) EndSwitch $tDRAWITEMSTRUCT = 0 Return $GUI_RUNDEFMSG EndFunc ;==>_WM_DRAWITEM rootx 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
rootx Posted March 14, 2017 Author Posted March 14, 2017 Thx, but I'm not sure how to implement it on my script, I populate the stausbar with a loop.. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <File.au3> #include <WinAPI.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 437, 192, 124) $hStatus = _GUICtrlStatusBar_Create($Form1) GUIRegisterMsg($WM_DRAWITEM, "_WM_DRAWITEM") _GUICtrlStatusBar_SetText($hStatus,"test",0,$SBT_OWNERDRAW) $Button1 = GUICtrlCreateButton("Button1", 176, 136, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $d = _FileListToArrayRec(@ScriptDir&"\ico","*.ico", 0,1,0,1) For $x = 1 to UBound($d) -1 ConsoleWrite($d[$x]&@CRLF) _GUICtrlStatusBar_SetText($hStatus,$x&" "&$d[$x],0,$SBT_OWNERDRAW) Next EndSwitch WEnd Func _WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $tDRAWITEMSTRUCT = DllStructCreate("uint CtlType;uint CtlID;uint itemID;uint itemAction;uint itemState;HWND hwndItem;HANDLE hDC;long rcItem[4];ULONG_PTR itemData", $lParam) Local $itemID = DllStructGetData($tDRAWITEMSTRUCT, "itemID") ;part number Local $hDC = DllStructGetData($tDRAWITEMSTRUCT, "hDC") Local $tRect = DllStructCreate("long left;long top;long right; long bottom", DllStructGetPtr($tDRAWITEMSTRUCT, "rcItem")) Local $iTop = DllStructGetData($tRect, "top") Local $iLeft = DllStructGetData($tRect, "left") Local $hBrush Switch $itemID Case 0 $hBrush = _WinAPI_CreateSolidBrush(0x0000FF) ; Backgound Color _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrush) _WinAPI_SetTextColor($hDC, 0x00FF00) ; Font Color _WinAPI_SetBkMode($hDC, $TRANSPARENT) DllStructSetData($tRect, "top", $iTop + 1) DllStructSetData($tRect, "left", $iLeft + 1) _WinAPI_DrawText($hDC, "Part 1", $tRect, $DT_LEFT) _WinAPI_DeleteObject($hBrush) EndSwitch $tDRAWITEMSTRUCT = 0 Return $GUI_RUNDEFMSG EndFunc ;==>_WM_DRAWITEM
KaFu Posted March 14, 2017 Posted March 14, 2017 expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <File.au3> #include <WinAPI.au3> #region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 437, 192, 124) $hStatus = _GUICtrlStatusBar_Create($Form1) GUIRegisterMsg($WM_DRAWITEM, "_WM_DRAWITEM") _GUICtrlStatusBar_SetText($hStatus, "test", 0, $SBT_OWNERDRAW) Global $global_StatusBar_Text = "Part 1" $Button1 = GUICtrlCreateButton("Button1", 176, 136, 75, 25) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ; $d = _FileListToArrayRec(@ScriptDir & "\ico", "*.ico", 0, 1, 0, 1) For $x = 1 To 100 ; ConsoleWrite($d[$x] & @CRLF) Sleep(20) $global_StatusBar_Text = $x _WinAPI_RedrawWindow($hStatus) ; _GUICtrlStatusBar_SetText($hStatus, $x & " " & $x, 0, $SBT_OWNERDRAW) Next EndSwitch WEnd Func _WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $tDRAWITEMSTRUCT = DllStructCreate("uint CtlType;uint CtlID;uint itemID;uint itemAction;uint itemState;HWND hwndItem;HANDLE hDC;long rcItem[4];ULONG_PTR itemData", $lParam) Local $itemID = DllStructGetData($tDRAWITEMSTRUCT, "itemID") ;part number Local $hDC = DllStructGetData($tDRAWITEMSTRUCT, "hDC") Local $tRect = DllStructCreate("long left;long top;long right; long bottom", DllStructGetPtr($tDRAWITEMSTRUCT, "rcItem")) Local $iTop = DllStructGetData($tRect, "top") Local $iLeft = DllStructGetData($tRect, "left") Local $hBrush Switch $itemID Case 0 $hBrush = _WinAPI_CreateSolidBrush(0x0000FF) ; Backgound Color _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrush) _WinAPI_SetTextColor($hDC, 0x00FF00) ; Font Color _WinAPI_SetBkMode($hDC, $TRANSPARENT) DllStructSetData($tRect, "top", $iTop + 1) DllStructSetData($tRect, "left", $iLeft + 1) _WinAPI_DrawText($hDC, $global_StatusBar_Text, $tRect, $DT_LEFT) _WinAPI_DeleteObject($hBrush) EndSwitch $tDRAWITEMSTRUCT = 0 Return $GUI_RUNDEFMSG EndFunc ;==>_WM_DRAWITEM rootx 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
rootx Posted March 14, 2017 Author Posted March 14, 2017 !!!!!! what a fool I am, THX 4your Time, THX again.
KaFu Posted March 14, 2017 Posted March 14, 2017 Oh well, it's not that you missed something obvious :), you're welcome! OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
rootx Posted March 16, 2017 Author Posted March 16, 2017 One more question please, how can I prevent this border?? expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <File.au3> #include <WinAPI.au3> #region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 437, 192, 124) GUICtrlSetDefColor(0x000000) GUICtrlSetDefBkColor(0xFF0000) $hStatus = _GUICtrlStatusBar_Create($Form1) GUIRegisterMsg($WM_DRAWITEM, "_WM_DRAWITEM") _GUICtrlStatusBar_SetText($hStatus, "test", 0, $SBT_OWNERDRAW) Global $global_StatusBar_Text = "Part 1" $Button1 = GUICtrlCreateButton("Button1", 176, 136, 75, 25) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ; $d = _FileListToArrayRec(@ScriptDir & "\ico", "*.ico", 0, 1, 0, 1) For $x = 1 To 100 ; ConsoleWrite($d[$x] & @CRLF) Sleep(20) $global_StatusBar_Text = $x _WinAPI_RedrawWindow($hStatus) ; _GUICtrlStatusBar_SetText($hStatus, $x & " " & $x, 0, $SBT_OWNERDRAW) Next EndSwitch WEnd Func _WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $tDRAWITEMSTRUCT = DllStructCreate("uint CtlType;uint CtlID;uint itemID;uint itemAction;uint itemState;HWND hwndItem;HANDLE hDC;long rcItem[4];ULONG_PTR itemData", $lParam) Local $itemID = DllStructGetData($tDRAWITEMSTRUCT, "itemID") ;part number Local $hDC = DllStructGetData($tDRAWITEMSTRUCT, "hDC") Local $tRect = DllStructCreate("long left;long top;long right; long bottom", DllStructGetPtr($tDRAWITEMSTRUCT, "rcItem")) Local $iTop = DllStructGetData($tRect, "top") Local $iLeft = DllStructGetData($tRect, "left") Local $hBrush Switch $itemID Case 0 $hBrush = _WinAPI_CreateSolidBrush(0x0000FF) ; Backgound Color _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrush) _WinAPI_SetTextColor($hDC, 0x00FF00) ; Font Color _WinAPI_SetBkMode($hDC, $TRANSPARENT) DllStructSetData($tRect, "top", $iTop + 1) DllStructSetData($tRect, "left", $iLeft + 1) _WinAPI_DrawText($hDC, $global_StatusBar_Text, $tRect, $DT_LEFT) _WinAPI_DeleteObject($hBrush) EndSwitch $tDRAWITEMSTRUCT = 0 Return $GUI_RUNDEFMSG EndFunc ;==>_WM_DRAWITEM
KaFu Posted March 16, 2017 Posted March 16, 2017 See comment "Only process the statusbar" expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <File.au3> #include <WinAPI.au3> #region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 437, 192, 124) GUICtrlSetDefColor(0x000000) GUICtrlSetDefBkColor(0xFF0000) $hStatus = _GUICtrlStatusBar_Create($Form1) GUIRegisterMsg($WM_DRAWITEM, "_WM_DRAWITEM") _GUICtrlStatusBar_SetText($hStatus, "test", 0, $SBT_OWNERDRAW) Global $global_StatusBar_Text = "Part 1" $Button1 = GUICtrlCreateButton("Button1", 176, 136, 75, 25) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ; $d = _FileListToArrayRec(@ScriptDir & "\ico", "*.ico", 0, 1, 0, 1) For $x = 1 To 100 ; ConsoleWrite($d[$x] & @CRLF) Sleep(20) $global_StatusBar_Text = $x _WinAPI_RedrawWindow($hStatus) ; _GUICtrlStatusBar_SetText($hStatus, $x & " " & $x, 0, $SBT_OWNERDRAW) Next EndSwitch WEnd Func _WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $tDRAWITEMSTRUCT = DllStructCreate("uint CtlType;uint CtlID;uint itemID;uint itemAction;uint itemState;HWND hwndItem;HANDLE hDC;long rcItem[4];ULONG_PTR itemData", $lParam) If DllStructGetData($tDRAWITEMSTRUCT, "hwndItem") <> $hStatus Then Return $GUI_RUNDEFMSG ; Only process the statusbar Local $itemID = DllStructGetData($tDRAWITEMSTRUCT, "itemID") ;part number Local $hDC = DllStructGetData($tDRAWITEMSTRUCT, "hDC") Local $tRect = DllStructCreate("long left;long top;long right; long bottom", DllStructGetPtr($tDRAWITEMSTRUCT, "rcItem")) Local $iTop = DllStructGetData($tRect, "top") Local $iLeft = DllStructGetData($tRect, "left") Local $hBrush Switch $itemID Case 0 $hBrush = _WinAPI_CreateSolidBrush(0x0000FF) ; Backgound Color _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrush) _WinAPI_SetTextColor($hDC, 0x00FF00) ; Font Color _WinAPI_SetBkMode($hDC, $TRANSPARENT) DllStructSetData($tRect, "top", $iTop + 1) DllStructSetData($tRect, "left", $iLeft + 1) _WinAPI_DrawText($hDC, $global_StatusBar_Text, $tRect, $DT_LEFT) _WinAPI_DeleteObject($hBrush) EndSwitch $tDRAWITEMSTRUCT = 0 Return $GUI_RUNDEFMSG EndFunc ;==>_WM_DRAWITEM pixelsearch and rootx 2 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
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