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. Visual Basic
  4. VB.NET Clipboard Change

VB.NET Clipboard Change

Scheduled Pinned Locked Moved Visual Basic
csharptutorial
5 Posts 2 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.
  • J Offline
    J Offline
    jordan2000
    wrote on last edited by
    #1

    Hello, I am writing a program and i need to catch the change clipboard msg to start a event. The program is a ScreenDump program so you will understand this short qeustion. I know how to put and get data in or out the clipboard. maybe you can give me a code sample on how the change clipboard msg works after pressing toe Snapshot key. thank you in advanced. Jordan2000

    D 1 Reply Last reply
    0
    • J jordan2000

      Hello, I am writing a program and i need to catch the change clipboard msg to start a event. The program is a ScreenDump program so you will understand this short qeustion. I know how to put and get data in or out the clipboard. maybe you can give me a code sample on how the change clipboard msg works after pressing toe Snapshot key. thank you in advanced. Jordan2000

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      I'm a bit confused... You're already putting the data on the clipboard and taking it off? If that's the case, why would you need to detect the change in the clipboard? BTW: There is no clipboard changed event... RageInTheMachine9532

      J 1 Reply Last reply
      0
      • D Dave Kreskowiak

        I'm a bit confused... You're already putting the data on the clipboard and taking it off? If that's the case, why would you need to detect the change in the clipboard? BTW: There is no clipboard changed event... RageInTheMachine9532

        J Offline
        J Offline
        jordan2000
        wrote on last edited by
        #3

        I am sorry the question was not clear. ok when i pres on the snapshot key i want that the screendump to be saved. there is a kinde of hook in the clipboard event that i can tap in but i cant find out how it works. WMDrawClipboard i found on msdn but the explenation is not clear. and cant find a soutable code sample fore VB.NET

        D 2 Replies Last reply
        0
        • J jordan2000

          I am sorry the question was not clear. ok when i pres on the snapshot key i want that the screendump to be saved. there is a kinde of hook in the clipboard event that i can tap in but i cant find out how it works. WMDrawClipboard i found on msdn but the explenation is not clear. and cant find a soutable code sample fore VB.NET

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Are you saying the when a user presses PrtScrn or Alt-PrtScrn, you want you app to be notified that there is something new on the clipboard? If that's true, now I understand... Ummm...OK. Your going to have to override the WndProc function in your form to receive the WM_DRAWCLIPBOARD message and process it. You'll also need to process WM_CHANGECBCHAIN too if other applications register as clipboard viewers, you can repair the end of the chain if your suddently the last in the chain. You'll need to use the SendMessage, SetClipBoardViewer and ChangeClipboardChain functions, in user32.dll, and GetLastError, in kernel32, to handle this. What your going to do is when your app starts, call SetClipBoardViewer with the window handle of your form. You'll have to save the return value as this is the handle of the next window in the clipboard viewer chain. Next, call GetLastError to see if what you got back was an error or a null handle. Now, in you WndProc procedure, when you get the WM_DRAWCLIPBOARD message, you can use the standard .NET Clipboard functions to get the image from the clipboard and display it in a PictureBox if need be. You'll then need to use SendMessage to send the same message you got to the next window in the chain, (remember that return value from SetClipBoardViewer?) unless it's null. Now, you may be wondering why you have to handle WM_CHANGECBCHAIN. This is because if the next window in the chain is the one that your supposed to send the WM_DRACLIPBOARD to, you'll need to know that it's been removed and you no longer have to send that message, or you'll need to send it to a different window now. . . I've lost you, haven't I...? Last but not least, when your app quits, you have to remove yourself from the viewer chain. This is done by calling ChangeClipboardChain with your window handle and the window handle of the window your supposed to be forwarding WM_DRAWCLIPBOARD messages to. Simple, no? :) RageInTheMachine9532

          1 Reply Last reply
          0
          • J jordan2000

            I am sorry the question was not clear. ok when i pres on the snapshot key i want that the screendump to be saved. there is a kinde of hook in the clipboard event that i can tap in but i cant find out how it works. WMDrawClipboard i found on msdn but the explenation is not clear. and cant find a soutable code sample fore VB.NET

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            jordan2000 wrote: cant find a soutable code sample fore VB.NET That's because there really isn't any. Registering as a clipboard viewer is not a common operation at all. You'll have to piece together example, like overriding WndProc and calling into the Win32 API. But, there is no simple way to do this. There is no event that is fired when the clipboard changes, so you have to go thru the Win32 API pain of registering for notifications yourself. RageInTheMachine9532

            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