Unwanted canvas clear lazarus / 39-Graphics ---------------------------------------------------------------------- user5 · 2014-04-04 17:07 I want to load a bitmap into my form on activation w/o the user having to press a button. The following loads the bitmap ok but then it disappears when the procedure ends. Any suggestions? procedure TForm1.FormActivate(); begin  MyBitmap := TBitmap.Create;  MyBitmap.LoadFromFile('c:\temp7\etc');  Canvas.Draw(0,0,MyBitmap);  delay(2000); end; ---------------------------------------------------------------------- Blaazen · 2014-04-04 17:21 Hi, at first, do not paint anything in OnActivate. Some widgetsets does not support it at all (Qt, Carbon). Even if you have widgetset which enables you to paint out of OnPaint method (Windows or GTK2) the picture will stay there to the next Invalidate only. If you want it there permanently, there are at least three ways: use TPaintBox + OnPaint event or TImage, or move the code to Form1.OnPaint event. ---------------------------------------------------------------------- user5 · 2014-04-04 19:54 Thank you so much Blaazen! OnPaint worked out fine but I was wondering how to send a bitmap to a TImage. I searched previous posts and found the following but it didn't work:     image1.Picture.Bitmap.LoadFromFile('c:\temp7\title1.bmp'); Can you tell me how to get MyBitmap into image1? (image1:TImage) Thanx again. This is a great forum!!!!! ---------------------------------------------------------------------- Blaazen · 2014-04-04 20:15 It works here. I tried both: Code: [Select]Image1.Picture.LoadFromFile('/media/disk/v1/Lazarus_Qt/l azarus/images/LazarusForm.bmp'); and Image1.Picture.Bitmap.LoadFromFile('/media/disk/v1/Lazarus_Qt/lazarus/ images/LazarusForm.bmp'); So I can only guess - some unsupported format of your image? Or typo in filename? ---------------------------------------------------------------------- user5 · 2014-04-05 10:03 Sorry I didn't reply sooner; I was tired. I can't get either procedure to work. It compiles ok but when I run it I get an error message and an assembler window. This has happened to me before if I didn't have the correct headers/tpus in the 'uses' section. Do you know what header applies to "Picture" in Image.Picture.LoadFromFile? Bitmap and LoadFromFile already work for me when I'm working strictly with bitmaps. Thanks ---------------------------------------------------------------------- jfmadre · 2014-04-05 11:07 I've tried a simple program with a Timage and a button procedure TForm1.Button1Click(Sender: TObject); begin   Image1.Picture.LoadFromFile('imagefond.jpg'); end; imagefond.jpg is in the directory of my program when i click on the button, the image loads without problem. I had a similar problem whith a software whith opening of assembler windows. It occured after my software was trying to read a table over the dimension declared in a try/finally zone of my soft. The error occured then in another part of the program and that sems odd. Solution to find this problem configure the Compiler (Project/Project options/Compiler options/ and what in french is "Infos de débogage" then check the options "Intervalle (-Cr)" and "Débordement (-Co)" Then when runing the soft it stops where the true error is. Perhaps the same problem ? ---------------------------------------------------------------------- user5 · 2014-04-06 07:31 My bonehead problem is solved. I didn't have a TImage box in my form to represent image1 and that's why it wouldn't work right. It works fine now. Thanks to you all for trying to help me. By the way, please spare a glance at my new posting titled "Bitmap wavefore from .wav file." I could really use some help there.