#Include <Constants.au3>
#Include <GUIConstantsEx.au3>
#Include <SliderConstants.au3>
#Include <StaticConstants.au3>
#Include <WinAPI.au3>
#Include <WindowsConstants.au3>
Global Const $tagNMCUSTOMDRAW = 'hwnd hWndFrom;uint_ptr IDFrom;int Code;dword DrawStage;hwnd hDC;' & $tagRECT & ';dword_ptr ItemSpec;uint ItemState;lparam ItemlParam'
Global Const $STM_GETIMAGE = 0x0173
Global $hTemp = 0
GUICreate('MyGUI', 413, 161)
GUICtrlCreatePic(@DesktopDir & '\1.jpg', 0, 0, 413, 161)
GUICtrlSetState(-1, $GUI_DISABLE)
$hPic = GUICtrlGetHandle(-1)
GUICtrlCreateSlider(200, 100, 200, 23, $TBS_NOTICKS)
$hSlider = GUICtrlGetHandle(-1)
GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
GUISetState()
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
Local $tNMCD = DllStructCreate($tagNMCUSTOMDRAW, $lParam)
Local $hWndFrom = DllStructGetData($tNMCD, 'hWndFrom')
Local $Code = DllStructGetData($tNMCD, 'Code')
Local $DrawStage = DllStructGetData($tNMCD, 'DrawStage')
Local $ItemSpec = DllStructGetData($tNMCD, 'ItemSpec')
Local $hDC = DllStructGetData($tNMCD, 'hDC')
Local $hMemDC, $hBitmap, $hPrev
Local $aPos
Switch $hWndFrom
Case $hSlider
Switch $Code
Case $NM_CUSTOMDRAW
Switch $DrawStage
Case $CDDS_PREPAINT, $CDDS_POSTPAINT
$aPos = ControlGetPos($hSlider, '', '')
Switch $DrawStage
Case $CDDS_PREPAINT
$hMemDC = _WinAPI_CreateCompatibleDC($hDC)
$hBitmap = _SendMessage($hPic, $STM_GETIMAGE, $IMAGE_BITMAP, 0)
$hPrev = _WinAPI_SelectObject($hMemDC, $hBitmap)
_WinAPI_BitBlt($hDC, 0, 0, $aPos[2], $aPos[3], $hMemDC, $aPos[0], $aPos[1], $SRCCOPY)
_WinAPI_SelectObject($hMemDC, $hPrev)
_WinAPI_DeleteDC($hMemDC)
DllStructSetData($tNMCD, 'ItemState', BitXOR(DllStructGetData($tNMCD, 'ItemState'), $CDIS_FOCUS))
Return BitOR($CDRF_NOTIFYITEMDRAW, $CDRF_NOTIFYPOSTPAINT)
Case $CDDS_POSTPAINT
$hMemDC = _WinAPI_CreateCompatibleDC($hDC)
If Not $hTemp Then
$hTemp = _WinAPI_CreateCompatibleBitmap($hDC, $aPos[2], $aPos[3])
$hPrev = _WinAPI_SelectObject($hMemDC, $hTemp)
_WinAPI_BitBlt($hMemDC, 0, 0, $aPos[2], $aPos[3], $hDC, 0, 0, $MERGECOPY)
Else
$hMemDC = _WinAPI_CreateCompatibleDC($hDC)
$hPrev = _WinAPI_SelectObject($hMemDC, $hTemp)
_WinAPI_BitBlt($hDC, 0, 0, $aPos[2], $aPos[3], $hMemDC, 0, 0, $SRCCOPY)
EndIf
_WinAPI_SelectObject($hMemDC, $hPrev)
_WinAPI_DeleteDC($hMemDC)
Return $CDRF_DODEFAULT
EndSwitch
Case $CDDS_ITEMPREPAINT
If $hTemp Then
_WinAPI_DeleteObject($hTemp)
$hTemp = 0
EndIf
Switch $ItemSpec
Case $TBCD_TICS
Return $CDRF_SKIPDEFAULT
Case $TBCD_THUMB, $TBCD_CHANNEL
Return $CDRF_DODEFAULT
EndSwitch
EndSwitch
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
|