TImage and visabillity lazarus / 39-Graphics ---------------------------------------------------------------------- madref · 2015-03-14 18:26 I have several images onto of each other and depending on the input i want to show that image. I use the following code: Code: [Select]  case MsgT of     mNone     : begin                   Image_UitroepTeken.Visible := False;                   Image_VraagTeken.Visible := False;                   Image_Informatie.Visible := False;                   Image_Stop.Visible := False;                   //Ook lblMessage verschuiven                   Label_Message.Left := 10;                   Label_Message.Top := 10;                   Label_Message.Width := 380;                 end;     // mNone     mStop     : begin                   Image_UitroepTeken.Visible := False;                   Image_VraagTeken.Visible := False;                   Image_Informatie.Visible := False;                   Image_Stop.Visible := True;                 end;     // mStop     mInfo     : begin                   Image_UitroepTeken.Visible := False;                   Image_VraagTeken.Visible := False;                   Image_Informatie.Visible := True;                   Image_Stop.Visible := False;                 end;     // mInfo     mQuestion : begin                   Image_UitroepTeken.Visible := False;                   Image_VraagTeken.Visible := True;                   Image_Informatie.Visible := False;                   Image_Stop.Visible := False;                 end;     // mQuestion     mWarning  : begin                   Image_UitroepTeken.Visible := True;                   Image_VraagTeken.Visible := False;                   Image_Informatie.Visible := False;                   Image_Stop.Visible := False;                 end;     // mWarning   end;     // MsgT If MsgT = mInfo then i get an error on the Image_Informatie.Visible := True statement. I don't know why but can anyone help me? ---------------------------------------------------------------------- Never · 2015-03-14 19:08 what is the error you are getting? ---------------------------------------------------------------------- madref · 2015-03-14 19:34 Error: Project raised exception class 'External: EXC_BAD_ECCESS'. ---------------------------------------------------------------------- Never · 2015-03-14 19:48 the error means this object Image_Informatie is not yet created or is freed beyond this it might be a good idea to have only on image control and change images usinng an image list ---------------------------------------------------------------------- madref · 2015-03-16 09:18 How do you do that. Because i am new to Lazarus ---------------------------------------------------------------------- mm7 · 2015-03-17 15:47 You should create the object before you try to use it. Image_Informatie := TImage.Create... ---------------------------------------------------------------------- Never · 2015-03-17 16:10 here you are have a look  to get the idea create a project and add a button add a timage add an imagelist -->add 3 images same size (height/width) add a spinedit-->set minvalue to 0 set maxvalue to the count of imagelist items wich will be 2 copy paste the code Code: [Select]unit Unit1; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, Spin; type   { TForm1 }   TForm1 = class(TForm)     Button1: TButton;     Image1: TImage;     ImageList1: TImageList;     SpinEdit1: TSpinEdit;     procedure Button1Click(Sender: TObject);   private     { private declarations }   public     { public declarations }   end; var   Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject); var loc_Index:Integer; begin      loc_Index:=SpinEdit1.Value;      Image1.Canvas.Clear;    Image1.Picture.Bitmap.SetSize(ImageList1.Width, ImageList1.Height);      ImageList1.Draw(Image1.Picture.Bitmap.Canvas, 0, 0, loc_Index); end; end. and run the project change the number in spinedit and click the button to see the images in timage