TVirtualDrawtree
Forum kuralları
Forum kurallarını okuyup, uyunuz!
Forum kurallarını okuyup, uyunuz!
Re: TVirtualDrawtree
Now it's 17.05 Turkey Local Time (GMT+2) at 20.00 i have been back to hotel. I'll check it out.
Re: TVirtualDrawtree
Hi again, I saw your example.mia yazdı:thats how i get animation from url what i try so far i saved it to memory stream , but gif is too slow also i can i make diffrent image for each item ? and how to specif items with images ?
- There is a special situation in this example : when you DRAW a GRAPHIC on to a Canvas, then this is not an animated gif anymore. This is a static picture.
- Animation speed value is not sensitive. Only refresh rate affects speed of animation. In this case, you need to put a lower value to timer interval. ( you say timer1.interval := 10; for example )
Ok now I share the whole code below. You make your work over this.
Project source and executable attached the message
Kod: Tümünü seç
Uses GIFImg, GraphUtil;
Var
xboolBlink : Boolean = False;
procedure TForm1.FormCreate(Sender: TObject);
begin
GIFImg.GIFImageDefaultAnimate := True;
GIFImg.GIFImageDefaultAnimationLoop := glContinously;
GIFImg.GIFImageDefaultTransparent := True;
// This is for repaint the ListView and so for the animation
Timer1.Interval := 200;
Timer1.Enabled := true;
// This is for enlarge the ListView height
ImageList1.Width := 32;
ImageList1.Height := 32;
With ListView1 do begin
SmallImages := ImageList1;
ViewStyle := vsReport;
RowSelect := True;
ReadOnly := True;
OwnerDraw := True;
DoubleBuffered := True;
With Columns.Add do Width := 50;
With Columns.Add do Width := 250;
With Columns.Add do Width := 50;
With Columns.Add do Width := 50;
end;
end;
Procedure Add_Item( strCaption: String; ListView : TListView; strFile: String; boolBlink : Boolean );
Var
aGIF : TGifImage;
begin
aGIF := TGifImage.Create;
aGIF.LoadFromFile( strFile );
aGIF.Transparent := True;
With ListView.Items.Add do
begin
Caption := '';
SubItems.Add( strCaption ); // subitem 0
SubItems.AddObject( 'IMA', TObject( aGIF ) ); // subitem 1
if boolBlink
then SubItems.Add( 'blink' ) // subitem 2
else SubItems.Add( '' ); // subitem 2
end;
// DO NOT Free this image because now it is a SubItems[1] Object
end;
// This is the ARMAN magic... :)
procedure TForm1.ListView1CustomDraw(Sender: TCustomListView;
const ARect: TRect; var DefaultDraw: Boolean);
Var
R: TRect;
begin
// Full ListView
SetRect(R, ARect.Left, ARect.Top, ARect.Right - ((ARect.Right-ARect.Left) div 2), ARect.Bottom );
GradientFillCanvas(Sender.Canvas, clSilver, clWhite, R, gdHorizontal); // GraphUtil
SetRect(R, ARect.Right - ((ARect.Right-ARect.Left) div 2), ARect.Top, ARect.Right, ARect.Bottom );
GradientFillCanvas(Sender.Canvas, clWhite, clSilver, R, gdHorizontal);
end;
procedure TForm1.ListView1DrawItem(Sender: TCustomListView; Item: TListItem;
Rect: TRect; State: TOwnerDrawState);
Var
xOff, yOff : Integer;
R: TRect;
i : Integer;
begin
With TListView(Sender).Canvas do
begin
if Item.Selected then
begin
SetRect(R, Rect.Left, Rect.Top, Rect.Right, Rect.Bottom-( (Rect.Bottom-Rect.Top) div 2 ) );
GradientFillCanvas(Sender.Canvas, $00056AFF, clWhite, R, gdVertical); // GraphUtil
SetRect(R, Rect.Left, Rect.Bottom-( (Rect.Bottom-Rect.Top) div 2 ), Rect.Right, Rect.Bottom );
GradientFillCanvas(Sender.Canvas, clWhite, $000055FF, R, gdVertical);
Sender.Canvas.Brush.Style := bsClear;
Sender.Canvas.Pen.Color := clRed;
Sender.Canvas.Pen.Width := 1;
//Sender.Canvas.Font.Color := clBlue;
//Sender.Canvas.Brush.Color := clYellow;
//Sender.Canvas.FillRect(Rect);
Rectangle( Rect.Left, Rect.Top, Rect.Right, Rect.Top + ImageList1.Height);
end;
Sender.Canvas.Brush.Style := bsClear;
// Image
xOff := Rect.Left + ((TListView(Sender).Columns[0].Width - TGIFImage( Item.SubItems.Objects[1]).Width ) div 2);
yOff := Rect.Top + ((ImageList1.Height - TGIFImage( Item.SubItems.Objects[1]).Height) div 2);
Draw( xOff, yOff, TGIFImage( Item.SubItems.Objects[1]) );
// Caption and Text
xOff := Rect.Left;
for i := 1 to TListView(sender).Columns.Count - 1 do
begin
xOff := xOff + TListView(Sender).Columns[i-1].Width;
yOff := Rect.Top + ((ImageList1.Height-Canvas.TextHeight('H')) div 2);
if xboolBlink or ( Item.SubItems[2] = '' )
then TextOut( xOff, yOff, Item.SubItems[i-1] );
end;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
{$j+}
Const iCount : Cardinal = 0;
{$j-}
begin
inc(iCount);
if (iCount * TTimer(Sender).Interval) > 500 then
begin // this is for blink text which subitem[2] contains 'blink'
xboolBlink := NOT xboolBlink;
iCount := 0;
end;
ListView1.Repaint; // This is for animation over ListView Canvas
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
{$j+}
Const boolblink : boolean = false;
{$j-}
begin
boolblink := not boolblink;
With TOpenDialog.Create(nil) do
begin
Filter := 'GIF Image *.GIF|*.gif|Bitmap Images *.BMP|*.bmp';
FilterIndex := 1;
if Execute then begin
Add_Item( 'Muharrem ARMAN - ' + IntToStr(ListView1.Items.Count+1), ListView1, FileName, boolblink );
end;
Free;
end;

- Dosya ekleri
-
- AnimatedGIF_ListView.rar
- (252.43 KiB) 119 kere indirildi
Re: TVirtualDrawtree
i started to play around i got some pitfalls
- how to control on image size if i get it from url
- how to make the image and item indent in list view
- how to hide this scroll bar down
- and the most important point i want to add the item first then show its image
here is the project
- how to control on image size if i get it from url
- how to make the image and item indent in list view
- how to hide this scroll bar down
- and the most important point i want to add the item first then show its image
here is the project
- Dosya ekleri
-
- AnimatedGIF.rar
- (79.7 KiB) 81 kere indirildi
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ
in god i trust with every movement i do
graduated student and looking for knowledge
in god i trust with every movement i do
graduated student and looking for knowledge
Re: TVirtualDrawtree
You want too many things...
- Image size issue; you need to lock with standart size to be control on you, you know. (lock the image size with 100x100) Because there is you have no power without controlled power by you. ImageList's Height value affects TListView's ItemHeight.
- indent is easy, you decide a margin then add every image(s) xOff value to this value.
- For hiding scrollbars issue, don't ask me, this is a standart TListView you know, Google it.
- Most important thing is the easiest thing, think like indent. xOff value + firstColWidth + indent = Image new X offset... Did you got it?
- Image size issue; you need to lock with standart size to be control on you, you know. (lock the image size with 100x100) Because there is you have no power without controlled power by you. ImageList's Height value affects TListView's ItemHeight.
- indent is easy, you decide a margin then add every image(s) xOff value to this value.
- For hiding scrollbars issue, don't ask me, this is a standart TListView you know, Google it.

- Most important thing is the easiest thing, think like indent. xOff value + firstColWidth + indent = Image new X offset... Did you got it?
Re: TVirtualDrawtree
i searched about tlistview scrollbars seems to be there is 2 way , First way that i do not prefer is using WindowProc this is i will not prefer because its will make the vertical scrollbar always showing i want only show it if there is extra items , second way by making columns width same as list view width and this is sounds good but i cannot verfiy how to do it with this project there is to many columns out there also i get ride of indy http and i use wininet seems much faster here is the current project
- Dosya ekleri
-
- AnimatedGIF.rar
- (89.52 KiB) 79 kere indirildi
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ
in god i trust with every movement i do
graduated student and looking for knowledge
in god i trust with every movement i do
graduated student and looking for knowledge
Re: TVirtualDrawtree
if total amount of every column width equals or bigger than listview width, then scrollbar will became visible. Then you need to calculate column widths depend on this situation.
Re: TVirtualDrawtree
thank you mrmarman yes i got it , i also created only 2 visible columns , also i discover something correct me if iam wrong i also can use hidden text as sub item without adding its column correct ? also i notice that i only allowed to add gif images can i added JPEG and bmp and png too ?
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ
in god i trust with every movement i do
graduated student and looking for knowledge
in god i trust with every movement i do
graduated student and looking for knowledge
Re: TVirtualDrawtree
yes you're totally right.
i like using listviews. Many many SubItems you can add and use, plus you do not need to show all of them at the same time.
one last thing, an unit for png image type, that's all you need is.
i like using listviews. Many many SubItems you can add and use, plus you do not need to show all of them at the same time.
one last thing, an unit for png image type, that's all you need is.
Re: TVirtualDrawtree
yes , i made it thank you for this directions you are awesome , but i still canot find solve for image size here is the project with gif and jpg and any other image can be done if i fix image size part this gonna be hilarious thing i tried
aGIF.Height := 20 and thats does not resize the image sadly to test the image just put image url in edit1
aGIF.Height := 20 and thats does not resize the image sadly to test the image just put image url in edit1
- Dosya ekleri
-
- AnimatedGIF.rar
- (91.48 KiB) 93 kere indirildi
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ
in god i trust with every movement i do
graduated student and looking for knowledge
in god i trust with every movement i do
graduated student and looking for knowledge
Re: TVirtualDrawtree
you need to change ImageList height to higher value.
Imagelist controls the listview item height . According this, Controls the height of canvas section of item. finally co trols the image height.
Imagelist controls the listview item height . According this, Controls the height of canvas section of item. finally co trols the image height.
Re: TVirtualDrawtree
do you mean at this lines ?
Kod: Tümünü seç
xOff := Rect.Left + ((TListView(Sender).Columns[0].Width - TGIFImage( Item.SubItems.Objects[1]).Width ) div 2);
yOff := Rect.Top + ((ImageList1.Height - TGIFImage( Item.SubItems.Objects[1]).Height) div 2);
Draw( xOff, yOff, TGIFImage( Item.SubItems.Objects[1]) );
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ
in god i trust with every movement i do
graduated student and looking for knowledge
in god i trust with every movement i do
graduated student and looking for knowledge
Re: TVirtualDrawtree
no, listview column add section,
on the form create procedure
listview height is wrong, listview item height is right. it's my bad.
on the form create procedure
Kod: Tümünü seç
// This is for enlarge the ListView height
ImageList1.Width := 32;
ImageList1.Height := 32;
Re: TVirtualDrawtree
i dont get it yet thats how my code looks like and thats how image looks like if its large
- Dosya ekleri
-
- inlargee.jpg (12.74 KiB) 4046 kere görüntülendi
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ
in god i trust with every movement i do
graduated student and looking for knowledge
in god i trust with every movement i do
graduated student and looking for knowledge
Re: TVirtualDrawtree
I'm on field for shooting. I cannot see the picture in my condition.
If you change the imagelist height the listview item height changes.
after that, you xhange image size below.
if image stretch property enabled then you see bigger or smaller
If you change the imagelist height the listview item height changes.
after that, you xhange image size below.
Kod: Tümünü seç
aGIF := TGifImage.Create;
aGIF.LoadFromFile( strFile );
aGIF.Transparent := True;
aGIF. Height := imagelist1.height;
aGIF. Width := imagelist1.width;
Re: TVirtualDrawtree
adding
does not changes gif size and also on
says cannot change image size
Kod: Tümünü seç
aGIF. Height := form1.imagelist1.height;
aGIF. Width := form1.imagelist1.width;
Kod: Tümünü seç
jpg.Height := form1.imagelist1.height;
jpg.Width := form1.imagelist1.width;
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ
in god i trust with every movement i do
graduated student and looking for knowledge
in god i trust with every movement i do
graduated student and looking for knowledge