At the picture below you can see what I've already done. Left scrollbar is a system scrollbar, right one - custom scrollbar.
FVertBar: Boolean; FPressedBtn1, FPressedBtn2, FSelectedBtn1, FSelectedBtn2: Boolean; FBarBmp, FBtn1Bmp, FBtn2Bmp: TBitmap; MainDC: hDC;
FBarBmp.Free; FBtn1Bmp.Free; FBtn2Bmp.Free;
Case WM_ENABLE ' WM_SHOWWINDOW
Width=100
Height=80
FSelectedBtn1=false
FSelectedBtn2=false
FPressedBtn1=false
FPressedBtn2=false
(FBarBmp=LoadImageA(0,"D:\...bmp",0,16,16,&H10
=FBtn1Bmp
=FBtn2Bmp
Case WM_DESTROY
DeleteObject FBarBmp
DeleteObject FBtn1Bmp
DeleteObject FBtn2Bmp
Case WM_NCCALCIZE
decrease width to create non-client area'
(Dec(Message.CalcSize_Params.rgrc(0).Right,17
FVertBar= true
Case WM_NCPAINT
(MainDC=GetWindowDC(Hwnd
(if FVertBar then PaintScrollBarVert(MainDC
if FVertBar then
PaintButtonVert1 MainDC
PaintButtonVert2 MainDC
End if
Enf if
ReleaseDC Handle, MainDC
Case WM_NCMOUSEMOVE
GetCursorPos pt
ScreenToClient hwnd,pt
Top Vert Button'
(Rect(Width - 17 - 2, ClientRect.Top, Width - 2, 17
if PtInRect(Crect,pt) then
FSelectedBtn1= true
else
FSelectedBtn1=false
End If
bottom vert button '
Rect(Width - 17 - 2, ClientRect.Bottom - 17, Width - 2,
(ClientRect.Bottom + 17,
if PtInRect(Crect,pt) then
FSelectedBtn2=true
else
FSelectedBtn2=false
End if
SendMessageA hwnd,WM_NCPAINT,1, 0
Cas WM_NCLBUTTONDOWN
GetCursorPos pt
ScreenToClient hwnd,pt
'Top Vert Button
Rect(Width - 17 - 2, ClientRect.Top, Width - 2, 17)
if PtInRect(Crect,pt) then
FPressedBtn1=true
End If
'bottom vert button
Rect(Width - 17 - 2, ClientRect.Bottom - 17, Width - 2, ClientRect.Bottom + 17)
if PtInRect(Crect,pt) then
FPressedBtn2=true
End if
SendMessageA hwnd,WM_NCPAINT,1, 0
Case WM_NCLBUTTONUP
FPressedBtn1=false
FPressedBtn2 =false
SendMessageA hwnd,WM_NCPAINT,1, 0
(PaintScrollBarVert(hDC
FBarBmp.Width= 17
FBarBmp.Height=ClientRect.Bottom
FBarBmp.Canvas.Brush.Color=clLime FBarBmp.Canvas.FillRect(FBarBmp.Canvas.ClipRect)
BitBlt(MainDC,Width-17-2,ClientRect.Top + 2,FBarBmp.Width,FBarBmp.Height, FBarBmp.Canvas.Handle,0, 0,SRCCOPY)
(PaintButtonVert1(hDC
FBtn1Bmp.Width=17
FBtn1Bmp.Height=17
if not FSelectedBtn1 then FBtn1Bmp.Canvas.Brush.Color=clRed
End if
if FSelectedBtn1 then FBtn1Bmp.Canvas.Brush.Color =clBlue
End if
if FSelectedBtn1 and FPressedBtn1 then FBtn1Bmp.Canvas.Brush.Color=clPurple
FBtn1Bmp.Canvas.FillRect(FBtn1Bmp.Canvas.ClipRect)
BitBlt(DC, Width - 17 - 2, ClientRect.Top + 2, FBtn1Bmp.Width, FBtn1Bmp.Height, FBtn1Bmp.Canvas.Handle, 0, 0, SRCCOPY)
End if
(PaintButtonVert2(hDC
FBtn2Bmp.Width=17
FBtn2Bmp.Height=17
if not FSelectedBtn2 then FBtn1Bmp.Canvas.Brush.Color=clRed
End if
if FSelectedBtn2 then FBtn1Bmp.Canvas.Brush.Color=clBlue
End if
if FSelectedBtn2 and FPressedBtn2 then FBtn1Bmp.Canvas.Brush.Color=clPurple
FBtn1Bmp.Canvas.FillRect(FBtn1Bmp.Canvas.ClipRect)
BitBlt(DC, Width - 17 - 2, ClientRect.Bottom - 17 + 2, FBtn1Bmp.Width,FBtn1Bmp.Height, FBtn1Bmp.Canvas.Handle, 0, 0, SRCCOPY)
End if
مربوط به مثال بالا نیست