locked
WM_DRAWCLIPBOARD event doesn't get fired when clipboard contents changed RRS feed

  • Question

  • Hi, I have been working on Clipboard monitoring application and I am facing problem of clipboard chain broken. Sometimes it happens that some application registered into the clipboard chain and terminated without unregistered which leaves all other applications in clipboard chain without having clipboard change events.  Baically WM_DRAWCLIPBOARD event doesn't get fired.
     
    Could you please help on my below questions. It would be really helpful for me.
     
            1. How many clipboard chain will be there and how it differs from application X to application Y?
            2. Sometime it happens that some application X getting clipboard event changes but not other application Y. How this could be possible?
            3. If some how clipboard chain broken then is there any way to take all application into that chain back to working clipboard chain?
     
    Please let me know if you need any other details.
     
    Thanks,
    Megha
    Wednesday, July 1, 2009 1:31 PM

Answers

  • The API is desperately obsolete, there wasn't any way to fix it in the Win32 API due to the implementation.

    1: there's only one, that's the problem.
    2: they are notoriously written to assume they are the only viewer the user cares about.
    3: no, the link got lost along with the program that terminated.

    No happy answers here.

    Hans Passant.
    Thursday, September 24, 2009 12:46 AM
    Moderator

All replies

  • I am not sure:
    a) whether we checked the WindowProc function? What is the result. Certainly this is a must and needs to be checked. Please note: This is an application-defined function that processes messages sent to a window. Also this acts as the placeholder for the application-defined function name. Also i am interested to know about the relevant handles?
    b) Make sure we implement the exception handling?
    c) Make sure we release unused objects in a periodical basis?
    c) Also can you check that the event triggers or not? Please bifurcate the issue, by implementing custom log or flag mechnism to verify according to your logic.

    As we know, Only clipboard viewer windows receive this message. These are windows that have been added to the clipboard viewer chain by using the SetClipboardViewer function. We need to note: Each window that receives the WM_DRAWCLIPBOARD message must call the SendMessage function to pass the message on to the next window in the clipboard viewer chain. The handle to the next window in the chain is returned by SetClipboardViewer, and may change in response to a WM_CHANGECBCHAIN message.
    DeVa, M.S., {MSFT}
    Wednesday, September 23, 2009 11:01 PM
  • The API is desperately obsolete, there wasn't any way to fix it in the Win32 API due to the implementation.

    1: there's only one, that's the problem.
    2: they are notoriously written to assume they are the only viewer the user cares about.
    3: no, the link got lost along with the program that terminated.

    No happy answers here.

    Hans Passant.
    Thursday, September 24, 2009 12:46 AM
    Moderator
  • >> Each window that receives the WM_DRAWCLIPBOARD message must call the SendMessage function to pass the message on to the next windo...
    Deva, this is expected but not the restriction from windows OS. What if there are some faulty application like KeePass1.06 which register itself into clipboard chain and doesn't send clipboard modified messages to next application in queue? The all other applications in queue suffers because of this single application. Also there is another case I found is when registered application abnormally terminated leaves the chain broken.

    I really surprised by Windows OS such implementation. The only problem here is Windows made clipboard functionality Application oriented. Ideally, it should be handle by OS itself. I heard that this has been taken care in Windows Vista but never tried.

    I am desperate to know the idea behind this weird(at least for me) implementation. Could you provide any details on why this implementation was designed and implemented such a way?

    I logged this question when I wasn't aware of much details about Clipboard functionality but now I think I knows A-Z of how it works.

    Thanks.
    Thursday, September 24, 2009 6:56 AM
  • I managed to solve this problem by unregister/register myself every 1 minute so that i will always be the first in the chain.

    Then no matter how others do, i'll get noticed when the clipboard is changed.

    Saturday, March 27, 2010 11:26 AM
  • KingMario, Initially I had done the similar but I would say it is not efficient way to resolve the issue and also not 100% full-proof. You should register only when required. I also resolved my issue with the same concept long back.

    Cheers!

    Saturday, May 1, 2010 1:22 PM