This is how you track ownership of Windows clipboard in Win32

Reading time icon 3 min. read


Readers help support Windows Report. We may get a commission if you buy through our links. Tooltip Icon

Read our disclosure page to find out how can you help Windows Report sustain the editorial team Read more

Key notes

  • Microsoft’s Raymond Chen explains that, in Win32, there is the concept of a clipboard owner.
  • The clipboard owner gets a coded message when someone requests data from the clipboard.
  • The delay-rendering allows the user to postpone the creation of complicated clipboard data.
  • In this article, you can find out under what circumstances ownership of the clipboard changes.
Windows clipboard ownership in Win32

In a recent Microsoft blog post, Microsoft’s Raymond Chen explains for all the users out there, exactly how the ownership of the Windows clipboard is tracked in Win32.

This information may prove invaluable to some of the more enthusiastic and tech-savvy Windows users out there, as we are sure you can agree.

Tracking ownership of the Windows clipboard in Win32

As some of you may know, in Win32, there is the concept of a clipboard owner. The intended rule behind all this is that the clipboard owner is , actually, the window that created the data currently on the clipboard.

In this post, Chen also explains the specific usage pattern for putting data on the clipboard. He mentions that the clipboard owner receives a coded message when somebody requests data from the clipboard that had been set as delay-rendered.

These coded messages are also received as part of the window destruction sequence if it is still the owner of the clipboard at the time it is destroyed.

Thus, delay-rendering allows the user to defer the creation of complicated clipboard data up to the point it is requested.

Following the rules is of paramount importance

Raymond Chen mentions the fact that its very important to follow certain rules, when performing this process and points out that not everybody actually does it.

We can understand that, seeing how some programs open the clipboard with the intent of adding data, instead of replacing the content altogether.

Back in the days of 16-bit Windows, the system assumed that applications were honest and played by the rules for the common good.

He goes on by explaining that this bonus clipboard data scenario creates an issue, since there is only one clipboard owner, but there are now two windows who collaborated to put data onto the clipboard.

Ownership of the clipboard changes only under these circumstances, as explained by Chen:

  • When the empty clipboard command is deployed, the current clipboard opener becomes the clipboard owner.
  • When the clipboard owner is destroyed, the clipboard owner resets to null.

The only logical conclusion here would be that the clipboard owner can be summarized as the window that most recently called the empty keyboard command if it still exists.

All this useful information can be browsed by reading the complete article submitted on the Microsoft blog.

What is your take on the methods presented by the Microsoft employee? Let us know all about it in the comments section below.

More about the topics: windows 10