這不是侯捷大師的網站,只是一個姓名英譯相似的人企圖魚目混珠....

[Delphi]TComboBox下拉式選單著色


將下拉式選單之選項著色




procedure TfmMain.cbItemDrawItem(Control: TWinControl;
  Index: Integer; Rect: TRect; State: TOwnerDrawState);
begin
//cb.style 要設成 csOwnerDrawVariable
  TComboBox(Control).Canvas.Font.Color := clBlack;
  if (Copy(TComboBox(Control).Items[Index],1,1) = 'A') then begin
     TComboBox(Control).Canvas.Brush.Color := $00FFECFF;
  end else
  if (Copy(TComboBox(Control).Items[Index],1,1) = 'B') then begin
     TComboBox(Control).Canvas.Brush.Color := $00DFFFFF;
  end else
  if (Copy(TComboBox(Control).Items[Index],1,1) = 'C') then begin
     TComboBox(Control).Canvas.Brush.Color := $00DFDFFF;
  end else
  if (Copy(TComboBox(Control).Items[Index],1,1) = 'D') then begin
     TComboBox(Control).Canvas.Brush.Color := $00FFECD9;
  end;
  TComboBox(Control).Canvas.FillRect(Rect);
  TComboBox(Control).Canvas.TextOut(Rect.Left , Rect.Top ,TComboBox(Control).Items[Index]);
end;
SHARE

Milan Tomic

Hi. I’m Designer of Blog Magic. I’m CEO/Founder of ThemeXpose. I’m Creative Art Director, Web Designer, UI/UX Designer, Interaction Designer, Industrial Designer, Web Developer, Business Enthusiast, StartUp Enthusiast, Speaker, Writer and Photographer. Inspired to make things looks better.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 意見:

張貼留言