Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WM_DRAWCLIPBOARD Clipboard monitor call question 1

Status
Not open for further replies.

bajdev

Programmer
Aug 15, 2005
13
0
0
US
I have an application written in C# that monitors any clipboard activity. Everything works great as far as registering the application as a clipboardviewer, calling an event when a passing the clipboard chain on and then unregistering.

In a nutshell the application keeps the last 5 items that were cut or copied to the clipboard. If you click on any one of the 5 history items, the item you click on is put on the active clipboard (essentially copied).

My problem is when my application places text on the clipboard it fires the clipboard event and adds the item to the clipboard history again.

Does anyone have any insight as to how I could work around this? At first I thought maybe if I could find out which application was making the original clipboard call I could ignore my applications calls. That' won't work though because if actual text is cut or copied within my application I want it to go in the history. The only time I want to ignore it is when I restore an old item to the current active clipboard.

Sorry I don't have any technical code examples to go along with my question. It's not the code, it's the approach that I'm stumped on.

Please let me know if you need any more information.

Any advice is greatly appreciated.

Thanks in advance,
bjordan

 
Okay, let's say you have 5 items in your 'history':

A, B, C, D, E

If you choose to copy B to the 'active' clipboard, the method to add this item to the history again is automatically fired. To prevent it from firing is very obscure since there's a simple way: before you execute any code in this method, first check wether the item already exists in the history. If it does, simply skip the code to add it again.

Regards, Ruffnekk
---
Is it my imagination or do buffalo wings taste just like chicken?
 
To prevent it from firing is very obscure since there's a simple way:" ... Wow isn't that the truth! I was making the problem a lot harder then it needed to be.

I have no idea why that never crossed my mind. It was late and I had been coding for a long time so it was all a blur. That's the excuse I'll stick with ... :)

I broke my number one rule. When fighting a problem, step back and simplify things.

Thanks again!
bjordan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top