Erratic Behavior of: WPRichText.CopyToClipBoard(true)

  • Delphi 2007, Win 32 app, running on Windows XP.
    WPTools version 5.51

    In my application, users create documents (letter) in WPRichText and eventually paste them in their business app for storage. They copy text in WP Editor using a popup menu which has this one line of code: WPRichText_Ltr.CopyToClipBoard(true);

    There are no tables or graphics or other fancy stuff in the documents - just text. Documents are not saved to file by my App - simply copied from it. Templates, which serve as starting point for letters have been saved in WPT format.

    Most of the time copy and paste function works fine. However, I have been getting reports that, at times, on using above menu option, NOTHING GETS COPIED to clipboard. Using right click on target app, e.g., Notepad, "Paste" option remains grayed out meaning there is nothing on clipboard).

    Today a user demonstrated this to me: I could verify that indeed it was problem in software and not "operator error" or false alarm. Nothing got copied to Clipboard even with text highlighted (the above command does not need text highlighted). I have a button in App that closes and FREEs the form thus WPRichText and other controls are recreated when form opens next time. Even doing that did not solve the above problem.

    Any ideas ? (I understand that this is very sporadic and will be virtually impossible to reproduce. Has anyone seen this behavior elsewhere - with/without WPRichText? Could this be something to do with Windows rather than WPRichText ?) Any insights are appreciated.

    Thanks

    JayM

    • Offizieller Beitrag

    Hi,

    Internally this code gets called:

    Code
    if not (wpcoDontCopyRTF in ClipboardOptions) and
              (Memo.GetWriterClass('RTF') <> nil) then
            begin
              Stream.Clear;
              if CompleteText then SaveToStream(Stream, 'RTF' + extra_frm)
              else SaveSelectionToStream(Stream, 'RTF' + extra_frm);

    so basically SaveToStream is performed.

    Later a memory handle is created and assigned to the clipboard using ClipBoard.SetAsHandle(FormatRTF, RTFMemHand);

    This will not work if the clipoard is currently open or in use. Then nothing can be copied.

    Julian