🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
9 messages
9 total messages Started by Clayton Arends Thu, 16 Mar 2006 16:31
Using clipboard delayed rendering properly
#4106
Author: Clayton Arends
Date: Thu, 16 Mar 2006 16:31
18 lines
1739 bytes
All,

I have recently created a test program which sets clipboard data using 
delayed rendering by handling the WM_RENDERFORMAT and WM_RENDERALLFORMATS 
messages rather than setting the data up front.  This works fine.  I have 
noticed that when my application closes the WM_RENDERALLFORMATS message is 
sent asking my program to put the data in the clipboard before my app is 
gone (makes sense).

For the program that I am creating I do not desire the clipboard to be 
filled when the app exits.  My question is: what is the typical way that 
programs handle this situation?  Should I ignore the message (return 
non-zero)?  Should I empty the clipboard before the app closes or during the 
WM_RENDERALLFORMATS message?

I really would just like to know the standard way other people handle this.

- Clayton 
Re: Using clipboard delayed rendering properly
#4107
Author: Alan Bellingham
Date: Thu, 16 Mar 2006 17:06
19 lines
1712 bytes
"Clayton Arends" <nospam_claytonarends@hotmail.com> wrote:

>For the program that I am creating I do not desire the clipboard to be 
>filled when the app exits.  My question is: what is the typical way that 
>programs handle this situation?  Should I ignore the message (return 
>non-zero)?  Should I empty the clipboard before the app closes or during the 
>WM_RENDERALLFORMATS message?
>
>I really would just like to know the standard way other people handle this.

I don't know what the standard method is, but I have noticed some
programs popping up a dialog on exit asking whether the user wants a
large amount of data left in the clipboard.

I now see why that message pops up.

Alan Bellingham
-- 
ACCU Conference 2006 - 19-22 April, Randolph Hotel, Oxford, UK
Re: Using clipboard delayed rendering properly
#4109
Author: Clayton Arends
Date: Thu, 16 Mar 2006 17:41
3 lines
1041 bytes
Yeah, the lightbulb went off for me too <g>

- Clayton 
Re: Using clipboard delayed rendering properly
#4108
Author: Bob Gonder
Date: Thu, 16 Mar 2006 17:55
19 lines
1807 bytes
Clayton Arends wrote:

>For the program that I am creating I do not desire the clipboard to be 
>filled when the app exits.  My question is: what is the typical way that 
>programs handle this situation?  Should I ignore the message (return 
>non-zero)?  Should I empty the clipboard before the app closes or during the 
>WM_RENDERALLFORMATS message?

This bit from the help seems to indicate that if you don't render
anything, then the clipboard will just forget agout you.

<Win32.hlp - Delayed Rendering>
Any clipboard formats that are not rendered in response to the
WM_RENDERALLFORMATS message cease to be available to other
applications and are no longer enumerated by the clipboard functions. 
</help>

So it would seem that doing nothing would be fine, but return 0,
processed.
Re: Using clipboard delayed rendering properly
#4110
Author: Clayton Arends
Date: Thu, 16 Mar 2006 20:33
19 lines
1621 bytes
ok, that makes sense.  Currently what I'm doing is something like this:

  // in message handler for WM_RENDERALLFORMATS
  ::OpenClipboard(NULL); // not sure if I should use handle or not
  ::EraseClipboard(); // help states that app should always erase

  if (!ComponentState.Contains(csDestroying))
  {
    // add all formats using ::SetClipboardData()
  }

  ::CloseClipboard();

  return 0; // or Msg->Result = 0 for VCL handlers

Unless there's something I'm completely missing I think this is what I will 
go with.  I can't test this right now (different projects to work on, etc).

- Clayton 
Re: Using clipboard delayed rendering properly
#4111
Author: Bob Gonder
Date: Thu, 16 Mar 2006 20:48
24 lines
1658 bytes
Clayton Arends wrote:

>Unless there's something I'm completely missing I think this is what I will 
>go with.

The help says don't open the clipboard when you get a
WM_RENDERALLFORMATS, just SetClipboardData.

<help>
An application should not open the clipboard before calling
SetClipboardData in response to the WM_RENDERFORMAT or
WM_RENDERALLFORMATS message. 
</help>


So the proper response would simply be...

case WM_RENDERFORMAT:
case WM_RENDERALLFORMATS:
	  if (!ComponentState.Contains(csDestroying))
	  {
	    // add all formats using ::SetClipboardData()
	  }
	  return 0; // or Msg->Result = 0 for VCL handlers
Re: Using clipboard delayed rendering properly
#4113
Author: Clayton Arends
Date: Fri, 17 Mar 2006 02:32
7 lines
1248 bytes
From the help for WM_RENDERALLFORMATS:

  When responding to a WM_RENDERALLFORMATS message, the clipboard
  owner must call the OpenClipboard and EmptyClipboard functions before
  calling SetClipboardData.

- Clayton 
Re: Using clipboard delayed rendering properly
#4117
Author: Bob Gonder
Date: Fri, 17 Mar 2006 19:41
37 lines
2556 bytes
Clayton Arends wrote:

>From the help for WM_RENDERALLFORMATS:
>
>  When responding to a WM_RENDERALLFORMATS message, the clipboard
>  owner must call the OpenClipboard and EmptyClipboard functions before
>  calling SetClipboardData.


Ok, I see the conflict.
The general overview as well as the doc for SetClipboardData say DON'T
Open/Close for Both the WM_RENDERx, whereas the docs for
WM_RENDERFORMAT say DON'T and the docs for WM_RENDERALLFORMATS say DO.

This may wrap. SetClipboardData
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/dataexchange/clipboard/clipboardreference/clipboardfunctions/setclipboarddata.asp

Again, may wrap: WM_RENDERALLFORMATS
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/dataexchange/clipboard/clipboardreference/clipboardmessages/wm_renderallformats.asp

Both from MSDN, so which is correct?

This example code from MSDN shows non-Open/Close usage:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/dataexchange/clipboard/usingtheclipboard.asp

In particular:

case WM_RENDERFORMAT: 
    RenderFormat((UINT) wParam); 
    break; 
 
case WM_RENDERALLFORMATS: 
    RenderFormat(uLabelFormat); 
    RenderFormat(CF_TEXT); 
    break;

No Open/Erase/Close in there at all.
Re: Using clipboard delayed rendering properly
#4119
Author: Clayton Arends
Date: Sat, 18 Mar 2006 05:04
10 lines
1560 bytes
Bob,

Nice research, and a handy page.  I don't know if we can say for sure which 
is the preferred method given that the document contradicts itself. 
However, with all of the other uses it is looking more and more like the 
help for WM_RENDERALLFORMATS has the error.  I will try to do both when I 
get around to testing again.  Though, I suspect it will have no affect 
either way and in that case the smaller/faster code wins!

- Clayton 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads