buymeapc Posted December 21, 2017 Posted December 21, 2017 Hi all, I was trying the example from this link in regards to creating tabs with a color behind the tabs themselves. While Yashied's code works great to achieve this, the controls on the tabs seem to be hidden until the mouse cursor hovers over them. What am I missing in order to show the controls on the tabs? expandcollapse popup#include <Constants.au3> #include <GuiTab.au3> #include <TabConstants.au3> #include <WinAPIEx.au3> #include <WindowsConstants.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') GUICtrlCreateButton("Hi", 50, 50, 80); <<<<< Hidden until mouse hovers over it...but why?? 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
LarsJ Posted December 21, 2017 Posted December 21, 2017 This is an old and well known issue. Just replace Return _WinAPI_CallWindowProc($hProc, $hWnd, $iMsg, $wParam, $lParam) with Return DllCall("user32.dll", "lresult", "CallWindowProc", "ptr", $hProc, "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam)[0] Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
buymeapc Posted December 21, 2017 Author Posted December 21, 2017 Hey LarsJ, I've replaced the line as you suggest, but the "Hi" button in my reproducer is still hidden until I hover over it. Also, when I click the other tabs in the example, the button control is hidden again.
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