Listbox ta Otomatik boyutlandırma işlemi

Reklam Alanı

unit MutliLineListBox;

interface

uses Windows, Graphics, Messages, SysUtils, Classes, Controls, StdCtrls;

type
TMutliLineListBox = class(TListBox)
private
{ Private declarations }
FMultiLine: Boolean;
procedure SetMultiLine(const Value: Boolean);
protected
{ Protected declarations }
procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState); override;
procedure MeasureItem(Index: Integer; var Height: Integer); override;
public
{ Public declarations }
published
{ Published declarations }
property MultiLine: Boolean read FMultiLine write SetMultiLine;
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents(‘Standard’, [TMutliLineListBox]);
end;

{ TMutliLineListBox }

procedure TMutliLineListBox.DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState);
var
s: string;
begin
if (FMultiLine) then
begin
Canvas.Font := Font;
if (odSelected in State) then Canvas.Font.Color := clHighlightText;
Canvas.FillRect(Rect);
s := Items[ Index ];
DrawText(Canvas.Handle, PChar(s), Length(s), Rect, DT_WORDBREAK);
end
else
inherited;
end;

procedure TMutliLineListBox.MeasureItem(Index: Integer; var Height: Integer);
var
s: string;
h: Integer;
r: TRect;
begin
if (FMultiLine) then
begin
h := Height;
Canvas.Font := Font;
s := Items[ Index ];
r := ItemRect(Index);
DrawText(Canvas.Handle, PChar(s), Length(s), r, DT_CALCRECT or DT_WORDBREAK);
Height := (r.Bottom – r.Top);
if (Height < h) then Height := h;
end
else
inherited;
end;

procedure TMutliLineListBox.SetMultiLine(const Value: Boolean);
begin
if (FMultiLine <> Value) then
begin
FMultiLine := Value;

if (FMultiLine) then
Style := lbOwnerDrawVariable
else
Style := lbStandard;
end;
end;

end.

Alıntıdır.
Etiketler : Listbox, listbox ta boyutlandırma, lixbox metin boyutu , listbox outo size, listbox text size, listbox otomatik metin boyutu

administrator2009-08-30 15:15:07

Benzer Yazılar:

  1. Ekran Klavyesi
  2. Listbox İtemlerinin Sırasını Mause ile sürükleyerek Değiştirmek
  3. Delphide Yazılmış Kaynak Kodlar
  4. Tüm Dosya ve Klasörlerin Listesini Almak
  5. CxGrid de Arama Yapmak
  6. Bilgisayardaki Sürücü Listesini Almak
  7. Dosya Uzantısından Programın Tespiti
  8. Yazılan Fiyatı Metine Çevirmek
  9. Ağ daki Bilgisayarlara Ping Atmak
  10. Metnin İçerisindeki Kelime Sayısını Bulan Kod
Etiketler:

Eğer yazıyı beğendiyseniz ya da ekleyecekleriniz varsa, lütfen yorumunuz yazın veya RSS aboneliği ile yeni yazılardan anında haberdar olun.

Yorum yapın

*

Gizlilik Politikası