0

I've created a Clipboard viewer in the standard suggested way editing the WndProc as follows.

            case WM_DRAWCLIPBOARD:

                Logger.Main.LogMessage("Draw Clipboard event");
                if (OnClipboardChanged != null) {
                    OnClipboardChanged(this, new ViewChangeEventArgs());
                }
                WindowAPI.SendMessage(NextClipboardViewer, m.Msg, m.WParam, m.LParam);
                break;

            case WM_CHANGECBCHAIN:

                Logger.Main.LogMessage("Change CB Chain");
                if (m.WParam == NextClipboardViewer) {
                    NextClipboardViewer = m.LParam;
                }
                else {
                    WindowAPI.SendMessage(NextClipboardViewer, m.Msg, m.WParam, m.LParam);
                }
                break;

My application need just to be notified when new data is available in the clipboard. Things work fine and the messages are properly detected.

Sometimes (and this is very hard to reproduce) I receive a big number of WM_DRAWCLIPBOARD generated events generated with the same timestamp, associated with the same data in the clipboard. Any idea of what could cause this? Any suggestions on how to get more information about those messages?

Thanks.

Andrea Nagar
  • 1,233
  • 2
  • 13
  • 23
  • "It Happens" -- F. Gump – Chris Thornton Feb 18 '13 at 00:11
  • Thanks for th einfo Chris. How do you normally manage that. You check if the messages received are very close to one another and you ignore them? – Andrea Nagar Feb 18 '13 at 07:29
  • Yes. Usually what you want to do, is react just to the last event. That usually involves calling yourself back after everything has been quiet for 500ms or so. – Chris Thornton Feb 18 '13 at 21:57
  • What do you mean exactly. What I'm currently doing is processing the first call and ignore all the other calls that are very close in time to the one I processed. – Andrea Nagar Feb 19 '13 at 07:46

1 Answers1

0

You need create a global to store your last read clipboard data. Then, in your case WM_DRAWCLIPBOARD: method, compare to the last read, only process when the data is different.

Ray Wong
  • 1
  • 1