Ich habe eine Gui mit Hintergrundbild und 3 Tabs. Wenn ich einen Button erstelle im 1. Tab, dann bleibt er wenn ich in den 2. bzw. 3. wechsel da. Im 2. und 3. kann ich ihn erst gar nicht erstellen.
Was muss ich ändern?
Spoiler anzeigen
#include <Constants.au3>
#include <GuiTab.au3>
#include <TabConstants.au3>
#include <WinAPIEx.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
[/autoit] [autoit][/autoit] [autoit]Global Const $STM_GETIMAGE = 0x0173
Global Const $PRF_CLIENT = 0x04
Global $hPic, $hTab, $hDll, $pDll, $hProc
[/autoit] [autoit][/autoit] [autoit]GUICreate('MyGUI', 300, 300)
GUICtrlCreatePic(@ScriptDir & '\Tech.bmp', 0, 0, 300, 300, $WS_CLIPCHILDREN)
$hPic = GUICtrlGetHandle(-1)
GUICtrlCreateTab(20, 20, 262, 261, $TCS_FOCUSONBUTTONDOWN)
$hTab = GUICtrlGetHandle(-1)
GUICtrlCreateTabItem('Tab 1')
GUICtrlCreateButton("",100,100,20,20)
GUICtrlCreateTabItem('Tab 2')
GUICtrlCreateTabItem('Tab 3')
GUICtrlCreateTabItem('')
$hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam')
$pDll = DllCallbackGetPtr($hDll)
$hProc = _WinAPI_SetWindowLongEx($hTab, $GWL_WNDPROC, $pDll)
_WinAPI_SetParent($hTab, $hPic)
[/autoit] [autoit][/autoit] [autoit]OnAutoItExitRegister('AutoItExit')
[/autoit] [autoit][/autoit] [autoit]GUISetState()
[/autoit] [autoit][/autoit] [autoit]Do
Until GUIGetMsg() = -3
Func _CreateClipRgn($hWnd)
[/autoit] [autoit][/autoit] [autoit]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)
Local Const $WM_PRINTCLIENT = 0x0318
If _WinAPI_IsThemeActive() Then
Switch $iMsg
Case $WM_ERASEBKGND
Local $tRect[2]
Local $hParent = _WinAPI_GetParent($hWnd)
Local $hRgn = _CreateClipRgn($hWnd)
Local $hPrev = _WinAPI_GetClipRgn($wParam)
$tRect[0] = _WinAPI_GetWindowRect($hParent)
$tRect[1] = _WinAPI_GetWindowRect($hWnd)
_WinAPI_ExtSelectClipRgn($wParam, $hRgn, $RGN_DIFF)
_WinAPI_DrawBitmap($wParam, DllStructGetData($tRect[0], 1) - DllStructGetData($tRect[1], 1), DllStructGetData($tRect[0], 2) - DllStructGetData($tRect[1], 2), _SendMessage($hParent, $STM_GETIMAGE))
_WinAPI_SelectClipRgn($wParam, $hPrev)
_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_SetWindowLongEx($hTab, $GWL_WNDPROC, $hProc)
DllCallbackFree($hDll)
EndFunc ;==>AutoItExit