Copy an image onto a new form, results in access violation

Posted on 2005-05-14
Last Modified: 2010-04-05

Problem with the following code... I am copying an image from one form to another... If I use showmodal on the form, the access violation do not appear vefore I close the window...
uncommenting the zzommImage code, will result in the excact same problem...

What am I doing wrong ???

procedure TForm1.Image1DblClick(Sender: TObject);
  zOrgImage     : TBitmap;
  zZoomMapRect  : TRect;
  //zZoomImage    : TBitmap;
  zWnd          : TForm2;

  zWnd := TForm2.Create(Self);
  zOrgImage := TBitmap.Create;
  //zZoomImage := TBitmap.Create;
  zOrgImage := Image1.Picture.Bitmap;

  zZoomMapRect.TopLeft := Point(100, 100);
  zZoomMapRect.BottomRight := Point(300, 300);

  zWnd.Image1.Picture.Bitmap.Width := zWnd.Image1.Width;
  zWnd.Image1.Picture.Bitmap.Height := zWnd.Image1.Height;

  //zZoomImage.Canvas.CopyRect(Rect(0,0,zWnd.Image1.Width, zWNd.Image1.Height), zOrgImage.Canvas, zZoomMapRect);

  zWnd.Image1.Picture.Bitmap.Canvas.CopyRect(Rect(0,0,zWnd.Image1.Width, zWNd.Image1.Height), zOrgImage.Canvas, zZoomMapRect);


Question by:olefjeld
    LVL 5

    Accepted Solution

     zOrgImage := Image1.Picture.Bitmap;

    should be

    LVL 1

    Author Comment


    think I went blind from looking at it for too long...

    Cheers !

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
    Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now