Type | Description | |||
Part as PartEnum | A PartEnum expression that's responsible for its drawing | |||
Boolean | A Boolean expression that indicates whether the user is responsible for drawing the specified part, or not. |
The control paints the parts in the following order ( only if visible ):
For instance, the following VB sample draws the lower part in red, and the upper part in green ( as in the screen shot ) :
With ScrollBar1 .OwnerDrawPart(exLowerBackPart Or exUpperBackPart) = True End With
Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Declare Function GetClipBox Lib "gdi32" (ByVal hdc As Long, lpRect As RECT) As Long Private Declare Function FillRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Private Sub ScrollBar1_OwnerDrawEnd(ByVal Part As EXSCROLLBARLibCtl.PartEnum, ByVal hdc As Long) Dim r As RECT, h As Long GetClipBox hdc, r r.Left = r.Left + 4 r.Right = r.Right - 4 If Part = exLowerBackPart Then h = CreateSolidBrush(RGB(255, 0, 0)) FillRect hdc, r, h DeleteObject (h) Else If Part = exUpperBackPart Then h = CreateSolidBrush(RGB(0, 255, 0)) FillRect hdc, r, h DeleteObject (h) End If End If End Sub
The following C++ sample draws the lower part in red, and the upper part in green ( as in the screen shot ) :
m_scrollbar.SetOwnerDrawPart( 128 /*exUpperBackPart*/, TRUE ); m_scrollbar.SetOwnerDrawPart( 512 /*exLowerBackPart*/, TRUE );
void OnOwnerDrawEndScrollbar1(long Part, long hDC) { HDC h = (HDC)hDC; RECT rtPart = {0}; GetClipBox( h, &rtPart ); InflateRect( &rtPart, -4, 0 ); switch ( Part ) { case 128: /*exUpperBackPart*/ { HBRUSH hB = CreateSolidBrush( RGB(0,255,0) ); FillRect( h, &rtPart, hB ); DeleteObject( hB ); break; } case 512: /*exLowerBackPart*/ { HBRUSH hB = CreateSolidBrush( RGB(255,0,0) ); FillRect( h, &rtPart, hB ); DeleteObject( hB ); break; } } }