$nCtlType = DllStructGetData($stDrawItem, 1) If $nCtlType = $ODT_BUTTON Then $nCtrlID = DllStructGetData($stDrawItem, 2) $nItemState = DllStructGetData($stDrawItem, 5) $hCtrl = DllStructGetData($stDrawItem, 6) $hDC = DllStructGetData($stDrawItem, 7) $nLeft = DllStructGetData($stDrawItem, 8, 1) $nTop = DllStructGetData($stDrawItem, 8, 2) $nRight = DllStructGetData($stDrawItem, 8, 3) $nBottom = DllStructGetData($stDrawItem, 8, 4) $sText = "Ownerdrawn Button" $nTextColor = 0x5555DD $nBackColor = 0xFFEEDD DrawButton($hWnd, $hCtrl, $hDC, $nLeft, $nTop, $nRight, $nBottom, $nItemState, $sText, $nTextColor, $nBackColor) $stDrawItem = 0 Return 1 EndIf $stDrawItem = 0 Return $GUI_RUNDEFMSG ; Proceed the default Autoit3 internal message commands EndFunc ;==>MY_WM_DRAWITEM ; The main drawing procedure Func DrawButton($hWnd, $hCtrl, $hDC, $nLeft, $nTop, $nRight, $nBottom, $nItemState, $sText, $nTextColor, $nBackColor) ;Local $bDefault = FALSE Local Const $GWL_STYLE = -16 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 Const $DFC_BUTTON = 4 Local Const $DFCS_BUTTONPUSH = 0x0010 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) $stRect = DllStructCreate("int;int;int;int") DllStructSetData($stRect, 1, $nLeft) DllStructSetData($stRect, 2, $nTop) DllStructSetData($stRect, 3, $nRight) DllStructSetData($stRect, 4, $nBottom) If $bGrayed Then $nClrTxt = SetTextColor($hDC, GetSysColor($COLOR_HIGHLIGHTTEXT)) ElseIf $nTextColor = -1 Then $nClrTxt = SetTextColor($hDC, GetSysColor($COLOR_BTNTEXT)) Else $nClrTxt = SetTextColor($hDC, $nTextColor) EndIf If $nBackColor = -1 Then $hBrush = GetSysColorBrush($COLOR_BTNFACE) $nClrSel = GetSysColor($COLOR_BTNFACE) Else $hBrush = CreateSolidBrush($nBackColor) $nClrSel = $nBackColor; EndIf $nClrBk = SetBkColor($hDC, $nClrSel) $hOldBrush = SelectObject($hDC, $hBrush) $nTmpLeft = $nLeft $nTmpTop = $nTop $nTmpRight = $nRight $nTmpBottom = $nBottom If $bSelected Then InflateRect($nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, -1, -1) $hBrushSel = CreateSolidBrush(GetSysColor($COLOR_BTNSHADOW)) FrameRect($hDC, $nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, $hBrushSel) DeleteObject($hBrushSel) Else If $bFocused And Not $bSelected Then InflateRect($nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, -1, -1) DrawFrameControl($hDC, $nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, $DFC_BUTTON, $DFCS_BUTTONPUSH) EndIf $nTmpLeft = $nLeft $nTmpTop = $nTop $nTmpRight = $nRight $nTmpBottom = $nBottom If $bSelected Then InflateRect($nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, -2, -2) Else If $bFocused And Not $bSelected Then InflateRect($nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, -3, -3) $nTmpLeft -= 1 $nTmpTop -= 1 Else InflateRect($nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, -2, -2) $nTmpLeft -= 1 $nTmpTop -= 1 EndIf EndIf FillRect($hDC, $nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, $hBrush) If $bSelected Or $bGrayed Then $nTmpLeft = $nTmpLeft + 2 $nTmpTop = $nTmpTop + 2 EndIf $uFlags = BitOR($DT_NOCLIP, $DT_CENTER, $DT_VCENTER) If Not BitAND(GetWindowLong($hCtrl, $GWL_STYLE), $BS_MULTILINE) Then $uFlags = BitOR($uFlags, $DT_SINGLELINE) DrawText($hDC, $sText, $nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, $uFlags) If $bGrayed Then $nTmpLeft = $nLeft $nTmpTop = $nTop $nTmpRight = $nRight $nTmpBottom = $nBottom $nTmpLeft -= 1 $nClrTxt = SetTextColor($hDC, GetSysColor($COLOR_GRAYTEXT)) DrawText($hDC, $sText, $nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, BitOR($DT_NOCLIP, $DT_CENTER, $DT_VCENTER, $DT_SINGLELINE)) EndIf $nTmpLeft = $nLeft $nTmpTop = $nTop $nTmpRight = $nRight $nTmpBottom = $nBottom If $bFocused Then $hBrush = CreateSolidBrush(0) FrameRect($hDC, $nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, $hBrush) $nTmpLeft = $nLeft $nTmpTop = $nTop $nTmpRight = $nRight $nTmpBottom = $nBottom InflateRect($nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, -4, -4) DrawFocusRect($hDC, $nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom) EndIf SelectObject($hDC, $hOldBrush) DeleteObject($hBrush) SetTextColor($hDC, $nClrTxt) SetBkColor($hDC, $nClrBk) Return 1 EndFunc ;==>DrawButton ; Some graphic / windows functions Func CreateSolidBrush($nColor) Local $hBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $nColor) Return $hBrush[0] EndFunc ;==>CreateSolidBrush Func GetSysColor($nIndex) Local $nColor = DllCall("user32.dll", "int", "GetSysColor", "int", $nIndex) Return $nColor[0] EndFunc ;==>GetSysColor Func GetSysColorBrush($nIndex) Local $hBrush = DllCall("user32.dll", "hwnd", "GetSysColorBrush", "int", $nIndex) Return $hBrush[0] EndFunc ;==>GetSysColorBrush Func DrawFrameControl($hDC, $nLeft, $nTop, $nRight, $nBottom, $nType, $nState) Local $stRect = DllStructCreate("int;int;int;int") DllStructSetData($stRect, 1, $nLeft) DllStructSetData($stRect, 2, $nTop) DllStructSetData($stRect, 3, $nRight) DllStructSetData($stRect, 4, $nBottom) DllCall("user32.dll", "int", "DrawFrameControl", "hwnd", $hDC, "ptr", . $stDrawItem = 0 Return 1 EndIf $stDrawItem = 0 Return $GUI_RUNDEFMSG ; Proceed the default Autoit3 internal message commands EndFunc ;==>MY_WM_DRAWITEM ; The main drawing procedure