When some other program puts a delay rendered data to clipboard (by calling SetClipboardData(fmt, NULL)), my clipboard viewer gets WM_DRAWCLIPBOARD.
When my viewer calls GetClipboardData(), my window proc is called recursively with another WM_DRAWCLIPBOARD.
I can't find any description of that.
#define MY_CF CF_RIFF
LRESULT CALLBACK WindowProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg) {
case WM_DRAWCLIPBOARD:
OpenClipboard(hwnd);
HGLOBAL hglob = GetClipboardData(MY_CF); // Sends recursive WM_DRAWCLIPBOARD
break;
default:
return DefWindowProc( hwnd,uMsg,wParam,lParam);
}
return 0;
}
First, you don't handle
WM_DRAWCLIPBOARD
properly you should let the message forward to other windowsSecond, unfortunately receiving many
WM_DRAWCLIPBOARD
is common. By experience it's common to receive between 0 and 4.The ugly trick (which works) is to get timestamps on each call, and if it's too close to the previous one simply ignore.