Jump to content

mLipok

MVPs
  • Posts

    11,960
  • Joined

  • Last visited

  • Days Won

    68

mLipok last won the day on May 11

mLipok had the most liked content!

About mLipok

  • Birthday 07/19/1978

Profile Information

  • Member Title
    Sometimes... even usually I'm nitpicky.
  • Location
    Europe, Poland, Upper Silesia, Zabrze
  • Interests
    ¯\_(ツ)_/¯

Recent Profile Visitors

30,710 profile views

mLipok's Achievements

  1. it was introduced: From this time only occasionally, some examples in HelpFile were changed. Even more, many Standard UDF's are still not ready for Au3Stripper.
  2. Good Au3Stripper with those parameters #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/rm /sv /sf was stripping name of the function not strings which looks like function names for this reason only function declaration (name of the function) was stripped, and not the string OnAutoItExitRegister("__GUIDarkTheme_OnExit") Func __GUIDarkTheme_OnExit() ..... EndFunc ;==>__GUIDarkTheme_OnExit in scenario in the following snippet function declaration and function usage (name of the function) is stripped: OnAutoItExitRegister(__GUIDarkTheme_OnExit) Func __GUIDarkTheme_OnExit() ..... EndFunc ;==>__GUIDarkTheme_OnExit Au3Stripper never strips Strings enclosed within double or single quotes.
  3. Please check the following example focusing on #Region ; Fill tab background #Region ; *** Dynamically added Include files *** #include <Array.au3> ; added:05/16/26 00:23:43 #EndRegion ; *** Dynamically added Include files *** #include <ColorConstants.au3> #include <GUIConstantsEx.au3> #include <GuiTab.au3> #include <TabConstants.au3> #include <WindowsNotifsConstants.au3> #include <WindowsSysColorConstants.au3> #include <WinAPIGdi.au3> #include <WinAPISysWin.au3> #include <WinAPITheme.au3> ; Initialize System DPI awareness DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", @AutoItX64 ? "int64" : "int", -2) Global $g_hTab_CB, $g_pTab_CB, $g_hProc, $g_hTab Global Const $COLOR_BUTTON_BG = 0x383838, $COLOR_BG_DARK = 0x202020, $COLOR_GUI_BG = 0x101010, $COLOR_BORDER = 0x606060, $COLOR_BORDER_DARK = 0x303030 Example() Func Example() Local $hGUI = GUICreate("DarkTheme TabControl (24H2/25H2)", 500, 300) GUISetBkColor($COLOR_GUI_BG) GUISetFont(10) Local $idTab = GUICtrlCreateTab(20, 20, 460, 260) $g_hTab = GUICtrlGetHandle($idTab) GUICtrlCreateTabItem("tab0") GUICtrlCreateTabItem("tab1") GUICtrlCreateTabItem("tab2") GUICtrlSetState(-1, $GUI_SHOW) GUICtrlCreateTabItem("tab3") GUICtrlCreateTabItem("tab4") ; Remove focus rectangle from tab control GUICtrlSendMsg($idTab, $WM_CHANGEUISTATE, 65537, 0) ; Set dark titlebar _WinAPI_DwmSetWindowAttribute($hGUI, $DWMWA_USE_IMMERSIVE_DARK_MODE, True) ; Set theme if OS supports it If _is24H2Plus() Then _WinAPI_SetWindowTheme(GUICtrlGetHandle($idTab), 'DarkMode_DarkTheme') ; Register Subclassing / Window Procedure $g_hTab_CB = DllCallbackRegister(_WinProc, "ptr", "hwnd;uint;wparam;lparam") $g_pTab_CB = DllCallbackGetPtr($g_hTab_CB) $g_hProc = _WinAPI_SetWindowLong($g_hTab, $GWL_WNDPROC, $g_pTab_CB) GUISetState(@SW_SHOW) Local $idMsg While 1 $idMsg = GUIGetMsg() If $idMsg = $GUI_EVENT_CLOSE Then ExitLoop WEnd ; Cleanup: Restore original Window Procedure _WinAPI_SetWindowLong($g_hTab, $GWL_WNDPROC, $g_hProc) DllCallbackFree($g_hTab_CB) EndFunc ;==>Example Func _is24H2Plus() ; Check if this OS build is Windows 11 24H2/25H2 to support the newer DarkMode_DarkTheme Local $iRevision = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "UBR") Local $b24H2Plus = False If @OSBuild >= 26100 And $iRevision >= 6899 Then $b24H2Plus = True Else ConsoleWrite("Windows 11 24H2/25H2 (build 26100.6899 or higher) is required to use DarkMode_DarkTheme." & @CRLF) EndIf Return $b24H2Plus EndFunc ;==>_is24H2Plus Func _WinProc($hWnd, $iMsg, $wParam, $lParam) ;coded by UEZ Switch $iMsg Case $WM_ERASEBKGND Return 1 ; Prevent background erasing to avoid flickering Case $WM_PAINT Local $tPaint = DllStructCreate($tagPAINTSTRUCT) Local $hDC = _WinAPI_BeginPaint($hWnd, $tPaint) If @error Or Not $hDC Then Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam) Local $tClient = _WinAPI_GetClientRect($hWnd) Local $iWidth = $tClient.Right Local $iHeight = $tClient.Bottom ; Prepare Double Buffering Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight) Local $hOldBmp = _WinAPI_SelectObject($hMemDC, $hBitmap) ; --- 1. Clipping (Exclude child controls from drawing) --- Local $hParent = _WinAPI_GetParent($hWnd) Local $hChild = _WinAPI_GetWindow($hParent, $GW_CHILD) Local $tCR, $tPR = _WinAPI_GetWindowRect($hWnd) Local $left, $top, $right, $bottom While $hChild If $hChild <> $hWnd And _WinAPI_IsWindowVisible($hChild) Then $tCR = _WinAPI_GetWindowRect($hChild) If Not ($tCR.right < $tPR.left Or $tCR.left > $tPR.right Or $tCR.bottom < $tPR.top Or $tCR.top > $tPR.bottom) Then $left = Max($tCR.left, $tPR.left) - $tPR.left $top = Max($tCR.top, $tPR.top) - $tPR.top $right = Min($tCR.right, $tPR.right) - $tPR.left $bottom = Min($tCR.bottom, $tPR.bottom) - $tPR.top DllCall("gdi32.dll", "int", "ExcludeClipRect", "handle", $hMemDC, "int", $left, "int", $top, "int", $right, "int", $bottom) EndIf EndIf $hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT) WEnd Local $hTabUpDown = _WinAPI_FindWindowEx($hWnd, "msctls_updown32") If $hTabUpDown And _WinAPI_IsWindowVisible($hTabUpDown) Then $tCR = _WinAPI_GetWindowRect($hTabUpDown) If Not ($tCR.right < $tPR.left Or $tCR.left > $tPR.right Or $tCR.bottom < $tPR.top Or $tCR.top > $tPR.bottom) Then $left = Max($tCR.left, $tPR.left) - $tPR.left $top = Max($tCR.top, $tPR.top) - $tPR.top $right = Min($tCR.right, $tPR.right) - $tPR.left $bottom = Min($tCR.bottom, $tPR.bottom) - $tPR.top DllCall("gdi32.dll", "int", "ExcludeClipRect", "handle", $hMemDC, "int", $left, "int", $top, "int", $right, "int", $bottom) EndIf EndIf ; 2. Draw main background (Dark color) Local $hBrushBg = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($COLOR_BG_DARK)) ; _WinAPI_FillRect($hMemDC, $tClient, $hBrushBg) Local $iTabCount = _SendMessage($hWnd, $TCM_GETITEMCOUNT, 0, 0) Local $iCurSel = _SendMessage($hWnd, $TCM_GETCURSEL, 0, 0) ; 3. Prepare the Body Frame (The area beneath the tabs) Local $tFirstTabRect = DllStructCreate($tagRECT) _SendMessage($hWnd, $TCM_GETITEMRECT, 0, DllStructGetPtr($tFirstTabRect)) Local $tBodyRect = DllStructCreate($tagRECT) $tBodyRect.Left = 0 $tBodyRect.Top = $tFirstTabRect.Bottom ; Starts at the bottom edge of the tabs $tBodyRect.Right = $iWidth $tBodyRect.Bottom = $iHeight Local $hBrushBorder = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($COLOR_RED)) _WinAPI_FrameRect($hMemDC, $tBodyRect, $hBrushBorder) ; 4. Draw the "Gap" to the right of the tabs in GUI background color If $iTabCount > 0 Then Local $tLastTabRect = DllStructCreate($tagRECT) _SendMessage($hWnd, $TCM_GETITEMRECT, $iTabCount - 1, DllStructGetPtr($tLastTabRect)) Local $tGapRect = DllStructCreate($tagRECT) $tGapRect.Left = $tLastTabRect.Right + 2 $tGapRect.Top = 0 $tGapRect.Right = $iWidth $tGapRect.Bottom = $tLastTabRect.Bottom Local $hBrushGui = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($COLOR_GUI_BG)) _WinAPI_FillRect($hMemDC, $tGapRect, $hBrushGui) _WinAPI_DeleteObject($hBrushGui) EndIf _WinAPI_SetBkMode($hMemDC, 1) ; Transparent background for text ;~ _WinAPI_SetTextColor($hMemDC, _ColorToCOLORREF(0xF0F0F0)) ; 5. Draw individual tabs For $i = 0 To $iTabCount - 1 Local $tRECT = DllStructCreate($tagRECT) _SendMessage($hWnd, $TCM_GETITEMRECT, $i, DllStructGetPtr($tRECT)) If $tRECT.Right < 0 Or $tRECT.Left > $iWidth Then ContinueLoop $tRECT.top -= 2 #Region ; Fill tab background Local $aWinPos = WinGetPos($hWnd) Local $aMousePos = MouseGetPos() ConsoleWrite("$aWinPos : " & _ArrayToString($aWinPos) & @CRLF) ConsoleWrite("$aMousePos : " & _ArrayToString($aMousePos) & @CRLF) ConsoleWrite("HitTest : " & _ArrayToString(_GUICtrlTab_HitTest($hWnd, $aMousePos[0] - $aWinPos[0], $aMousePos[1] - $aWinPos[1])) & @CRLF) Local $bMouseOverTab = (_GUICtrlTab_HitTest($hWnd, $aMousePos[0] - $aWinPos[0], $aMousePos[1] - $aWinPos[1])[0] > -1) Local $bSelected = ($i = $iCurSel) Local $iTabColor = ($bSelected Or $bMouseOverTab) ? $COLOR_DARKSLATEGRAY : $COLOR_BG_DARK Local $hTabBrush = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($iTabColor)) _WinAPI_FillRect($hMemDC, $tRECT, $hTabBrush) #EndRegion ; Fill tab background If $bSelected Then _WinAPI_SetTextColor($hMemDC, _WinAPI_SwitchColor($COLOR_VIOLET)) ; Draw border ONLY for the active tab (Top, Left, Right) _WinAPI_FrameRect($hMemDC, $tRECT, $hBrushBorder) Local $tOpenLine = DllStructCreate($tagRECT) $tOpenLine.Left = $tRECT.Left + 1 $tOpenLine.Top = $tRECT.Bottom - 1 ; Exactly on the border line of the body $tOpenLine.Right = $tRECT.Right - 1 $tOpenLine.Bottom = $tRECT.Bottom + 1 ; OPEN BOTTOM: Draw a line in tab-color over the body-border to merge them _WinAPI_FillRect($hMemDC, $tOpenLine, $hTabBrush) Else _WinAPI_SetTextColor($hMemDC, _WinAPI_SwitchColor($COLOR_RED)) ; Draw rectangle around non active tabs Local $hBrushTabRecDark = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($COLOR_BORDER_DARK)) _WinAPI_FrameRect($hMemDC, $tRECT, $hBrushTabRecDark) _WinAPI_DeleteObject($hBrushTabRecDark) EndIf _WinAPI_DeleteObject($hTabBrush) ; Draw text centered Local $sText = _GUICtrlTab_GetItemText($hWnd, $i) Local $tTextRect = DllStructCreate($tagRECT) With $tTextRect .Left = $tRECT.Left + 6 .Top = $tRECT.Top + ($bSelected ? 1 : 3) .Right = $tRECT.Right - 6 .Bottom = $tRECT.Bottom - 3 EndWith DllCall("user32.dll", "int", "DrawTextW", "handle", $hMemDC, "wstr", $sText, "int", -1, "struct*", $tTextRect, "uint", BitOR($DT_CENTER, $DT_VCENTER, $DT_SINGLELINE, $DT_NOPREFIX)) Next ; 6. Copy memory DC to screen DC (BitBlt) _WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hMemDC, 0, 0, $SRCCOPY) ; Cleanup _WinAPI_SelectObject($hMemDC, $hOldBmp) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hBrushBg) _WinAPI_DeleteObject($hBrushBorder) _WinAPI_DeleteDC($hMemDC) _WinAPI_EndPaint($hWnd, $tPaint) Return 0 EndSwitch Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_WinProc Func _ColorToCOLORREF($iColor) ; Convert RGB to BGR Local $iR = BitAND(BitShift($iColor, 16), 0xFF) Local $iG = BitAND(BitShift($iColor, 8), 0xFF) Local $iB = BitAND($iColor, 0xFF) Return BitOR(BitShift($iB, -16), BitShift($iG, -8), $iR) EndFunc ;==>_ColorToCOLORREF Func Min($a, $b) Return ($a < $b ? $a : $b) EndFunc ;==>Min Func Max($a, $b) Return ($a > $b ? $a : $b) EndFunc ;==>Max Func _WinAPI_FindWindowEx($hParent, $sClass, $sTitle = "", $hAfter = 0) Local $ret = DllCall("user32.dll", "hwnd", "FindWindowExW", "hwnd", $hParent, "hwnd", $hAfter, "wstr", $sClass, "wstr", $sTitle) If @error Or Not IsArray($ret) Then Return 0 Return $ret[0] EndFunc ;==>_WinAPI_FindWindowEx btw. there are some issues but it is a good start
  4. check: https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmmouse but.. I have also other idea... working on
  5. Did you have oportunity to test my 2 last examples? Any comment on them ?
  6. Not sure what exactly you mean, as I said I not following this thread from begining and Im not expert here.
  7. haha..... I do not see this issue in this example #include <ColorConstants.au3> #include <GUIConstantsEx.au3> #include <GuiTab.au3> #include <TabConstants.au3> #include <WindowsNotifsConstants.au3> #include <WindowsSysColorConstants.au3> #include <WinAPIGdi.au3> #include <WinAPISysWin.au3> #include <WinAPITheme.au3> ; Initialize System DPI awareness DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", @AutoItX64 ? "int64" : "int", -2) Global $g_hTab_CB, $g_pTab_CB, $g_hProc, $g_hTab Global Const $COLOR_BUTTON_BG = 0x383838, $COLOR_BG_DARK = 0x202020, $COLOR_GUI_BG = 0x101010, $COLOR_BORDER = 0x606060, $COLOR_BORDER_DARK = 0x303030 Example() Func Example() Local $hGUI = GUICreate("DarkTheme TabControl (24H2/25H2)", 500, 300) GUISetBkColor($COLOR_GUI_BG) GUISetFont(10) Local $idTab = GUICtrlCreateTab(20, 20, 460, 260) $g_hTab = GUICtrlGetHandle($idTab) GUICtrlCreateTabItem("tab0") GUICtrlCreateTabItem("tab1") GUICtrlSetState(-1, $GUI_SHOW) GUICtrlCreateTabItem("tab2") GUICtrlCreateTabItem("tab3") GUICtrlCreateTabItem("tab4") ; Remove focus rectangle from tab control GUICtrlSendMsg($idTab, $WM_CHANGEUISTATE, 65537, 0) ; Set dark titlebar _WinAPI_DwmSetWindowAttribute($hGUI, $DWMWA_USE_IMMERSIVE_DARK_MODE, True) ; Set theme if OS supports it If _is24H2Plus() Then _WinAPI_SetWindowTheme(GUICtrlGetHandle($idTab), 'DarkMode_DarkTheme') ; Register Subclassing / Window Procedure $g_hTab_CB = DllCallbackRegister(_WinProc, "ptr", "hwnd;uint;wparam;lparam") $g_pTab_CB = DllCallbackGetPtr($g_hTab_CB) $g_hProc = _WinAPI_SetWindowLong($g_hTab, $GWL_WNDPROC, $g_pTab_CB) GUISetState(@SW_SHOW) Local $idMsg While 1 WinMove($hGUI, "", 400, 300, (8 * Random(0, 1, 1)) + 157) Sleep(400) $idMsg = GUIGetMsg() If $idMsg = $GUI_EVENT_CLOSE Then ExitLoop WEnd ; Cleanup: Restore original Window Procedure _WinAPI_SetWindowLong($g_hTab, $GWL_WNDPROC, $g_hProc) DllCallbackFree($g_hTab_CB) EndFunc ;==>Example Func _is24H2Plus() ; Check if this OS build is Windows 11 24H2/25H2 to support the newer DarkMode_DarkTheme Local $iRevision = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "UBR") Local $b24H2Plus = False If @OSBuild >= 26100 And $iRevision >= 6899 Then $b24H2Plus = True Else ConsoleWrite("Windows 11 24H2/25H2 (build 26100.6899 or higher) is required to use DarkMode_DarkTheme." & @CRLF) EndIf Return $b24H2Plus EndFunc ;==>_is24H2Plus Func _WinProc($hWnd, $iMsg, $wParam, $lParam) ;coded by UEZ Switch $iMsg Case $WM_ERASEBKGND Return 1 ; Prevent background erasing to avoid flickering Case $WM_PAINT Local $tPaint = DllStructCreate($tagPAINTSTRUCT) Local $hDC = _WinAPI_BeginPaint($hWnd, $tPaint) If @error Or Not $hDC Then Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam) Local $tClient = _WinAPI_GetClientRect($hWnd) Local $iWidth = $tClient.Right Local $iHeight = $tClient.Bottom ; Prepare Double Buffering Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight) Local $hOldBmp = _WinAPI_SelectObject($hMemDC, $hBitmap) ; --- 1. Clipping (Exclude child controls from drawing) --- Local $hParent = _WinAPI_GetParent($hWnd) Local $hChild = _WinAPI_GetWindow($hParent, $GW_CHILD) Local $tCR, $tPR = _WinAPI_GetWindowRect($hWnd) Local $left, $top, $right, $bottom While $hChild If $hChild <> $hWnd And _WinAPI_IsWindowVisible($hChild) Then $tCR = _WinAPI_GetWindowRect($hChild) If Not ($tCR.right < $tPR.left Or $tCR.left > $tPR.right Or $tCR.bottom < $tPR.top Or $tCR.top > $tPR.bottom) Then $left = Max($tCR.left, $tPR.left) - $tPR.left $top = Max($tCR.top, $tPR.top) - $tPR.top $right = Min($tCR.right, $tPR.right) - $tPR.left $bottom = Min($tCR.bottom, $tPR.bottom) - $tPR.top DllCall("gdi32.dll", "int", "ExcludeClipRect", "handle", $hMemDC, "int", $left, "int", $top, "int", $right, "int", $bottom) EndIf EndIf $hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT) WEnd Local $hTabUpDown = _WinAPI_FindWindowEx($hWnd, "msctls_updown32") If $hTabUpDown And _WinAPI_IsWindowVisible($hTabUpDown) Then $tCR = _WinAPI_GetWindowRect($hTabUpDown) If Not ($tCR.right < $tPR.left Or $tCR.left > $tPR.right Or $tCR.bottom < $tPR.top Or $tCR.top > $tPR.bottom) Then $left = Max($tCR.left, $tPR.left) - $tPR.left $top = Max($tCR.top, $tPR.top) - $tPR.top $right = Min($tCR.right, $tPR.right) - $tPR.left $bottom = Min($tCR.bottom, $tPR.bottom) - $tPR.top DllCall("gdi32.dll", "int", "ExcludeClipRect", "handle", $hMemDC, "int", $left, "int", $top, "int", $right, "int", $bottom) EndIf EndIf ; 2. Draw main background (Dark color) Local $hBrushBg = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($COLOR_BG_DARK)) ; _WinAPI_FillRect($hMemDC, $tClient, $hBrushBg) Local $iTabCount = _SendMessage($hWnd, $TCM_GETITEMCOUNT, 0, 0) Local $iCurSel = _SendMessage($hWnd, $TCM_GETCURSEL, 0, 0) ; 3. Prepare the Body Frame (The area beneath the tabs) Local $tFirstTabRect = DllStructCreate($tagRECT) _SendMessage($hWnd, $TCM_GETITEMRECT, 0, DllStructGetPtr($tFirstTabRect)) Local $tBodyRect = DllStructCreate($tagRECT) $tBodyRect.Left = 0 $tBodyRect.Top = $tFirstTabRect.Bottom ; Starts at the bottom edge of the tabs $tBodyRect.Right = $iWidth $tBodyRect.Bottom = $iHeight Local $hBrushBorder = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($COLOR_RED)) _WinAPI_FrameRect($hMemDC, $tBodyRect, $hBrushBorder) ; 4. Draw the "Gap" to the right of the tabs in GUI background color If $iTabCount > 0 Then Local $tLastTabRect = DllStructCreate($tagRECT) _SendMessage($hWnd, $TCM_GETITEMRECT, $iTabCount - 1, DllStructGetPtr($tLastTabRect)) Local $tGapRect = DllStructCreate($tagRECT) $tGapRect.Left = $tLastTabRect.Right + 2 $tGapRect.Top = 0 $tGapRect.Right = $iWidth $tGapRect.Bottom = $tLastTabRect.Bottom Local $hBrushGui = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($COLOR_GUI_BG)) _WinAPI_FillRect($hMemDC, $tGapRect, $hBrushGui) _WinAPI_DeleteObject($hBrushGui) EndIf _WinAPI_SetBkMode($hMemDC, 1) ; Transparent background for text ;~ _WinAPI_SetTextColor($hMemDC, _ColorToCOLORREF(0xF0F0F0)) ; 5. Draw individual tabs For $i = 0 To $iTabCount - 1 Local $tRECT = DllStructCreate($tagRECT) _SendMessage($hWnd, $TCM_GETITEMRECT, $i, DllStructGetPtr($tRECT)) If $tRECT.Right < 0 Or $tRECT.Left > $iWidth Then ContinueLoop $tRECT.top -= 2 Local $bSelected = ($i = $iCurSel) Local $iTabColor = $bSelected ? $COLOR_DARKSLATEGRAY : $COLOR_BG_DARK Local $hTabBrush = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($iTabColor)) ; Fill tab background _WinAPI_FillRect($hMemDC, $tRECT, $hTabBrush) If $bSelected Then _WinAPI_SetTextColor($hMemDC, _WinAPI_SwitchColor($COLOR_VIOLET)) ; Draw border ONLY for the active tab (Top, Left, Right) _WinAPI_FrameRect($hMemDC, $tRECT, $hBrushBorder) ; OPEN BOTTOM: Draw a line in tab-color over the body-border to merge them Local $tOpenLine = DllStructCreate($tagRECT) $tOpenLine.Left = $tRECT.Left + 1 $tOpenLine.Top = $tRECT.Bottom - 1 ; Exactly on the border line of the body $tOpenLine.Right = $tRECT.Right - 1 $tOpenLine.Bottom = $tRECT.Bottom + 1 _WinAPI_FillRect($hMemDC, $tOpenLine, $hTabBrush) Else _WinAPI_SetTextColor($hMemDC, _WinAPI_SwitchColor($COLOR_RED)) ; Draw rectangle around non active tabs Local $hBrushTabRecDark = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($COLOR_BORDER_DARK)) _WinAPI_FrameRect($hMemDC, $tRECT, $hBrushTabRecDark) _WinAPI_DeleteObject($hBrushTabRecDark) EndIf _WinAPI_DeleteObject($hTabBrush) ; Draw text centered Local $sText = _GUICtrlTab_GetItemText($hWnd, $i) Local $tTextRect = DllStructCreate($tagRECT) With $tTextRect .Left = $tRECT.Left + 6 .Top = $tRECT.Top + ($bSelected ? 1 : 3) .Right = $tRECT.Right - 6 .Bottom = $tRECT.Bottom - 3 EndWith DllCall("user32.dll", "int", "DrawTextW", "handle", $hMemDC, "wstr", $sText, "int", -1, "struct*", $tTextRect, "uint", BitOR($DT_CENTER, $DT_VCENTER, $DT_SINGLELINE, $DT_NOPREFIX)) Next ; 6. Copy memory DC to screen DC (BitBlt) _WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hMemDC, 0, 0, $SRCCOPY) ; Cleanup _WinAPI_SelectObject($hMemDC, $hOldBmp) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hBrushBg) _WinAPI_DeleteObject($hBrushBorder) _WinAPI_DeleteDC($hMemDC) _WinAPI_EndPaint($hWnd, $tPaint) Return 0 EndSwitch Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_WinProc Func _ColorToCOLORREF($iColor) ; Convert RGB to BGR Local $iR = BitAND(BitShift($iColor, 16), 0xFF) Local $iG = BitAND(BitShift($iColor, 8), 0xFF) Local $iB = BitAND($iColor, 0xFF) Return BitOR(BitShift($iB, -16), BitShift($iG, -8), $iR) EndFunc ;==>_ColorToCOLORREF Func Min($a, $b) Return ($a < $b ? $a : $b) EndFunc ;==>Min Func Max($a, $b) Return ($a > $b ? $a : $b) EndFunc ;==>Max Func _WinAPI_FindWindowEx($hParent, $sClass, $sTitle = "", $hAfter = 0) Local $ret = DllCall("user32.dll", "hwnd", "FindWindowExW", "hwnd", $hParent, "hwnd", $hAfter, "wstr", $sClass, "wstr", $sTitle) If @error Or Not IsArray($ret) Then Return 0 Return $ret[0] EndFunc ;==>_WinAPI_FindWindowEx
  8. hey you know what ? I have an idea: Try to focus on how the "frame" is drawn here
  9. Found it 100% example: Note that tab2 size is changing but the blue line above stays with the same size ;~ https://www.autoitscript.com/forum/topic/213699-how-can-i-determine-if-tab-item-is-visible-in-tab-control/#findComment-1552580 ; From Nine #include <GUIConstants.au3> #include <WinAPI.au3> #include <GuiTab.au3> #include <WindowsSysColorConstants.au3> #include <WinAPITheme.au3> ; initiate System DPI awareness DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", @AutoItX64 ? "int64" : "int", -2) Opt("MustDeclareVars", True) Global $g_hPenAccent = _WinAPI_CreatePen($PS_SOLID, 2, _ColorToCOLORREF(0x0078D4)) Example() Func Example() Local $hGUI = GUICreate("DarkTheme TabControl", 400, 300, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP)) GUISetBkColor(0x191919) GUISetFont(10, 300) Local $idTab = GUICtrlCreateTab(20, 20, 360, 260) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM) Local $hTab = GUICtrlGetHandle($idTab) GUICtrlCreateTabItem("tab0") GUICtrlCreateLabel("label0", 30, 80, 300, 60) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x262626) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP) GUICtrlCreateTabItem("tab1") GUICtrlCreateLabel("label1", 30, 80, 300, 60) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x262626) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP) GUICtrlCreateTabItem("tab2") GUICtrlSetState(-1, $GUI_SHOW) GUICtrlCreateLabel("Resize GUI to trigger"&@CRLF&"UpDown controls.", 30, 80, 300, 30) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x262626) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP) Local $iLable_size = GUICtrlCreateLabel("Width", 30, 130, 200, 30) GUICtrlSetColor(-1, 0x00FF10) GUICtrlSetBkColor(-1, 0x262626) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP) GUICtrlCreateLabel('Note that "tab2" size is changing but the blue line above stays with the same size', 30, 160, 240, 90) GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetBkColor(-1, 0x262626) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP) GUICtrlCreateTabItem("tab3") GUICtrlCreateLabel("label3", 30, 80, 300, 60) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x262626) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP) GUICtrlCreateTabItem("tab4") GUICtrlCreateLabel("label4", 30, 80, 300, 60) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x262626) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP) GUICtrlCreateTabItem("") ; end tabitem definition ; set DarkMode_DarkTheme visual theme on Tab control as long as OSBuild supports it If _is24H2Plus() Then _WinAPI_SetWindowTheme($hTab, 'DarkMode_DarkTheme') ; get handle for UpDown control to apply theme Local $hUpDown = _WinAPI_FindWindowEx($hTab, "msctls_updown32") If _is24H2Plus() And $hUpDown Then _WinAPI_SetWindowTheme($hUpDown, 'DarkMode_DarkTheme') Local $pAddress = _WinAPI_GetWindowLong($hTab, $GWL_WNDPROC) Local $hSubclass = DllCallbackRegister(_ModernTabProc, "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr") _WinAPI_SetWindowSubclass($hTab, DllCallbackGetPtr($hSubclass), $idTab, $pAddress) ; remove focus rectangle from tab control GUICtrlSendMsg($idTab, $WM_CHANGEUISTATE, 65537, 0) _GUICtrlTab_ActivateTab($idTab, 1) ; lower the Z-order of the tab control (helps fix various issues) _WinAPI_SetWindowPos($hTab, $HWND_BOTTOM, 0, 0, 0, 0, BitOR($SWP_NOMOVE, $SWP_NOREDRAW, $SWP_NOSIZE)) GUISetState() While 1 WinMove($hGUI, "", 400, 300, (8 * Random(0, 1, 1)) + 240) GUICtrlSetData($iLable_size, "GUI width=" & WinGetPos($hGUI, "")[2]) Sleep(400) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _WinAPI_RemoveWindowSubclass($hTab, DllCallbackGetPtr($hSubclass), $idTab) DllCallbackFree($hSubclass) EndFunc ;==>Example Func _ModernTabProc($hWnd, $iMsg, $wParam, $lParam, $iID, $pData) #forceref $iID, $pData Local $iTabCount ;~ ConsoleWrite("- _WinAPI_GetClassName($hWnd) = " & _WinAPI_GetClassName($hWnd) & @CRLF) ;~ _WinAPI_GetClassName($hWnd) = "msctls_updown32" Switch $iMsg Case $WM_ERASEBKGND Return 1 ; Prevent background erase to avoid flicker Case $WM_PAINT Local $tPaint = DllStructCreate($tagPAINTSTRUCT) Local $hDC = _WinAPI_BeginPaint($hWnd, $tPaint) Local $tRect2 = _WinAPI_GetClientRect($hWnd) Local $iW = $tRect2.Right Local $iH = $tRect2.Bottom Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) Local $hOldBmp = _WinAPI_SelectObject($hMemDC, $hBitmap) Local $iUpDownWidth = 0 Local Const $PRF_CHILDREN = 16 Local Const $PRF_CLIENT = 4 _SendMessage($hWnd, $WM_PRINTCLIENT, $hMemDC, BitOR($PRF_CLIENT, $PRF_CHILDREN)) Local $hBrush = _WinAPI_CreateSolidBrush(0x191919) $iTabCount = _GUICtrlTab_GetItemCount($hWnd) If $iTabCount > 0 Then ; determine if tab control contains an UpDown (spin) control Local $hTabUpDown = _WinAPI_FindWindowEx($hWnd, "msctls_updown32") If $hTabUpDown And _WinAPI_IsWindowVisible($hTabUpDown) Then Local $tCR = _WinAPI_GetWindowRect($hTabUpDown) Local $tPR = _WinAPI_GetWindowRect($hWnd) ; get width of UpDown control $iUpDownWidth = $tCR.Right - $tCR.Left ; exclude UpDown control from being painted over DllCall('gdi32.dll', "int", "ExcludeClipRect", "handle", $hDC, "int", $tCR.Left - $tPR.Left, "int", _ $tCR.Top - $tPR.Top - 1, "int", $tCR.Right - $tPR.Left, "int", $tCR.Bottom - $tPR.Top + 2) EndIf ; Draw selection indicator (top border for selected tab) Local $tRect, $iLeft, $iTop, $iRight, $iBottom $iTabCount = _SendMessage($hWnd, $TCM_GETITEMCOUNT, 0, 0) Local $iCurSel = _SendMessage($hWnd, $TCM_GETCURSEL, 0, 0) For $i = 0 To $iTabCount - 1 Local $bSelected = ($i = $iCurSel) If $bSelected Then ; Get tab rectangle using TCM_GETITEMRECT $tRect = DllStructCreate($tagRECT) Local $aResult = DllCall('user32.dll', "lresult", "SendMessageW", _ "hwnd", $hWnd, _ "uint", $TCM_GETITEMRECT, _ "wparam", $i, _ "struct*", $tRect) If @error Or Not $aResult[0] Then ContinueLoop $iLeft = $tRect.Left $iTop = $tRect.Top $iRight = $tRect.Right $iBottom = $tRect.Bottom ;If _GUICtrlTab_HitTest($hWnd, 10, 10)[0] <> 0 Then ConsoleWrite("tab on left is not 0" & @CRLF) ;ConsoleWrite("tab on left: " & _GUICtrlTab_HitTest($hWnd, 10, 10)[0] & @CRLF) ; adjustment for UpDown ;Local $iTabOnLeft = _GUICtrlTab_HitTest($hWnd, 10, 10)[0] If $hTabUpDown And _WinAPI_IsWindowVisible($hTabUpDown) Then Local $iTabOnLeft = _GUICtrlTab_HitTest($hWnd, 10, 10)[0] If $iTabOnLeft <> 0 Then $iRight = $tRect.Right If $iTabOnLeft = 0 And $iCurSel <> 0 Then $iRight = $tRect.Right - 2 ; if tab on left <> selected tab... EndIf ConsoleWrite(@CRLF) ConsoleWrite("$tRect.Left: " & $tRect.Left & @CRLF) ConsoleWrite("$tRect.Top: " & $tRect.Top & @CRLF) ConsoleWrite("$tRect.Right: " & $tRect.Right & @CRLF) ConsoleWrite("$tRect.Bottom: " & $tRect.Bottom & @CRLF) ;If $hTabUpDown And _WinAPI_IsWindowVisible($hTabUpDown) And $i <> 0 Then $iRight = $tRect.Right - 2 ;If $hTabUpDown And _WinAPI_IsWindowVisible($hTabUpDown) And $iTabOnLeft <> 0 Then $iRight = $tRect.Right ; Skip if rectangle is invalid If $iLeft >= $iRight Or $iTop >= $iBottom Then ContinueLoop Local $hPen = $g_hPenAccent Local $hOldPen = _WinAPI_SelectObject($hMemDC, $hPen) _WinAPI_MoveTo($hMemDC, $iLeft - 1, $iTop - 1) _WinAPI_LineTo($hMemDC, $iRight, $iTop - 2) _WinAPI_SelectObject($hMemDC, $hOldPen) EndIf _WinAPI_SelectObject($hMemDC, $hBrush) _WinAPI_ExtFloodFill($hMemDC, $tRect2.right - 1 - $iUpDownWidth, 1, 0xf0f0f0, $FLOODFILLSURFACE) _WinAPI_ExtFloodFill($hMemDC, $tRect2.left + 1, 1, 0xf0f0f0, $FLOODFILLSURFACE) Next _WinAPI_DeleteObject($hBrush) _WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hMemDC, 0, 0, $SRCCOPY) _WinAPI_SelectObject($hMemDC, $hOldBmp) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) _WinAPI_EndPaint($hWnd, $tPaint) EndIf Return 0 Case $WM_PARENTNOTIFY ; Fired when a child window is created inside the tab control. ; The tab spinner (msctls_updown32) is created lazily by Windows when tabs overflow - ; it doesn't exist at init time, so we theme it here the moment it appears. If _WinAPI_LoWord($wParam) = $WM_CREATE Then Local $hNewChild = HWnd($lParam) ; lParam carries the new child's HWND as integer - must cast! If _WinAPI_GetClassName($hNewChild) = "msctls_updown32" Then If _is24H2Plus() Then _WinAPI_SetWindowTheme($hNewChild, 'DarkMode_DarkTheme') EndIf EndIf Return __WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndSwitch Return __WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_ModernTabProc Func _is24H2Plus() ; check if this OS build is Windows 11 24H2/25H2 to support the newer DarkMode_DarkTheme Local $iRevision = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "UBR") Local $b24H2Plus = False If @OSBuild >= 26100 And $iRevision >= 6899 Then $b24H2Plus = True Else ConsoleWrite("Windows 11 24H2/25H2 (build 26100.6899 or higher) is required to use DarkMode_DarkTheme.") EndIf Return $b24H2Plus EndFunc ;==>_is24H2Plus Func _WinAPI_FindWindowEx($hParent, $sClass, $sTitle = "", $hAfter = 0) Local $ret = DllCall('user32.dll', "hwnd", "FindWindowExW", "hwnd", $hParent, "hwnd", $hAfter, "wstr", $sClass, "wstr", $sTitle) If @error Or Not IsArray($ret) Then Return 0 Return $ret[0] EndFunc ;==>_WinAPI_FindWindowEx Func __WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) Return DllCall('comctl32.dll', 'lresult', 'DefSubclassProc', 'hwnd', $hWnd, 'uint', $iMsg, 'wparam', $wParam, _ 'lparam', $lParam)[0] EndFunc ;==>__WinAPI_DefSubclassProc Func _ColorToCOLORREF($iColor) ;RGB to BGR Local $iR = BitAND(BitShift($iColor, 16), 0xFF) Local $iG = BitAND(BitShift($iColor, 8), 0xFF) Local $iB = BitAND($iColor, 0xFF) Return BitOR(BitShift($iB, -16), BitShift($iG, -8), $iR) EndFunc ;==>_ColorToCOLORREF
  10. modified: While 1 WinMove($hGUI, "", 400, 300, (20 * Random(1, 3, 2)) + 180) Sleep(400) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd full example: ;~ https://www.autoitscript.com/forum/topic/213699-how-can-i-determine-if-tab-item-is-visible-in-tab-control/#findComment-1552571 ; From Nine #include <GUIConstants.au3> #include <WinAPI.au3> #include <GuiTab.au3> #include <WindowsSysColorConstants.au3> #include <WinAPITheme.au3> ; initiate System DPI awareness DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", @AutoItX64 ? "int64" : "int", -2) Opt("MustDeclareVars", True) Global $g_hPenAccent = _WinAPI_CreatePen($PS_SOLID, 2, _ColorToCOLORREF(0x0078D4)) Example() Func Example() Local $hGUI = GUICreate("DarkTheme TabControl", 400, 300, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP)) GUISetBkColor(0x191919) GUISetFont(10, 300) Local $idTab = GUICtrlCreateTab(20, 20, 360, 260) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM) Local $hTab = GUICtrlGetHandle($idTab) GUICtrlCreateTabItem("tab0") GUICtrlCreateLabel("label0", 30, 80, 300, 60) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x262626) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP) GUICtrlCreateTabItem("tab1") GUICtrlCreateLabel("label1", 30, 80, 300, 60) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x262626) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP) GUICtrlCreateTabItem("tab2") GUICtrlSetState(-1, $GUI_SHOW) GUICtrlCreateLabel("Resize GUI to trigger UpDown controls.", 30, 80, 300, 100) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x262626) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP) GUICtrlCreateTabItem("tab3") GUICtrlCreateLabel("label3", 30, 80, 300, 60) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x262626) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP) GUICtrlCreateTabItem("tab4") GUICtrlCreateLabel("label4", 30, 80, 300, 60) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x262626) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP) GUICtrlCreateTabItem("") ; end tabitem definition ; set DarkMode_DarkTheme visual theme on Tab control as long as OSBuild supports it If _is24H2Plus() Then _WinAPI_SetWindowTheme($hTab, 'DarkMode_DarkTheme') ; get handle for UpDown control to apply theme Local $hUpDown = _WinAPI_FindWindowEx($hTab, "msctls_updown32") If _is24H2Plus() And $hUpDown Then _WinAPI_SetWindowTheme($hUpDown, 'DarkMode_DarkTheme') Local $pAddress = _WinAPI_GetWindowLong($hTab, $GWL_WNDPROC) Local $hSubclass = DllCallbackRegister(_ModernTabProc, "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr") _WinAPI_SetWindowSubclass($hTab, DllCallbackGetPtr($hSubclass), $idTab, $pAddress) ; remove focus rectangle from tab control GUICtrlSendMsg($idTab, $WM_CHANGEUISTATE, 65537, 0) ; lower the Z-order of the tab control (helps fix various issues) _WinAPI_SetWindowPos($hTab, $HWND_BOTTOM, 0, 0, 0, 0, BitOR($SWP_NOMOVE, $SWP_NOREDRAW, $SWP_NOSIZE)) GUISetState() While 1 WinMove($hGUI, "", 400, 300, (20 * Random(1, 3, 2)) + 180) Sleep(400) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _WinAPI_RemoveWindowSubclass($hTab, DllCallbackGetPtr($hSubclass), $idTab) DllCallbackFree($hSubclass) EndFunc ;==>Example Func _ModernTabProc($hWnd, $iMsg, $wParam, $lParam, $iID, $pData) #forceref $iID, $pData Local $iTabCount ;~ ConsoleWrite("- _WinAPI_GetClassName($hWnd) = " & _WinAPI_GetClassName($hWnd) & @CRLF) ;~ _WinAPI_GetClassName($hWnd) = "msctls_updown32" Switch $iMsg Case $WM_ERASEBKGND Return 1 ; Prevent background erase to avoid flicker Case $WM_PAINT Local $tPaint = DllStructCreate($tagPAINTSTRUCT) Local $hDC = _WinAPI_BeginPaint($hWnd, $tPaint) Local $tRect2 = _WinAPI_GetClientRect($hWnd) Local $iW = $tRect2.Right Local $iH = $tRect2.Bottom Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) Local $hOldBmp = _WinAPI_SelectObject($hMemDC, $hBitmap) Local $iUpDownWidth = 0 Local Const $PRF_CHILDREN = 16 Local Const $PRF_CLIENT = 4 _SendMessage($hWnd, $WM_PRINTCLIENT, $hMemDC, BitOR($PRF_CLIENT, $PRF_CHILDREN)) Local $hBrush = _WinAPI_CreateSolidBrush(0x191919) $iTabCount = _GUICtrlTab_GetItemCount($hWnd) If $iTabCount > 0 Then ; determine if tab control contains an UpDown (spin) control Local $hTabUpDown = _WinAPI_FindWindowEx($hWnd, "msctls_updown32") If $hTabUpDown And _WinAPI_IsWindowVisible($hTabUpDown) Then Local $tCR = _WinAPI_GetWindowRect($hTabUpDown) Local $tPR = _WinAPI_GetWindowRect($hWnd) ; get width of UpDown control $iUpDownWidth = $tCR.Right - $tCR.Left ; exclude UpDown control from being painted over DllCall('gdi32.dll', "int", "ExcludeClipRect", "handle", $hDC, "int", $tCR.Left - $tPR.Left, "int", _ $tCR.Top - $tPR.Top - 1, "int", $tCR.Right - $tPR.Left, "int", $tCR.Bottom - $tPR.Top + 2) EndIf ; Draw selection indicator (top border for selected tab) Local $tRect, $iLeft, $iTop, $iRight, $iBottom $iTabCount = _SendMessage($hWnd, $TCM_GETITEMCOUNT, 0, 0) Local $iCurSel = _SendMessage($hWnd, $TCM_GETCURSEL, 0, 0) For $i = 0 To $iTabCount - 1 Local $bSelected = ($i = $iCurSel) If $bSelected Then ; Get tab rectangle using TCM_GETITEMRECT $tRect = DllStructCreate($tagRECT) Local $aResult = DllCall('user32.dll', "lresult", "SendMessageW", _ "hwnd", $hWnd, _ "uint", $TCM_GETITEMRECT, _ "wparam", $i, _ "struct*", $tRect) If @error Or Not $aResult[0] Then ContinueLoop $iLeft = $tRect.Left $iTop = $tRect.Top $iRight = $tRect.Right $iBottom = $tRect.Bottom ;If _GUICtrlTab_HitTest($hWnd, 10, 10)[0] <> 0 Then ConsoleWrite("tab on left is not 0" & @CRLF) ;ConsoleWrite("tab on left: " & _GUICtrlTab_HitTest($hWnd, 10, 10)[0] & @CRLF) ; adjustment for UpDown ;Local $iTabOnLeft = _GUICtrlTab_HitTest($hWnd, 10, 10)[0] If $hTabUpDown And _WinAPI_IsWindowVisible($hTabUpDown) Then Local $iTabOnLeft = _GUICtrlTab_HitTest($hWnd, 10, 10)[0] If $iTabOnLeft <> 0 Then $iRight = $tRect.Right If $iTabOnLeft = 0 And $iCurSel <> 0 Then $iRight = $tRect.Right - 2 ; if tab on left <> selected tab... EndIf ConsoleWrite(@CRLF) ConsoleWrite("$tRect.Left: " & $tRect.Left & @CRLF) ConsoleWrite("$tRect.Top: " & $tRect.Top & @CRLF) ConsoleWrite("$tRect.Right: " & $tRect.Right & @CRLF) ConsoleWrite("$tRect.Bottom: " & $tRect.Bottom & @CRLF) ;If $hTabUpDown And _WinAPI_IsWindowVisible($hTabUpDown) And $i <> 0 Then $iRight = $tRect.Right - 2 ;If $hTabUpDown And _WinAPI_IsWindowVisible($hTabUpDown) And $iTabOnLeft <> 0 Then $iRight = $tRect.Right ; Skip if rectangle is invalid If $iLeft >= $iRight Or $iTop >= $iBottom Then ContinueLoop Local $hPen = $g_hPenAccent Local $hOldPen = _WinAPI_SelectObject($hMemDC, $hPen) _WinAPI_MoveTo($hMemDC, $iLeft - 1, $iTop - 1) _WinAPI_LineTo($hMemDC, $iRight, $iTop - 2) _WinAPI_SelectObject($hMemDC, $hOldPen) EndIf _WinAPI_SelectObject($hMemDC, $hBrush) _WinAPI_ExtFloodFill($hMemDC, $tRect2.right - 1 - $iUpDownWidth, 1, 0xf0f0f0, $FLOODFILLSURFACE) _WinAPI_ExtFloodFill($hMemDC, $tRect2.left + 1, 1, 0xf0f0f0, $FLOODFILLSURFACE) Next _WinAPI_DeleteObject($hBrush) _WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hMemDC, 0, 0, $SRCCOPY) _WinAPI_SelectObject($hMemDC, $hOldBmp) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) _WinAPI_EndPaint($hWnd, $tPaint) EndIf Return 0 Case $WM_PARENTNOTIFY ; Fired when a child window is created inside the tab control. ; The tab spinner (msctls_updown32) is created lazily by Windows when tabs overflow - ; it doesn't exist at init time, so we theme it here the moment it appears. If _WinAPI_LoWord($wParam) = $WM_CREATE Then Local $hNewChild = HWnd($lParam) ; lParam carries the new child's HWND as integer - must cast! If _WinAPI_GetClassName($hNewChild) = "msctls_updown32" Then If _is24H2Plus() Then _WinAPI_SetWindowTheme($hNewChild, 'DarkMode_DarkTheme') EndIf EndIf Return __WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndSwitch Return __WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_ModernTabProc Func _is24H2Plus() ; check if this OS build is Windows 11 24H2/25H2 to support the newer DarkMode_DarkTheme Local $iRevision = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "UBR") Local $b24H2Plus = False If @OSBuild >= 26100 And $iRevision >= 6899 Then $b24H2Plus = True Else ConsoleWrite("Windows 11 24H2/25H2 (build 26100.6899 or higher) is required to use DarkMode_DarkTheme.") EndIf Return $b24H2Plus EndFunc ;==>_is24H2Plus Func _WinAPI_FindWindowEx($hParent, $sClass, $sTitle = "", $hAfter = 0) Local $ret = DllCall('user32.dll', "hwnd", "FindWindowExW", "hwnd", $hParent, "hwnd", $hAfter, "wstr", $sClass, "wstr", $sTitle) If @error Or Not IsArray($ret) Then Return 0 Return $ret[0] EndFunc ;==>_WinAPI_FindWindowEx Func __WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) Return DllCall('comctl32.dll', 'lresult', 'DefSubclassProc', 'hwnd', $hWnd, 'uint', $iMsg, 'wparam', $wParam, _ 'lparam', $lParam)[0] EndFunc ;==>__WinAPI_DefSubclassProc Func _ColorToCOLORREF($iColor) ;RGB to BGR Local $iR = BitAND(BitShift($iColor, 16), 0xFF) Local $iG = BitAND(BitShift($iColor, 8), 0xFF) Local $iB = BitAND($iColor, 0xFF) Return BitOR(BitShift($iB, -16), BitShift($iG, -8), $iR) EndFunc ;==>_ColorToCOLORREF Still wondering how to notice the issue.
  11. Here is little modified example to mimic the window resize. Could you say what is wrong ? How I can notice the issue ? ;~ https://www.autoitscript.com/forum/topic/213699-how-can-i-determine-if-tab-item-is-visible-in-tab-control/#findComment-1552571 ; From Nine #include <GUIConstants.au3> #include <WinAPI.au3> #include <GuiTab.au3> #include <WindowsSysColorConstants.au3> #include <WinAPITheme.au3> ; initiate System DPI awareness DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", @AutoItX64 ? "int64" : "int", -2) Opt("MustDeclareVars", True) Global $g_hPenAccent = _WinAPI_CreatePen($PS_SOLID, 2, _ColorToCOLORREF(0x0078D4)) Example() Func Example() Local $hGUI = GUICreate("DarkTheme TabControl", 400, 300, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP)) GUISetBkColor(0x191919) GUISetFont(10, 300) Local $idTab = GUICtrlCreateTab(20, 20, 360, 260) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM) Local $hTab = GUICtrlGetHandle($idTab) GUICtrlCreateTabItem("tab0") GUICtrlCreateLabel("label0", 30, 80, 300, 60) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x262626) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP) GUICtrlCreateTabItem("tab1") GUICtrlCreateLabel("label1", 30, 80, 300, 60) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x262626) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP) GUICtrlCreateTabItem("tab2") GUICtrlSetState(-1, $GUI_SHOW) GUICtrlCreateLabel("Resize GUI to trigger UpDown controls.", 30, 80, 300, 100) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x262626) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP) GUICtrlCreateTabItem("tab3") GUICtrlCreateLabel("label3", 30, 80, 300, 60) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x262626) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP) GUICtrlCreateTabItem("tab4") GUICtrlCreateLabel("label4", 30, 80, 300, 60) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x262626) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP) GUICtrlCreateTabItem("") ; end tabitem definition ; set DarkMode_DarkTheme visual theme on Tab control as long as OSBuild supports it If _is24H2Plus() Then _WinAPI_SetWindowTheme($hTab, 'DarkMode_DarkTheme') ; get handle for UpDown control to apply theme Local $hUpDown = _WinAPI_FindWindowEx($hTab, "msctls_updown32") If _is24H2Plus() And $hUpDown Then _WinAPI_SetWindowTheme($hUpDown, 'DarkMode_DarkTheme') Local $pAddress = _WinAPI_GetWindowLong($hTab, $GWL_WNDPROC) Local $hSubclass = DllCallbackRegister(_ModernTabProc, "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr") _WinAPI_SetWindowSubclass($hTab, DllCallbackGetPtr($hSubclass), $idTab, $pAddress) ; remove focus rectangle from tab control GUICtrlSendMsg($idTab, $WM_CHANGEUISTATE, 65537, 0) ; lower the Z-order of the tab control (helps fix various issues) _WinAPI_SetWindowPos($hTab, $HWND_BOTTOM, 0, 0, 0, 0, BitOR($SWP_NOMOVE, $SWP_NOREDRAW, $SWP_NOSIZE)) GUISetState() While 1 WinMove($hGUI, "", 400, 300, (30 * Random(1, 10)) + 200) Sleep(10) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _WinAPI_RemoveWindowSubclass($hTab, DllCallbackGetPtr($hSubclass), $idTab) DllCallbackFree($hSubclass) EndFunc ;==>Example Func _ModernTabProc($hWnd, $iMsg, $wParam, $lParam, $iID, $pData) #forceref $iID, $pData Local $iTabCount ;~ ConsoleWrite("- _WinAPI_GetClassName($hWnd) = " & _WinAPI_GetClassName($hWnd) & @CRLF) ;~ _WinAPI_GetClassName($hWnd) = "msctls_updown32" Switch $iMsg Case $WM_ERASEBKGND Return 1 ; Prevent background erase to avoid flicker Case $WM_PAINT Local $tPaint = DllStructCreate($tagPAINTSTRUCT) Local $hDC = _WinAPI_BeginPaint($hWnd, $tPaint) Local $tRect2 = _WinAPI_GetClientRect($hWnd) Local $iW = $tRect2.Right Local $iH = $tRect2.Bottom Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) Local $hOldBmp = _WinAPI_SelectObject($hMemDC, $hBitmap) Local $iUpDownWidth = 0 Local Const $PRF_CHILDREN = 16 Local Const $PRF_CLIENT = 4 _SendMessage($hWnd, $WM_PRINTCLIENT, $hMemDC, BitOR($PRF_CLIENT, $PRF_CHILDREN)) Local $hBrush = _WinAPI_CreateSolidBrush(0x191919) $iTabCount = _GUICtrlTab_GetItemCount($hWnd) If $iTabCount > 0 Then ; determine if tab control contains an UpDown (spin) control Local $hTabUpDown = _WinAPI_FindWindowEx($hWnd, "msctls_updown32") If $hTabUpDown And _WinAPI_IsWindowVisible($hTabUpDown) Then Local $tCR = _WinAPI_GetWindowRect($hTabUpDown) Local $tPR = _WinAPI_GetWindowRect($hWnd) ; get width of UpDown control $iUpDownWidth = $tCR.Right - $tCR.Left ; exclude UpDown control from being painted over DllCall('gdi32.dll', "int", "ExcludeClipRect", "handle", $hDC, "int", $tCR.Left - $tPR.Left, "int", _ $tCR.Top - $tPR.Top - 1, "int", $tCR.Right - $tPR.Left, "int", $tCR.Bottom - $tPR.Top + 2) EndIf ; Draw selection indicator (top border for selected tab) Local $tRect, $iLeft, $iTop, $iRight, $iBottom $iTabCount = _SendMessage($hWnd, $TCM_GETITEMCOUNT, 0, 0) Local $iCurSel = _SendMessage($hWnd, $TCM_GETCURSEL, 0, 0) For $i = 0 To $iTabCount - 1 Local $bSelected = ($i = $iCurSel) If $bSelected Then ; Get tab rectangle using TCM_GETITEMRECT $tRect = DllStructCreate($tagRECT) Local $aResult = DllCall('user32.dll', "lresult", "SendMessageW", _ "hwnd", $hWnd, _ "uint", $TCM_GETITEMRECT, _ "wparam", $i, _ "struct*", $tRect) If @error Or Not $aResult[0] Then ContinueLoop $iLeft = $tRect.Left $iTop = $tRect.Top $iRight = $tRect.Right $iBottom = $tRect.Bottom ;If _GUICtrlTab_HitTest($hWnd, 10, 10)[0] <> 0 Then ConsoleWrite("tab on left is not 0" & @CRLF) ;ConsoleWrite("tab on left: " & _GUICtrlTab_HitTest($hWnd, 10, 10)[0] & @CRLF) ; adjustment for UpDown ;Local $iTabOnLeft = _GUICtrlTab_HitTest($hWnd, 10, 10)[0] If $hTabUpDown And _WinAPI_IsWindowVisible($hTabUpDown) Then Local $iTabOnLeft = _GUICtrlTab_HitTest($hWnd, 10, 10)[0] If $iTabOnLeft <> 0 Then $iRight = $tRect.Right If $iTabOnLeft = 0 And $iCurSel <> 0 Then $iRight = $tRect.Right - 2 ; if tab on left <> selected tab... EndIf ConsoleWrite(@CRLF) ConsoleWrite("$tRect.Left: " & $tRect.Left & @CRLF) ConsoleWrite("$tRect.Top: " & $tRect.Top & @CRLF) ConsoleWrite("$tRect.Right: " & $tRect.Right & @CRLF) ConsoleWrite("$tRect.Bottom: " & $tRect.Bottom & @CRLF) ;If $hTabUpDown And _WinAPI_IsWindowVisible($hTabUpDown) And $i <> 0 Then $iRight = $tRect.Right - 2 ;If $hTabUpDown And _WinAPI_IsWindowVisible($hTabUpDown) And $iTabOnLeft <> 0 Then $iRight = $tRect.Right ; Skip if rectangle is invalid If $iLeft >= $iRight Or $iTop >= $iBottom Then ContinueLoop Local $hPen = $g_hPenAccent Local $hOldPen = _WinAPI_SelectObject($hMemDC, $hPen) _WinAPI_MoveTo($hMemDC, $iLeft - 1, $iTop - 1) _WinAPI_LineTo($hMemDC, $iRight, $iTop - 2) _WinAPI_SelectObject($hMemDC, $hOldPen) EndIf _WinAPI_SelectObject($hMemDC, $hBrush) _WinAPI_ExtFloodFill($hMemDC, $tRect2.right - 1 - $iUpDownWidth, 1, 0xf0f0f0, $FLOODFILLSURFACE) _WinAPI_ExtFloodFill($hMemDC, $tRect2.left + 1, 1, 0xf0f0f0, $FLOODFILLSURFACE) Next _WinAPI_DeleteObject($hBrush) _WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hMemDC, 0, 0, $SRCCOPY) _WinAPI_SelectObject($hMemDC, $hOldBmp) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) _WinAPI_EndPaint($hWnd, $tPaint) EndIf Return 0 Case $WM_PARENTNOTIFY ; Fired when a child window is created inside the tab control. ; The tab spinner (msctls_updown32) is created lazily by Windows when tabs overflow - ; it doesn't exist at init time, so we theme it here the moment it appears. If _WinAPI_LoWord($wParam) = $WM_CREATE Then Local $hNewChild = HWnd($lParam) ; lParam carries the new child's HWND as integer - must cast! If _WinAPI_GetClassName($hNewChild) = "msctls_updown32" Then If _is24H2Plus() Then _WinAPI_SetWindowTheme($hNewChild, 'DarkMode_DarkTheme') EndIf EndIf Return __WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndSwitch Return __WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_ModernTabProc Func _is24H2Plus() ; check if this OS build is Windows 11 24H2/25H2 to support the newer DarkMode_DarkTheme Local $iRevision = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "UBR") Local $b24H2Plus = False If @OSBuild >= 26100 And $iRevision >= 6899 Then $b24H2Plus = True Else ConsoleWrite("Windows 11 24H2/25H2 (build 26100.6899 or higher) is required to use DarkMode_DarkTheme.") EndIf Return $b24H2Plus EndFunc ;==>_is24H2Plus Func _WinAPI_FindWindowEx($hParent, $sClass, $sTitle = "", $hAfter = 0) Local $ret = DllCall('user32.dll', "hwnd", "FindWindowExW", "hwnd", $hParent, "hwnd", $hAfter, "wstr", $sClass, "wstr", $sTitle) If @error Or Not IsArray($ret) Then Return 0 Return $ret[0] EndFunc ;==>_WinAPI_FindWindowEx Func __WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) Return DllCall('comctl32.dll', 'lresult', 'DefSubclassProc', 'hwnd', $hWnd, 'uint', $iMsg, 'wparam', $wParam, _ 'lparam', $lParam)[0] EndFunc ;==>__WinAPI_DefSubclassProc Func _ColorToCOLORREF($iColor) ;RGB to BGR Local $iR = BitAND(BitShift($iColor, 16), 0xFF) Local $iG = BitAND(BitShift($iColor, 8), 0xFF) Local $iB = BitAND($iColor, 0xFF) Return BitOR(BitShift($iB, -16), BitShift($iG, -8), $iR) EndFunc ;==>_ColorToCOLORREF
  12. @water was asking about output from SciTE console from the compilation process especially log for Au3Stripper not the result au3 file. I was confused too, as Water is. As you was asking about helps with your script form here which fires a ton of Au3Check errors and variables names was so short so at first glance I asked about version before stripping. But then I realize what is the problem as I spent many hours on such issues together with my friend @Jos Because of this I already sent the SciTE output to Water, and you should find it on your screen and confirm to Water that this is the same case as you was requested or other one.... but then please send us yours SciTE console output.
  13. finally ??? #include <Array.au3> #include <GUIConstantsEx.au3> #include <GuiTab.au3> Global $hGUI Example() Func Example() $hGUI = GUICreate("My GUI Tab") ; will create a dialog box that when displayed is centered GUISetBkColor(0x00E0FFFF) GUISetFont(9, 300) Local $iTab_main = GUICtrlCreateTab(10, 10, 200, 100) For $IDX = 0 To 10 GUICtrlCreateTabItem("tab" & $IDX) Next GUICtrlCreateTabItem("") ; end tabitem definition GUISetState(@SW_SHOW) _Testing($iTab_main, 10) _GUICtrlTab_ActivateTab($iTab_main, 10) _Testing($iTab_main, 0) Local $idMsg ; Loop until the user exits. While 1 $idMsg = GUIGetMsg() If $idMsg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>Example Func _Testing($iTab_main, $IDX) Local $aPos = ControlGetPos($hGUI, "", "[CLASS:msctls_updown32; INSTANCE:1]") Local $x = $aPos[0] Local $tRECT = _GUICtrlTab_GetItemRectEx($iTab_main, $IDX) ConsoleWrite("l=" & $tRECT.left & @CRLF) ConsoleWrite("r=" & $tRECT.right & @CRLF) ConsoleWrite("t=" & $tRECT.top & @CRLF) ConsoleWrite("b=" & $tRECT.bottom & @CRLF) If $tRECT.right < 0 Or $tRECT.left > $x Then MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, "tab" & $IDX & " is INVISIBLE") Local $aHit = _GUICtrlTab_HitTest($iTab_main, $tRECT.left, $tRECT.top) ConsoleWrite("> " & _ArrayToString($aHit) & @CRLF) EndFunc ;==>_Testing
  14. It is fixed with my mod to the UDF.
  15. to be fine with Au3Stripper DllCallbackRegister() should not use function names as string Local $hMsgProc = DllCallbackRegister("__DM_CBTHookProc", "int", "uint;wparam;lparam") just use functions: Local $hMsgProc = DllCallbackRegister(__DM_CBTHookProc, "int", "uint;wparam;lparam") and here: Local $sTabProcName = $__DM_g_b24H2Plus ? __GUIDarkTheme_ModernTabProc : __GUIDarkTheme_TabProc $__DM_g_hTabProc = DllCallbackRegister($sTabProcName, "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr") but this will still fires warnings so better solutions is to use: If $__DM_g_b24H2Plus Then $__DM_g_hTabProc = DllCallbackRegister(__GUIDarkTheme_ModernTabProc, "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr") Else $__DM_g_hTabProc = DllCallbackRegister(__GUIDarkTheme_TabProc, "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr") EndIf fixed version in attached zip GUIDarkTheme.zip
×
×
  • Create New...