Delphi 2010 ve Delpi XE2 aynı pc üzerinde kullanımı!
Destek talebi(Lütfen oy verelim!)
Sitemiz üye alımına kapatılmıştır!
! CODEBANK 2012 !
İNDİRMEK&DETAYLI BİLGİ ALMAK İÇİN BURAYI TIKLAYINIZ.
0 Üye ve 1 Ziyaretçi konuyu incelemekte.
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) ListBox1: TListBox; Edit1: TEdit; procedure ListBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); procedure Edit1Change(Sender: TObject); procedure FormCreate(Sender: TObject); private HighlightText : string ; TextLength : integer ; Foreground : TColor ; Background : TColor ; public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);var Location : integer ; s : string ; Text : string; ax : integer ; TextWidth : integer ; OldBrushColor : TColor ; OldFontColor : TColor ;const HighlightColor = clRed ;begin with (Control as TListBox) do begin Canvas.FillRect(Rect) ; Location := Pos(HighlightText, Items[Index]) ; if Location > 0 then begin TextWidth := Canvas.TextWidth(HighlightText) ; s := Items[Index] ; ax := 0 ; while Location > 0 do begin Text := Copy(s, 1, Location - 1) ; s := Copy(s, Location + TextLength, Length(s)) ; Canvas.TextOut(ax, Rect.Top, Text) ; Inc(ax, Canvas.TextWidth(Text)) ; OldBrushColor := Canvas.Brush.Color ; OldFontColor := Canvas.Font.Color ; Canvas.Brush.Color := Background ; Canvas.Font.Color := Foreground ; Canvas.TextOut(ax, Rect.Top, HighlightText) ; Canvas.Brush.Color := OldBrushColor ; Canvas.Font.Color := OldFontColor ; Inc(ax, TextWidth) ; Location := Pos(HighlightText, s) ; end ; Canvas.TextOut(ax, Rect.Top, s) ; end else Canvas.TextOut(Rect.Left, Rect.Top, Items[Index]) ; end ;end;procedure TForm1.Edit1Change(Sender: TObject);beginHighlightText := Edit1.Text ;TextLength := Length(Edit1.Text) ;ListBox1.Refresh ;end;procedure TForm1.FormCreate(Sender: TObject);beginEdit1.Clear; ListBox1.Items.LoadFromFile('c:\a.txt');//you can change it. ListBox1.Style:=lbOwnerDrawFixed; HighlightText := Edit1.Text ; TextLength := 5 ; Background := clRed ;// item renki Foreground := clGreen ;// font renkiend;end.