musicstashall Posted June 27, 2017 Share Posted June 27, 2017 (edited) Hello. Who knows how to make such sliders: Edited June 27, 2017 by musicstashall Link to comment Share on other sites More sharing options...
UEZ Posted June 27, 2017 Share Posted June 27, 2017 (edited) Here an example for the 1st slider: expandcollapse popup;coded by rover / Yashied / UEZ build 2017-06-28 #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <SliderConstants.au3> #include <StructureConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global Const $tagNMCUSTOMDRAW = $tagNMHDR & ';dword DrawStage;handle hDC;long Rect[4];dword_ptr ItemSpec;uint ItemState;lparam ItemlParam' Global $hSlider, $hHBitmap, $hHBitmap2, $bmWidth = 8, $bmHeight = 25, $iWidth = 360, $iHeight = 15, $iXPos = 40 Example() Func Example() _GDIPlus_Startup() Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight), $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap), $hPen = _GDIPlus_PenCreate() _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, 4) Local $h, $RGB For $h = 0 To $iWidth $RGB = HSLToRGB($h / 360, 1, 0.5) _GDIPlus_PenSetColor($hPen, 0xFF000000 + $RGB) _GDIPlus_GraphicsDrawLine($hGfx, $h, 0, $h, $iHeight, $hPen) Next $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_GraphicsDispose($hGfx) Local Const $hBitmap2 = _GDIPlus_BitmapCreateFromScan0($bmWidth, $bmHeight), $hGfx2 = _GDIPlus_ImageGetGraphicsContext($hBitmap), $hBrush = _GDIPlus_BrushCreateSolid() _GDIPlus_GraphicsFillRect($hGfx2, 0, 0, $bmWidth, $bmHeight, $hBrush) $hHBitmap2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap2,0xFF404040) ;slider thumb color _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_GraphicsDispose($hGfx2) _GDIPlus_ImageDispose($hBitmap2) _GDIPlus_ImageDispose($hBitmap) _GDIPlus_Shutdown() GUICreate("HSL Slider", 450, 100) GUISetBkColor(0xFFFFFF) GUICtrlCreateLabel("HSL: ", 15, 18, 25, 20) Local $idSlider = GUICtrlCreateSlider($iXPos, 10, $iWidth + 30, 25, BitOR($TBS_NOTICKS, $TBS_FIXEDLENGTH, $WS_TABSTOP)) GUICtrlSetLimit(-1, 359, 0) ; change max/min value $hSlider = GUICtrlGetHandle($idSlider) GUICtrlSetCursor(-1, 0) GUICtrlSetBkColor(-1, 0xFFFFFF) _SendMessage($hSlider, $TBM_SETTHUMBLENGTH, 2 * $bmHeight - 1, 0) Local $idButton = GUICtrlCreateButton("RGB Value", 75, 70, 70, 20) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) GUICtrlSetData($idSlider, 0) ; set cursor ; Loop until the user exits. Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() _WinAPI_DeleteObject($hHBitmap) _WinAPI_DeleteObject($hHBitmap2) Exit Case $idButton MsgBox($MB_SYSTEMMODAL, "Slider", "RGB color in hex format: " & Hex(HSLToRGB(GUICtrlRead($idSlider) / 360, 1, 0.5), 6), 10) EndSwitch Until False EndFunc ;==>Example Func HSLToRGB($h, $s, $l) If Not $s Then Return BitShift(0xFF * $l, -16) + BitShift(0xFF * $l, -8) + BitShift(0xFF * $l, 0) Local Const $q = $l < 0.5 ? $l * (1 + $s) : $l + $s - $l * $s Local Const $p = 2 * $l - $q Return BitShift(0xFF * HUEtoRGB($p, $q, $h - 0.33333333), -16) + BitShift(0xFF * HUEtoRGB($p, $q, $h), -8) + BitShift(0xFF * HUEtoRGB($p, $q, $h + 0.33333333), 0) EndFunc Func HUEtoRGB($p, $q, $t) If($t < 0) Then $t += 1 If($t > 1) Then $t -= 1 If($t < 0.16666666) Then Return $p + ($q - $p) * 6 * $t If($t < 0.5) Then Return $q If($t < 0.66666666) Then Return $p + ($q - $p) * (0.66666666 - $t) * 6 Return $p EndFunc Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hWndFrom = DllStructGetData($tNMHDR, 'hWndFrom') Local $Code = DllStructGetData($tNMHDR, 'Code') Local $IDFrom = DllStructGetData($tNMHDR, 'IDFrom') Switch $hWndFrom Case $hSlider Switch $Code Case $NM_CUSTOMDRAW Local $tNMCD = DllStructCreate($tagNMCUSTOMDRAW, $lParam) Local $DrawStage = DllStructGetData($tNMCD, 'DrawStage') Local $ItemSpec = DllStructGetData($tNMCD, 'ItemSpec') Local $hDC, $hMemDC, $hPrev Switch $DrawStage Case $CDDS_PREPAINT DllStructSetData($tNMCD, 'ItemState', BitXOR(DllStructGetData($tNMCD, 'ItemState'), $CDIS_FOCUS)) ; Remove focus Rectangle Return $CDRF_NOTIFYITEMDRAW Case $CDDS_ITEMPREPAINT Local $nLeft = DllStructGetData($tNMCD, 'Rect', 1) Local $nTop = DllStructGetData($tNMCD, 'Rect', 2) Local $nRight = DllStructGetData($tNMCD, 'Rect', 3) Local $nBottom = DllStructGetData($tNMCD, 'Rect', 4) Local $nWidth = $nRight - $nLeft Local $nHeight = $nBottom - $nTop $hDC = DllStructGetData($tNMCD, 'hDC') Switch $ItemSpec Case $TBCD_TICS Return $CDRF_SKIPDEFAULT ; draw custom ticks from bitmap or remove tics ;Return $CDRF_DODEFAULT ; draw tics from current theme Case $TBCD_CHANNEL $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hPrev = _WinAPI_SelectObject($hMemDC, $hHBitmap) _WinAPI_BitBlt($hDC, $nLeft + 10, $nTop - 16, $iWidth - 20, $iHeight, $hMemDC, 0, 0, $MERGECOPY) _WinAPI_SelectObject($hMemDC, $hPrev) _WinAPI_DeleteDC($hMemDC) Return $CDRF_SKIPDEFAULT ;custom draw channel with bitmap or remove channel ;Return $CDRF_DODEFAULT ;draw channel from current theme Case $TBCD_THUMB If ($nWidth - $bmWidth) > 0 Then $nLeft += (($nWidth - $bmWidth) / 2) $nWidth = $bmWidth EndIf If ($nHeight - $bmHeight) > 0 Then $nTop += ($nHeight - $bmHeight) / 2 $nHeight = $bmHeight EndIf $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hPrev = _WinAPI_SelectObject($hMemDC, $hHBitmap2) _WinAPI_BitBlt($hDC, $nLeft, $nTop - 10, $nWidth, $nHeight, $hMemDC, 0, 0, $SRCCOPY) _WinAPI_SelectObject($hMemDC, $hPrev) _WinAPI_DeleteDC($hMemDC) Return $CDRF_SKIPDEFAULT ;custom draw thumb with bitmap EndSwitch EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY You have to do some adjustments in WM_NOTIFY function when you modify the slider settings! Edited June 28, 2017 by UEZ musicstashall, Danyfirex, Zedna and 1 other 4 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
musicstashall Posted July 1, 2017 Author Share Posted July 1, 2017 Super! Thank you Link to comment Share on other sites More sharing options...
musicstashall Posted July 1, 2017 Author Share Posted July 1, 2017 (edited) How can I adjust the width of the color bar?? Yes, I understood everything. : _WinAPI_BitBlt($hDC, $nLeft + 10, $nTop - 16, $iWidth - 20, $iHeight - 10, $hMemDC, 0, 0, $MERGECOPY) It would be desirable, that the slider on color and the form corresponded to system. Or the engine, or the handle ..., as correctly in English Edited July 1, 2017 by musicstashall Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now