Nein, ich glaube ich weiß welchen Thread Du meinst, erinnere mich aber auch nicht mehr an den Titel.
Brauchst Dich aber nicht weiter anstrengen ... ![]()
Spoiler anzeigen
#include-once
[/autoit] [autoit][/autoit] [autoit]#include <Constants.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
OnAutoItExitRegister ("AppExit")
[/autoit] [autoit][/autoit] [autoit]; --- $DRAWITEMSTRUCT
Global Const $DRAWITEMSTRUCT = _
'uint CtlType;'& _
'uint CtlID;'& _
'uint itemID;'& _
'uint itemAction;'& _
'uint itemState;'& _
'hwnd hwndItem;'& _
'ptr hDC;'& _
'long rcItem[4];'& _
'ulong_ptr itemData;'
Global Enum $PBS_NORMAL = 1, _
$PBS_HOT, _
$PBS_PRESSED, _
$PBS_DISABLED, _
$PBS_DEFAULTED, _
$PBS_DEFAULTED_ANIMATING
Global Const $BP_PUSHBUTTON = 1
[/autoit] [autoit][/autoit] [autoit]Global $g_hTheme
Global $g_hThemeLib
Global $g_hButtonProc
Global $g_bMouseHover = False
Global $ID_BUTTON_0
Global $ID_BUTTON_1
;««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
[/autoit] [autoit][/autoit] [autoit]$g_hThemeLib = DllOpen ("uxtheme.dll")
If ($g_hThemeLib == -1) Then
ConsoleWrite ("! g_hThemeLib = "&$g_hThemeLib & @crlf)
Else
MainDlg ( )
EndIf
Exit (0)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func MainDlg ( )
[/autoit] [autoit][/autoit] [autoit]Local $hWnd
Local $hwndButton_1
$hWnd = GUICreate ("Themed Ownerdraw Demo", 400, 300)
[/autoit] [autoit][/autoit] [autoit]$ID_BUTTON_1 = GUICtrlCreateButton ("Ownerdraw", 25, 85, 350, 90)
$ID_BUTTON_0 = GUICtrlCreateButton ("Standard", 25, 185, 350, 90)
GUICtrlSetStyle ($ID_BUTTON_1, BitOR($WS_TABSTOP, $BS_NOTIFY, $BS_OWNERDRAW))
GUICtrlSetTip ($ID_BUTTON_1, "Selbstgezeichnete Schaltfläche")
$hwndButton_1 = GUICtrlGetHandle ($ID_BUTTON_1)
$g_hTheme = OpenThemeData ($hwndButton_1, "Button")
;~ $g_hButtonProc = DllCallbackRegister ("ButtonWndProc", "long", "hwnd;uint;long;long")
[/autoit] [autoit][/autoit] [autoit]GUIRegisterMsg ($WM_DRAWITEM, "WM_DRAWITEM")
GUIRegisterMsg ($WM_MOUSEMOVE, "WM_MOUSEMOVE")
GUISetState (5, $hWnd)
[/autoit] [autoit][/autoit] [autoit]While True
[/autoit] [autoit][/autoit] [autoit]Switch GUIGetMsg ( )
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
EndFunc
[/autoit] [autoit][/autoit] [autoit]Func WM_DRAWITEM ($hwnd, $message, $wParam, $lParam)
[/autoit] [autoit][/autoit] [autoit]Local Const $ODA_DRAWENTIRE = 0x0001
Local Const $ODA_SELECT = 0x0002
Local Const $ODA_FOCUS = 0x0004
Local Const $ODS_SELECTED = 0x0001
Local Const $ODS_GRAYED = 0x0002
Local Const $ODS_DISABLED = 0x0004
Local Const $ODS_CHECKED = 0x0008
Local Const $ODS_FOCUS = 0x0010
Local Const $ODS_HOTLIGHT = 0x0040
Local Const $ODS_INACTIVE = 0x0080
Local Const $ODS_NOACCEL = 0x0100
Local Const $ODS_NOFOCUSRECT = 0x0200
Local $dis = DllStructCreate ($DRAWITEMSTRUCT, $lParam)
Local $hDC = DllStructGetData ($dis, "hDC")
Local $hwndItem = DllStructGetData ($dis, "hwndItem")
Local $nItemAction = DllStructGetData ($dis, "itemAction")
Local $nItemState = DllStructGetData ($dis, "itemState")
Local $lprcItem = DllStructGetPtr ($dis, ![]()
Local $bChecked = BitAND($nItemState, $ODS_CHECKED)
Local $bFocused = BitAND($nItemState, $ODS_FOCUS)
Local $bGrayed = BitAND($nItemState, BitOR($ODS_GRAYED, $ODS_DISABLED))
Local $bSelected = BitAND($nItemState, $ODS_SELECTED)
Local $sFormat = "> WM_DRAWITEM (%#x, %d, %#x, %#x)"
[/autoit] [autoit][/autoit] [autoit]ConsoleWrite (StringFormat ($sFormat, $hwnd, $message, $wParam, $lParam) & @crlf)
ConsoleWrite ("> CtlType = "&DllStructGetData ($dis, 1) & @crlf)
ConsoleWrite ("> CtlID = "&DllStructGetData ($dis, 2) & @crlf)
ConsoleWrite ("> itemID = "&DllStructGetData ($dis, 3) & @crlf)
ConsoleWrite ("> itemAction = "&DllStructGetData ($dis, 4) & @crlf)
ConsoleWrite ("> itemState = "&Ptr (DllStructGetData ($dis, 5)) & @crlf)
ConsoleWrite ("> hwndItem = "&DllStructGetData ($dis, 6) & @crlf)
ConsoleWrite ("> hDC = "&DllStructGetData ($dis, 7) & @crlf)
ConsoleWrite ("> rcItem.left = "&DllStructGetData ($dis, 8, 1) & @crlf)
ConsoleWrite ("> rcItem.top = "&DllStructGetData ($dis, 8, 2) & @crlf)
ConsoleWrite ("> rcItem.right = "&DllStructGetData ($dis, 8, 3) & @crlf)
ConsoleWrite ("> rcItem.bottom = "&DllStructGetData ($dis, 8, 4) & @crlf)
ConsoleWrite ("> itemData = "&DllStructGetData ($dis, 9) & @crlf)
ConsoleWrite ("--------------------" & @crlf)
[/autoit] [autoit][/autoit] [autoit]If ($nItemAction == $ODA_DRAWENTIRE) Then
[/autoit] [autoit][/autoit] [autoit]If ($bFocused) Then
If ($bSelected) Then
DrawControlTheme ($hDC, $lprcItem, $hwndItem, $g_hTheme, $PBS_PRESSED)
Else
DrawControlTheme ($hDC, $lprcItem, $hwndItem, $g_hTheme, $PBS_DEFAULTED)
EndIf
InflateRect ($lprcItem, -3, -3)
DrawFocusRect ($hDC, $lprcItem)
Else
DrawControlTheme ($hDC, $lprcItem, $hwndItem, $g_hTheme, $PBS_NORMAL)
EndIf
ElseIf ($nItemAction == $ODA_FOCUS) Then
[/autoit] [autoit][/autoit] [autoit]If ($bFocused) Then
DrawControlTheme ($hDC, $lprcItem, $hwndItem, $g_hTheme, $PBS_DEFAULTED)
EndIf
If ($bSelected) Then
DrawControlTheme ($hDC, $lprcItem, $hwndItem, $g_hTheme, $PBS_PRESSED)
EndIf
InflateRect ($lprcItem, -3, -3)
DrawFocusRect ($hDC, $lprcItem)
EndIf
Return 1
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func WM_MOUSEMOVE ($hwnd, $message, $wParam, $lParam)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func AppExit ( )
[/autoit] [autoit][/autoit] [autoit]if ($g_hThemeLib) then
if ($g_hTheme) then
CloseThemeData ($g_hTheme)
endif
DllClose ($g_hThemeLib)
endif
if ($g_hButtonProc) then
DllCallbackFree ($g_hButtonProc)
endif
EndFunc
;««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
Func DrawControlTheme ($hDC, $lprect, $hwndButton, $hTheme, $iState)
[/autoit] [autoit][/autoit] [autoit]Local $rc = DllStructCreate ("long;long;long;long", $lprect)
Local $rcContent = DllStructCreate ("long;long;long;long")
Local $szButtonText
Local $hr
Local $cch
$szButtonText = WinGetTitle ($hwndButton)
$cch = StringLen ($szButtonText)
if ($hTheme) then
[/autoit] [autoit][/autoit] [autoit]$hr = DrawThemeBackground ($hTheme, $hDC, $BP_PUSHBUTTON, _
$iState, DllStructGetPtr ($rc), 0)
$hr = GetThemeBackgroundContentRect ($hTheme, $hDC, _
$BP_PUSHBUTTON, $iState, DllStructGetPtr ($rc), DllStructGetPtr ($rcContent))
$hr = DrawThemeText ($hTheme, $hDC, $BP_PUSHBUTTON, $iState, _
$szButtonText, $cch, _
BitOR ($DT_CENTER, $DT_VCENTER, $DT_SINGLELINE), _
0, DllStructGetPtr ($rcContent))
endif
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit];««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
[/autoit] [autoit][/autoit] [autoit]Func InflateRect ($lprc, $dx, $dy)
[/autoit] [autoit][/autoit] [autoit]Local $aRes = DllCall ('user32.dll', 'int', 'InflateRect', _
'ptr', $lprc, _ ; rectangle
'int', $dx, _ ; amount to adjust width
'int', $dy) ; amount to adjust height
If @error Then _
Return @error
Return $aRes[0]
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func InvalidateRect ($hWnd, $lpRect, $bErase)
[/autoit] [autoit][/autoit] [autoit]Local $aRes = DllCall ('user32.dll', 'int', 'InvalidateRect', _
'hwnd', $hWnd, _ ; handle to window
'ptr', $lpRect, _ ; rectangle coordinates
'int', $bErase) ; erase state
If @error Then _
Return @error
Return $aRes[0]
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func DrawFocusRect ($hDC, $lprc)
[/autoit] [autoit][/autoit] [autoit]Local $aRes = DllCall ('user32.dll', 'int', 'DrawFocusRect', _
'ptr', $hDC, _ ; handle to device context
'ptr', $lprc) ; logical coordinates
If @error Then _
Return @error
Return $aRes[0]
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit];««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
[/autoit] [autoit][/autoit] [autoit]Func CloseThemeData ($hTheme)
[/autoit] [autoit][/autoit] [autoit]Local $aRes = DllCall ($g_hThemeLib, 'long', 'CloseThemeData', _
'ptr', $hTheme)
If @error Then _
Return @error
Return $aRes[0]
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func OpenThemeData ($hwnd, $pszClassList)
[/autoit] [autoit][/autoit] [autoit]Local $aRes = DllCall ($g_hThemeLib, 'ptr', 'OpenThemeData', _
'hwnd', $hwnd, _
'wstr', $pszClassList)
If @error Then _
Return @error
Return $aRes[0]
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func DrawThemeBackground ($hTheme, $hdc, $iPartId, $iStateId, $pRect, $pClipRect)
[/autoit] [autoit][/autoit] [autoit]Local $aRes = DllCall ($g_hThemeLib, 'long', 'DrawThemeBackground', _
'ptr', $hTheme, _
'ptr', $hdc, _
'int', $iPartId, _
'int', $iStateId, _
'ptr', $pRect, _
'ptr', $pClipRect)
If @error Then _
Return @error
Return $aRes[0]
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func DrawThemeEdge ($hTheme, $hdc, $iPartId, $iStateId, $pDestRect, $uEdge, $uFlags, $pContentRect)
[/autoit] [autoit][/autoit] [autoit]Local $aRes = DllCall ($g_hThemeLib, 'long', 'DrawThemeEdge', _
'ptr', $hTheme, _
'ptr', $hdc, _
'int', $iPartId, _
'int', $iStateId, _
'ptr', $pDestRect, _
'uint', $uEdge, _
'uint', $uFlags, _
'ptr', $pContentRect)
If @error Then _
Return @error
Return $aRes[0]
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func DrawThemeText ($hTheme, $hdc, $iPartId, $iStateId, $pszText, $iCharCount, $dwTextFlags, $dwTextFlags2, $pRect)
[/autoit] [autoit][/autoit] [autoit]Local $aRes = DllCall ($g_hThemeLib, 'long', 'DrawThemeText', _
'ptr', $hTheme, _
'ptr', $hdc, _
'int', $iPartId, _
'int', $iStateId, _
'wstr', $pszText, _
'int', $iCharCount, _
'dword', $dwTextFlags, _
'dword', $dwTextFlags2, _
'ptr', $pRect)
If @error Then _
Return @error
Return $aRes[0]
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func GetThemeBackgroundContentRect ($hTheme, $hdc, $iPartId, $iStateId, $pBoundingRect, $pContentRect)
[/autoit] [autoit][/autoit] [autoit]Local $aRes = DllCall ($g_hThemeLib, 'long', 'GetThemeBackgroundContentRect', _
'ptr', $hTheme, _
'ptr', $hdc, _
'int', $iPartId, _
'int', $iStateId, _
'ptr', $pBoundingRect, _
'ptr', $pContentRect)
If @error Then _
Return @error
Return $aRes[0]
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit];««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit]Gruß
Greenhorn