0

enter image description hereenter image description hereenter image description hereenter image description here

I want to run two images consecutively. I try to in an endless loop but my application has been blocked.

It looks like a gif but I don't have a gif with these images. I tried the following:

while 1=1 then
begin
    btnNotification.Glyph.LoadFromFile(ICON_DIR + '/notification-active-1.bmp');
    sleep(200);    
    btnNotification.Glyph.LoadFromFile(ICON_DIR + '/notification-active-2.bmp');
end;
Nevermore
  • 1,663
  • 7
  • 30
  • 56
  • Put your images to an image list, assign it to button's `Images` and from timer switch its `ImageIndex` like e.g. `MyButton.ImageIndex := (MyButton.ImageIndex + 1) mod MyButton.Images.Count;` – Victoria Dec 21 '17 at 13:51
  • 2
    why you don't get a free tool to make a gif from the images you want? – RBA Dec 21 '17 at 13:53
  • 4
    Many problems. A timer is needed to avoid a main thread busy loop. Loading the image from disk over and over is wasteful. `1=1`, you mean `True`. Why not use an animated gif? – David Heffernan Dec 21 '17 at 14:06
  • 1
    Using the `Vcl.Imaging.GIFImg;` unit it's easy to create a working `.gif` from the two bitmaps. [Look here](https://stackoverflow.com/q/930300/2292722) – Tom Brunberg Dec 21 '17 at 17:23
  • @Tom Any tool will do, no need to tie yourself down to Delphi here. – David Heffernan Dec 21 '17 at 19:18
  • @David Absolutely, any tool will do. No need to tie yourself down to anything here. – Tom Brunberg Dec 21 '17 at 20:06
  • Can you tell us why you want to do this this way?, I mean what are you trying to accomplish here?. [here is your gif](https://i.imgur.com/cvbmxb1.gif) – Nasreddine Galfout Dec 21 '17 at 23:30
  • Because i couldnt add gif on my tspeedbutton, it returns an error "Bitmap image is not valid" .. It is a TSpeedButton and accepts only bmp files.. – Nevermore Dec 22 '17 at 10:19
  • With my initial comment I've expected using `TButton` (I've focused at the component name and missed the rest of the lines using `Glyph`). – Victoria Dec 22 '17 at 13:48

0 Answers0