Try this:


  Clipboard.Open;
  try
    // Add bitmap to clipboard
  finally
    Clipboard.Close;
  end;

> BTW I
> havent seen anything in my references about 'clipboard sharing'

The clipboard *IS* a shared resource!  Windows only allows one app to open
the clipboard.  All access (read or write) to the clipboard is blocked.  It
remains blocked until the app has closed the clipboard.  The clipboard can
only be written to when it is open, and only by the app that has opened it.

> I have seen the following code:
>     H := Clipboard.GetAsHandle(CF_TEXT);
>     Len := GlobalSize(H)+1;
>     P := GlobalLock(H);
>     Memo1.SetTextBuf(P);
>     GlobalUnlock(H);
>
> Should I be doing something similar to above to force an unlock on the
> clipboard, and also set the size allocation for the clipboard
> too

The above code is for reading from the clipboard NOT writing.

To write use, SetAsHandle.  Do not free the handle as the clipboard then
owns the handle, not you.

Regards,
Dennis.

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Alistair George
> Sent: Friday, 3 December 1999 12:36
> To: Multiple recipients of list delphi
> Subject: [DUG]: Clipboard sharing violation
>
>
> Myprogram copies to the clipboard, then when a user tries to
> paste from the
> clipboard to Publisher they get the following error message:
> 'The clipboard is busy'
>
> procedure TCamForm.ClipCopyPaste(Tval: Integer);
> var bitmap: tbitmap;
> begin
>   bitmap := Tbitmap.Create;
>   try
>   if tval = 0 then //copy to clipboard FROM HERE
>   begin
>     bitmap.Width := FIMG1.Bmp.Width;
>     bitmap.Height := FIMG1.Bmp.Height;
>     FIMG1.bmp.draw(bitmap.Canvas.Handle, 0, 0);
>     clipboard.Assign(bitmap);// TO HERE
>   end
>   else if (tval = 1) and (Clipboard.HasFormat(CF_BITMAP))
> then //paste from
> clipboard
>   begin
>     bitmap.assign(clipboard);
>     insertPic(SizeFunc(bitmap));
>     PicClick(ADbmpc.Bitmaps.Count);
>   end;
>   finally bitmap.Free;
> end;
>
> I have seen the following code:
>     H := Clipboard.GetAsHandle(CF_TEXT);
>     Len := GlobalSize(H)+1;
>     P := GlobalLock(H);
>     Memo1.SetTextBuf(P);
>     GlobalUnlock(H);
>
> Should I be doing something similar to above to force an unlock on the
> clipboard, and also set the size allocation for the clipboard
> too - BTW I
> havent seen anything in my references about 'clipboard sharing'
> Thanks,
> Alistair+
>
> --------------------------------------------------------------
> -------------
>     New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
>

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to