Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to use WM_PASTE ?

How to use WM_PASTE ?

Scheduled Pinned Locked Moved C#
questionalgorithmshelptutorial
9 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mahmoud EL Shazly
    wrote on last edited by
    #1

    Hello, How can I use WM_PASTE to send a plain text from clipboard to the active window and the focused textbox/combobox ? ---------- I want to paste by double-Click, I can detect the double click event and execute a code when it done so the destination window will be active the textbox/combobox will be focused please provide me a little sample project working with a timer in background and do the paste command. I keep searching for a solution to this problem for days but no results ------------------- Thanks

    JusT LeT YouR MinD WorK

    S L B S 5 Replies Last reply
    0
    • M Mahmoud EL Shazly

      Hello, How can I use WM_PASTE to send a plain text from clipboard to the active window and the focused textbox/combobox ? ---------- I want to paste by double-Click, I can detect the double click event and execute a code when it done so the destination window will be active the textbox/combobox will be focused please provide me a little sample project working with a timer in background and do the paste command. I keep searching for a solution to this problem for days but no results ------------------- Thanks

      JusT LeT YouR MinD WorK

      S Offline
      S Offline
      Sivaraman Dhamodharan
      wrote on last edited by
      #2

      WM_PASTE is the message sent to the Window in which Paste operation takes place. Refer: Link[^]

      Programming Article

      M 1 Reply Last reply
      0
      • M Mahmoud EL Shazly

        Hello, How can I use WM_PASTE to send a plain text from clipboard to the active window and the focused textbox/combobox ? ---------- I want to paste by double-Click, I can detect the double click event and execute a code when it done so the destination window will be active the textbox/combobox will be focused please provide me a little sample project working with a timer in background and do the paste command. I keep searching for a solution to this problem for days but no results ------------------- Thanks

        JusT LeT YouR MinD WorK

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        This message must be handled by the receiving window. When you receive a WM_PASTE[^] message, it is your responsibility to deal with it. You should generally read the contents of the clipboard and past them onto your window, or wherever else your program wishes.

        Veni, vidi, abiit domum

        1 Reply Last reply
        0
        • M Mahmoud EL Shazly

          Hello, How can I use WM_PASTE to send a plain text from clipboard to the active window and the focused textbox/combobox ? ---------- I want to paste by double-Click, I can detect the double click event and execute a code when it done so the destination window will be active the textbox/combobox will be focused please provide me a little sample project working with a timer in background and do the paste command. I keep searching for a solution to this problem for days but no results ------------------- Thanks

          JusT LeT YouR MinD WorK

          B Offline
          B Offline
          BillWoodruff
          wrote on last edited by
          #4

          Are you programming C# ? In WinForms ? WPF ? In C# WinForms doing what you describe is very simple: if you create two TextBoxes, and define DoubleClick EventHandlers for them as shown here:

              private void textBox1\_DoubleClick(object sender, EventArgs e)
              {
                  if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
                  {
                      Clipboard.SetText(textBox1.Text);
                  }
              }
          
              private void textBox2\_DoubleClick(object sender, EventArgs e)
              {
                  if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
                  {
                      textBox2.Text = Clipboard.GetText();
                  }
              }
          

          Then the Text of textBox1 will be placed on the Clipoard when textBox1 is double-clicked, and whatever text is on the Clipboard will be pasted into textBox2, when it's double-clicked. imho, use of DoubleClick in a TextBox is generally not a good idea, because of the way the TextBox uses double-click as a method for selection. I assume you have a good reason for wanting to duplicate paste-and-copy functionality.

          Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview

          1 Reply Last reply
          0
          • M Mahmoud EL Shazly

            Hello, How can I use WM_PASTE to send a plain text from clipboard to the active window and the focused textbox/combobox ? ---------- I want to paste by double-Click, I can detect the double click event and execute a code when it done so the destination window will be active the textbox/combobox will be focused please provide me a little sample project working with a timer in background and do the paste command. I keep searching for a solution to this problem for days but no results ------------------- Thanks

            JusT LeT YouR MinD WorK

            B Offline
            B Offline
            BillWoodruff
            wrote on last edited by
            #5

            I assume, since you posted on this Forum, you are using C# ... correct ? Please state in what context you are using C#: WinForms ? WPF ? SilverLight ? ... ? Whatever you are using: what is it that you double-click on that triggers the Paste Event into the "destination window ... active ... textbox/combobox" ? Are you saying you want to detect a double-click Event anywhere in your application's main window, or in its child controls ? Does that imply you want to disable the standard double-click functions that occur in certain controls, like a TextBox ? Not a good idea. If you double-click on a WinForm the focus of the application may change, depending on what you clicked on; there may be no active Control. For example, if I have a TextBox and a PropertyGrid on a WinForm: if the TabOrder is set so that the TextBox is the Control with Focus when the application starts, then if I click on the PropertyGrid there is no active control on the Form. However, if I double-click on the Form itself, then Form.ActiveControl will still retain its last valid setting. I doubt anyone here is psychic enough (unless OriginalGriff is here) to figure out what the role of a Timer is in whatever you are trying to build. If you take the time to describe your problem in detail, I do think we can help you search more "smartly," however. You may be "spinning your wheels" right now as a result of "trying too hard:" that happens to me :)

            Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview

            OriginalGriffO M 2 Replies Last reply
            0
            • M Mahmoud EL Shazly

              Hello, How can I use WM_PASTE to send a plain text from clipboard to the active window and the focused textbox/combobox ? ---------- I want to paste by double-Click, I can detect the double click event and execute a code when it done so the destination window will be active the textbox/combobox will be focused please provide me a little sample project working with a timer in background and do the paste command. I keep searching for a solution to this problem for days but no results ------------------- Thanks

              JusT LeT YouR MinD WorK

              S Offline
              S Offline
              Simon_Whale
              wrote on last edited by
              #6

              This not help ? how to copy to clipboard how to copy data to the clipboard[^] how to paste from clipboard http://social.msdn.microsoft.com/Forums/windows/en-US/8c677273-77bf-4423-a799-528e3aed837e/c-paste-from-clipboard[^]

              Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON

              1 Reply Last reply
              0
              • B BillWoodruff

                I assume, since you posted on this Forum, you are using C# ... correct ? Please state in what context you are using C#: WinForms ? WPF ? SilverLight ? ... ? Whatever you are using: what is it that you double-click on that triggers the Paste Event into the "destination window ... active ... textbox/combobox" ? Are you saying you want to detect a double-click Event anywhere in your application's main window, or in its child controls ? Does that imply you want to disable the standard double-click functions that occur in certain controls, like a TextBox ? Not a good idea. If you double-click on a WinForm the focus of the application may change, depending on what you clicked on; there may be no active Control. For example, if I have a TextBox and a PropertyGrid on a WinForm: if the TabOrder is set so that the TextBox is the Control with Focus when the application starts, then if I click on the PropertyGrid there is no active control on the Form. However, if I double-click on the Form itself, then Form.ActiveControl will still retain its last valid setting. I doubt anyone here is psychic enough (unless OriginalGriff is here) to figure out what the role of a Timer is in whatever you are trying to build. If you take the time to describe your problem in detail, I do think we can help you search more "smartly," however. You may be "spinning your wheels" right now as a result of "trying too hard:" that happens to me :)

                Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview

                OriginalGriffO Online
                OriginalGriffO Online
                OriginalGriff
                wrote on last edited by
                #7

                I refuse to remove my tin-foil hat for this one! :laugh:

                The only instant messaging I do involves my middle finger.

                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                1 Reply Last reply
                0
                • S Sivaraman Dhamodharan

                  WM_PASTE is the message sent to the Window in which Paste operation takes place. Refer: Link[^]

                  Programming Article

                  M Offline
                  M Offline
                  Mahmoud EL Shazly
                  wrote on last edited by
                  #8

                  I understand this all what I need is a simple example to know how to do it

                  JusT LeT YouR MinD WorK

                  1 Reply Last reply
                  0
                  • B BillWoodruff

                    I assume, since you posted on this Forum, you are using C# ... correct ? Please state in what context you are using C#: WinForms ? WPF ? SilverLight ? ... ? Whatever you are using: what is it that you double-click on that triggers the Paste Event into the "destination window ... active ... textbox/combobox" ? Are you saying you want to detect a double-click Event anywhere in your application's main window, or in its child controls ? Does that imply you want to disable the standard double-click functions that occur in certain controls, like a TextBox ? Not a good idea. If you double-click on a WinForm the focus of the application may change, depending on what you clicked on; there may be no active Control. For example, if I have a TextBox and a PropertyGrid on a WinForm: if the TabOrder is set so that the TextBox is the Control with Focus when the application starts, then if I click on the PropertyGrid there is no active control on the Form. However, if I double-click on the Form itself, then Form.ActiveControl will still retain its last valid setting. I doubt anyone here is psychic enough (unless OriginalGriff is here) to figure out what the role of a Timer is in whatever you are trying to build. If you take the time to describe your problem in detail, I do think we can help you search more "smartly," however. You may be "spinning your wheels" right now as a result of "trying too hard:" that happens to me :)

                    Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview

                    M Offline
                    M Offline
                    Mahmoud EL Shazly
                    wrote on last edited by
                    #9

                    I have no problem with double-click event it is already working without any problem All what I need is to paste from clipboard to the active window and the focused textbox I tried SendMessage and PostMessage but it is not working with me

                    JusT LeT YouR MinD WorK

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups