ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Strange error with TIEBitmap.CopyToClipboard
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

982 Posts

Posted - Aug 12 2017 :  16:51:03  Show Profile  Reply
I have a TImageEnMView with several images inserted with SetImageFromStream:



I need to select one of the images and copy it to the clipboard. So I wrote this code:

procedure TFormMain.mvDocImagesKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
var
  bm: TIEBitmap;
begin
  case Key of
    VK_C:
      begin
        if Shift*[ssShift, ssAlt, ssCtrl] = [ssCtrl] then
        begin
          bm := mvDocImages.GetTIEBitmap(mvDocImages.SelectedImage);
          try
            if not bm.CopyToClipboard() then // error here!!!
              Application.MessageBox('Copy to Clipboard failed.',
                PChar(Application.Title), MB_OK + MB_ICONSTOP + MB_TOPMOST);
          finally
            bm.Free;
          end;
        end;
      end;
  end;
end;


Unfortunately, the CopyToClipboard action RANDOMLY causes an error:



What does this error mean?

Is this a bug?

PeterPanino

982 Posts

Posted - Aug 12 2017 :  17:24:55  Show Profile  Reply
When I delete this line:

bm.Free;

...then the error does not occur anymore.

But shouldn't the created TIEBitmap object be released?
Go to Top of Page

xequte

39053 Posts

Posted - Aug 13 2017 :  05:57:54  Show Profile  Reply
Hi

No, don't free it, call ReleaseBitmap. Please see the documentation at:

https://www.imageen.com/help/TImageEnMView.GetTIEBitmap.html



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: