WM_CLIPBOARDUPDATE issue

drjackool 956 Reputation points
2023-07-09T20:35:38.28+00:00

hi I registered my window to listen clipboard by AddClipboardFormatListener and when my window recieve WM_CLIPBOARDUPDATE I tried accessing clipboard data by isclipboardformatavailable and openclipboard data for cf_unicodetext by they fails! to solve this issue I use Sleep function with delay about 100ms before accessing clipboard and when I using sleep they works fine! this issue happens when I run my app on Win11 (some times its works but most of times not works) but when running it on Win7 (virtualbox) it works fine without sleep function. What is correct way to solve this issue? thanks

Windows development | Windows API - Win32
{count} votes

Answer accepted by question author
  1. RLWA32 51,456 Reputation points
    2023-07-13T10:02:09.7866667+00:00

    Following demonstrates using a timer to handle OpenClipboard failures. Multiple instances of the clipboard format listener are running, and the DebugView output shows the number of times each instance tried to open the clipboard before it succeeded. In this example a 50ms interval was used for the timer. The image also demonstrates that the WM_CLIPBOARDUPDATE message is not posted until the clipboard is closed.

    ClipboardUpdate

    The next image shows results without using a timer or looping. The error message indicates which process has the clipboard open which causes the OpenClipboard function failure.

    ClipboardNoTimer

    2 people found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.