procedure TJvCustomOutlookBar.DrawButtons(Index: Integer); var I: Integer; R, R2, R3: TRect; C: TColor; SavedDC: Integer; SavedColor: TColor; {$IFDEF JVCLThemesEnabled} ThemedColor: Cardinal; Details: TThemedElementDetails; {$ENDIF JVCLThemesEnabled} begin if csDestroying in ComponentState then Exit; if (Index < 0) or (Index >= Pages.Count) or (Pages[Index].Buttons = nil) or (Pages[Index].Buttons.Count <= 0) then Exit; R2 := GetPageRect(Index); R := GetButtonRect(Index, Pages[Index].TopButtonIndex); C := Canvas.Pen.Color; Canvas.Font := Pages[Index].Font; {$IFDEF JVCLThemesEnabled} if Themed then begin Details := StyleServices.GetElementDetails(ttbButtonNormal); with Details do GetThemeColor(StyleServices.Theme[Element], Part, State, TMT_TEXTCOLOR, ThemedColor); end; {$ENDIF JVCLThemesEnabled} try Canvas.Brush.Style := bsClear; for I := Pages[Index].TopButtonIndex to Pages[Index].Buttons.Count - 1 do begin // BJF *** If GetButtonRect(Index, I ).Bottom >= R2.Bottom then Break; Canvas.Font := Pages[Index].Font; // Canvas.Rectangle(R); // DEBUG {$IFDEF JVCLThemesEnabled} if Themed then Canvas.Font.Color := ThemedColor; {$ENDIF JVCLThemesEnabled} if Pages[Index].Buttons[I].Down then begin Canvas.Font := Pages[Index].DownFont; DrawButtonFrame(Index, I, I); end; if DoDrawButton(R, I, Pages[Index].Buttons[I].Down, I = FLastButtonIndex) then case Pages[Index].ButtonSize of olbsLarge: begin SavedColor := Canvas.Font.Color; try SavedDC := SaveDC(Canvas.Handle); try if LargeImages <> nil then LargeImages.Draw(Canvas, R.Left + ((R.Right - R.Left) - LargeImages.Width) div 2, R.Top + 4, Pages[Index].Buttons[I].ImageIndex, Pages[Index].Enabled and Pages[Index].Buttons[I].Enabled); finally RestoreDC(Canvas.Handle, SavedDC); end; R3 := GetButtonTextRect(ActivePageIndex, I); SetBkMode(Canvas.Handle, TRANSPARENT); if not Pages[Index].Enabled or not Pages[Index].Buttons[I].Enabled then begin if ColorToRGB(Pages[Index].Color) = ColorToRGB(clGrayText) then Canvas.Font.Color := PageBtnProps.Face//clBtnFace else Canvas.Font.Color := clGrayText; end; if FWordWrap then DrawText(Canvas.Handle, PChar(Pages[Index].Buttons[I].Caption), -1, R3, DT_WORDBREAK or DT_CENTER or DT_VCENTER) else DrawText(Canvas.Handle, PChar(Pages[Index].Buttons[I].Caption), -1, R3, DT_EXPANDTABS or DT_SINGLELINE or DT_CENTER or DT_VCENTER); finally Canvas.Font.Color := SavedColor; end; end; olbsSmall: begin SavedColor := Canvas.Font.Color; try SavedDC := SaveDC(Canvas.Handle); try if SmallImages <> nil then SmallImages.Draw(Canvas, R.Left + 2, R.Top + 2, Pages[Index].Buttons[I].ImageIndex, Pages[Index].Enabled and Pages[Index].Buttons[I].Enabled); finally RestoreDC(Canvas.Handle, SavedDC); end; R3 := GetButtonTextRect(ActivePageIndex, I); SetBkMode(Canvas.Handle, TRANSPARENT); if not Pages[Index].Enabled or not Pages[Index].Buttons[I].Enabled then begin if ColorToRGB(Pages[Index].Color) = ColorToRGB(clGrayText) then Canvas.Font.Color := PageBtnProps.Face//clBtnFace else Canvas.Font.Color := clGrayText; end; InflateRect(R3, -4, 0); DrawText(Canvas.Handle, PChar(Pages[Index].Buttons[I].Caption), -1, R3, DT_EXPANDTABS or DT_SINGLELINE or DT_LEFT or DT_VCENTER or DT_NOCLIP or DT_EDITCONTROL); finally Canvas.Font.Color := SavedColor; end; end; end; OffsetRect(R, 0, GetButtonHeight(Index, I)); // BJF *** // if R.Top >= R2.Bottom then // Break; end; finally Canvas.Font := Self.Font; Canvas.Pen.Color := C; end; end;