Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7861195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:36:28+00:00 2026-06-02T22:36:28+00:00

i want to save the changes in my clipboard. so i registered my application

  • 0

i want to save the changes in my clipboard. so i registered my application to get all the changes that happens to the Clipboard.

Using

    [DllImport("User32.dll")]
    protected static extern bool AddClipboardFormatListener(int hwnd);

and then

protected override void WndProc(ref Message m)
    {
switch (m.Msg)
        {
            case WM_CLIPBOARDUPDATE:
                OnClipboardChanged();
                break;
             ...
        }
     }

private void OnClipboardChanged()
{
    if (Clipboard.ContainsText())
        {
         MessageBox.Show(Clipboard.GetText().ToString());
        }
}

The Problem is:
When copying text from an application like visual studio or firefox, the OnClipboardChanged() function will be called twice or 3 times sometimes.

I think that those application will write the Data to the clipboard with different formats, this is why the function is called more than once.
But how would i prevent saving the same data because OnClipboardChanged() is being called more than once ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T22:36:41+00:00Added an answer on June 2, 2026 at 10:36 pm

    Because they’re opening/closing the clipboard multiple times. I’ve seen such madness before. Excel used to perform 24 separate operations when copying a chart.
    Instead of this (pseudocode):

    openClipboard
    for each format {
      place data on clipboard(format)
    }
    closeClipboard
    

    they’re probably doing this:

    for each format {
      openClipboard
      place data on clipboard(format)
      closeClipboard
    }
    

    Update: The usual mitigation strategy is to avoid reacting to every update, and react to the LAST update after a reasonable “settle time” has elapsed with no further clipboard notifications. 500ms will usually be more than adequate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to save a variable to be global variable on all screens i
I want to save and load my xml data using XmlReader. But I don't
I want to save changes made to my document. The easiest way to do
Case is I want to prompt a message (Do you want to save changes?)
If I want to save any changes in a table, previously saved in SQL
I have a problem here. DB: oracle 9i I want to save data changes
<%= link_to_remote <span class='button_sprite_star'></span>Save Changes, unsaved_changes = false; $('edit_content').submit();, :class=>save action_button %> I'm using
I'm writing a Excel class using Microsoft.Interropt.Excel DLL. I finish all function but I
I want the SaveChanges of the ObjectContext (Win apps) to save changes asynchronously, will
I have one model, which I save changes witch happens to certain person. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.