LerN Posted May 20, 2017 Posted May 20, 2017 Hi, i wish if everybody is having a good day ... is there any way to change the color of the tab that in the pic below ?Pic
Subz Posted May 20, 2017 Posted May 20, 2017 Unfortunately you require a workaround to get it to work, a nice workaround from Yashied post below nb: Since AutoIt has updated since Yashied posted this, I have added the latest includes in the code below. expandcollapse popup#Include <Constants.au3> #Include <GUITab.au3> #include <WinAPI.au3> #include <WinAPITheme.au3> #include <WindowsConstants.au3> #include <WinAPIGdi.au3> Opt('MustDeclareVars', 1) Global Const $PRF_CLIENT = 0x04 Global $hTab, $hDll, $pDll, $hProc GUICreate('MyGUI', 300, 300) GUISetBkColor(0xAACCFF) GUICtrlCreateTab(20, 20, 262, 261, $TCS_FOCUSONBUTTONDOWN) $hTab = GUICtrlGetHandle(-1) GUICtrlCreateTabItem('Tab 1') GUICtrlCreateTabItem('Tab 2') GUICtrlCreateTabItem('Tab 3') GUICtrlCreateTabItem('') $hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam') $pDll = DllCallbackGetPtr($hDll) $hProc = _WinAPI_SetWindowLong($hTab, $GWL_WNDPROC, $pDll) OnAutoItExitRegister('AutoItExit') GUISetState() Do Until GUIGetMsg() = -3 Func _CreateClipRgn($hWnd) Local $tRect Local $Count = _GUICtrlTab_GetItemCount($hWnd) Local $Sel = _GUICtrlTab_GetCurSel($hWnd) Local $hRgn = _WinAPI_CreateRectRgn(0, 0, 0, 0) Local $hTmp, $Ht For $i = 0 To $Count - 1 $tRect = _GUICtrlTab_GetItemRectEx($hWnd, $i) If $i = $Sel Then $hTmp = _WinAPI_CreateRectRgn(DllStructGetData($tRect, 1) - 2, DllStructGetData($tRect, 2) - 2, DllStructGetData($tRect, 3) + 2, DllStructGetData($tRect, 4)) $Ht = DllStructGetData($tRect, 4) - DllStructGetData($tRect, 2) + 2 Else If $i = $Count - 1 Then $hTmp = _WinAPI_CreateRectRgn(DllStructGetData($tRect, 1), DllStructGetData($tRect, 2), DllStructGetData($tRect, 3) - 2, DllStructGetData($tRect, 4)) Else $hTmp = _WinAPI_CreateRectRgn(DllStructGetData($tRect, 1), DllStructGetData($tRect, 2), DllStructGetData($tRect, 3), DllStructGetData($tRect, 4)) EndIf EndIf _WinAPI_CombineRgn($hRgn, $hRgn, $hTmp, $RGN_OR) _WinAPI_DeleteObject($hTmp) Next $tRect = _WinAPI_GetClientRect($hWnd) $hTmp = _WinAPI_CreateRectRgn(DllStructGetData($tRect, 1), DllStructGetData($tRect, 2) + $Ht, DllStructGetData($tRect, 3) - 2, DllStructGetData($tRect, 4) - 1) _WinAPI_CombineRgn($hRgn, $hRgn, $hTmp, $RGN_OR) _WinAPI_DeleteObject($hTmp) Return $hRgn EndFunc ;==>_CreateClipRgn Func _WinProc($hWnd, $iMsg, $wParam, $lParam) If _WinAPI_IsThemeActive() Then Switch $iMsg Case $WM_ERASEBKGND Local $hRgn = _CreateClipRgn($hWnd) Local $hPrev = _WinAPI_GetClipRgn($wParam) Local $hBrush = _WinAPI_CreateSolidBrush(0xFFCCAA) Local $tRect = _WinAPI_GetClientRect($hWnd) _WinAPI_ExtSelectClipRgn($wParam, $hRgn, $RGN_DIFF) _WinAPI_FillRect($wParam, DllStructGetPtr($tRect), $hBrush) _WinAPI_SelectClipRgn($wParam, $hPrev) _WinAPI_DeleteObject($hBrush) _WinAPI_DeleteObject($hRgn) Return 1 Case $WM_PAINT Local $tPaint Local $hDC = _WinAPI_BeginPaint($hWnd, $tPaint) Local $hRgn = _CreateClipRgn($hWnd) _WinAPI_ExtSelectClipRgn($hDC, $hRgn, $RGN_AND) _WinAPI_CallWindowProc($hProc, $hWnd, $WM_PRINTCLIENT, $hDC, $PRF_CLIENT) _WinAPI_DeleteObject($hRgn) _WinAPI_EndPaint($hWnd, $tPaint) Return 0 EndSwitch EndIf Return _WinAPI_CallWindowProc($hProc, $hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_WinProc Func AutoItExit() _WinAPI_SetWindowLong($hTab, $GWL_WNDPROC, $hProc) DllCallbackFree($hDll) EndFunc ;==>AutoItExit
3lbuniverse Posted December 30, 2017 Posted December 30, 2017 So, it seems _GUICtrlTab_SetBkColor() is no longer a thing. And Autoit updates have effected the original postings of Yashied's workaround and Melba23's solutions but I don't know enough about WinAPI to fiddle them into working. Subz helpful update here works on my system but addresses a very specific request and only changes the color of the space at the top of the tab by the tab names. And since this thread is somewhat recent, I thought I'd just ask here instead of posting a new one. What is the current workaround to change to entire tab color? I'm not fond of the white...
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