Что нового

Наложить цвет на ScrollBar

Viktor1703

AutoIT Гуру
Сообщения
1,535
Репутация
413
Не могу наложить цвет на ScrollBar хотя делал всё по примеру, правдо пример на PureBasic'e, что я делаю не так?

Код:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPIEx.au3>
#Include <UDFGlobalID.au3>

$hForm = GUICreate("ControlScroll", 400, 300)
$iScroll = GUIControlScroll_Create($hForm, 20, 20, 15, 200, True, 1)
GUISetState()
 
$sColor = DllStructCreate("dword Face;dword Highlight;dword Light3D;dword Shadow;dword DkShadow;dword Shape;dword ShapeClick;dword Arrow")
DllStructSetData($sColor, "Face", _WinAPI_RGB(255,191,0))
DllStructSetData($sColor, "Highlight", _WinAPI_RGB(255,227,145))
DllStructSetData($sColor, "Light3D", _WinAPI_RGB(255,191,0))
DllStructSetData($sColor, "Shadow", _WinAPI_RGB(234,147,0))
DllStructSetData($sColor, "DkShadow", _WinAPI_RGB(170,106,0))
DllStructSetData($sColor, "Shape", _WinAPI_RGB(255,227,145))
DllStructSetData($sColor, "ShapeClick", _WinAPI_RGB(255,191,0))
DllStructSetData($sColor, "Arrow", _WinAPI_RGB(149,74,0))

$hDC = _WinAPI_BeginPaint($iScroll, $sColor)
$hDCMem = _WinAPI_CreateCompatibleDC($hDC)
$hDmOutput = DllCall('gdi32.dll', 'hwnd', 'CreateCompatibleBitmap', 'hwnd', $hDC, 'int', 15, 'int', 200)
_WinAPI_SelectObject($hDCMem, $hDmOutput[0])
$hbrBackshape = _WinAPI_CreateSolidBrush(DllStructGetData($sColor, "Face"))
$tRECT = _WinAPI_CreateRect(20, 20, 15, 200)
_WinAPI_FillRect($hDCMem, DllStructGetPtr($tRECT), $hbrBackshape)
_WinAPI_DeleteObject($hbrBackshape)

$hPenFace = _WinAPI_CreatePen($PS_SOLID, 1, DllStructGetData($sColor, "Face"))
$hbrFace = _WinAPI_CreateSolidBrush(DllStructGetData($sColor, "Face"))
_WinAPI_SelectObject($hDCMem, $hPenFace)
_WinAPI_SelectObject($hDCMem, $hbrFace)
$tRECT = _WinAPI_CreateRect(20 + 2, 20 + 2, 20 + 15 - 2, 20 + 200 - 2)
_WinAPI_Rectangle($hDCMem, $tRECT)
_WinAPI_DeleteObject($hPenFace)
_WinAPI_DeleteObject($hbrFace)

While 1
	_WinAPI_BitBlt($hDC, 0, 0, 15, 200, $hDCMem, 17, 1, 1)
    If GUIGetMsg() = -3 Then Exit
WEnd
	
_WinAPI_DeleteDC($hDCMem)
_WinAPI_DeleteObject($hDmOutput[0])

Func GUIControlScroll_Create($hWnd, $iX, $iY, $iWidth = -1, $iHeight = -1, $iTheme = False, $iStyle = 0, $iExStyle = 0)
	If $iTheme = True Then DllCall('uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 0)
    Local $hStyle = BitOR($iStyle, $WS_CHILD, $WS_VISIBLE)
	Local $hModule = DllCall("kernel32.dll", "handle", "GetModuleHandleW", "ptr", 0)
	If @error Then Return SetError(@error, @extended, 0)
	Local $hControl = DllCall("user32.dll", "hwnd", "CreateWindowExW", "dword", $iExStyle, "wstr", "Scrollbar", _
	                                        "wstr", "", "dword", $hStyle, "int", $iX, "int", $iY, _
											"int", $iWidth, "int", $iHeight, "hwnd", $hWnd, _
											"handle", __UDF_GetNextGlobalID($hWnd), "handle", $hModule[0], "ptr", 0)
	If @error Then Return SetError(@error, @extended, 0)
	If $iTheme = True Then DllCall('uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 7)
    Return $hControl[0]
EndFunc
 
Верх