Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# catch clipboard changes, wont work if form minimized to tray

i have a problem using the "Catch Clipboard Events code" found on this link :

Clipboard event C#

the code works great only if the form stays in the foreground, not minimized to tray BUT: if you add a notifyicon and minimize the form to tray and turn the showintaskbar to false (so that you only have an icon in the tray), the program wont catch any clipboard changes anymore ... even if you maximize the form back, it wont work again ...you have to restart the program ..

any idea on how to solve this issue !? how can i catch clipboard changes, even if the form is minimized into the tray !?

any help is really appreciated ...

Thanks

like image 848
lebhero Avatar asked Mar 21 '10 23:03

lebhero


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

Is C language easy?

Compared to other languages—like Java, PHP, or C#—C is a relatively simple language to learn for anyone just starting to learn computer programming because of its limited number of keywords.

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.

What is C language?

C is an imperative procedural language supporting structured programming, lexical variable scope, and recursion, with a static type system. It was designed to be compiled to provide low-level access to memory and language constructs that map efficiently to machine instructions, all with minimal runtime support.


1 Answers

It should work if minimized - really minimized though, or hidden. If your implementation of "minimized" invovles destroying the window, then that handle is invalid. And the clipboard chain is now broken for whatever was listening to clipboard events downstream...

Throw some debug code in there to display this.Handle as a string (ex: "123456"). Put the call to SetClipboardViewer in a click event on the form. Click it, see the number. Minimize, restore. Click again. Do you have the same number? you should. If not, then there lies the problem. The clipboard events MUST go to a window that stays around. It can be a hidden window in the background.

-- Chris

like image 193
Chris Thornton Avatar answered Oct 01 '22 13:10

Chris Thornton