Clipboard Clears on Application Closure
Clipboard Clears on Application Closure
Clipboard Clears on Application Closure
Clipboard Clears on Application Closure
Clipboard Clears on Application Closure
Clipboard Clears on Application Closure Clipboard Clears on Application Closure Clipboard Clears on Application Closure Clipboard Clears on Application Closure Clipboard Clears on Application Closure Clipboard Clears on Application Closure Clipboard Clears on Application Closure Clipboard Clears on Application Closure
Clipboard Clears on Application Closure Clipboard Clears on Application Closure
Clipboard Clears on Application Closure
Go Back  Xtreme Visual Basic Talk > > > Clipboard Clears on Application Closure


Reply
 
Thread Tools Display Modes
  #1  
Old 09-16-2014, 06:28 AM
bobcory's Avatar
bobcory bobcory is offline
Contributor
 
Join Date: Jun 2003
Location: NW UK
Posts: 454
Question Clipboard Clears on Application Closure


I find that the clipboard is cleared when I close my application (written in Vb.net - VS 2013)

Anybody else find this? I do have clipboard write events in the program but it does not seem to be firing them on closure (I have put message boxes in the code to check that)
__________________
MOPEKS - a freeware program that generates programs that use each other to solve problems. Is this the correct route to a genuinely intelligent machine?
.
Reply With Quote
  #2  
Old 09-16-2014, 07:24 AM
Roger-U Roger-U is offline
Centurion
 
Join Date: Apr 2008
Location: Surrey, UK
Posts: 111
Default

There is a parameter for that:

Clipboard.SetDataObject(u, True)

The 'True' specifies to leave the data on the clipboard when the application closes
Reply With Quote
  #3  
Old 09-19-2014, 05:19 AM
bobcory's Avatar
bobcory bobcory is offline
Contributor
 
Join Date: Jun 2003
Location: NW UK
Posts: 454
Default

Quote:
Originally Posted by Roger-U View Post
There is a parameter for that:

Clipboard.SetDataObject(u, True)

The 'True' specifies to leave the data on the clipboard when the application closes
Wow! Who knew? The wisdom of crowds ... thank you

I experimented a bit and this works. The problem is that SetDataObject clears the clipboard and then puts "u" into the clipboard.

So, this retrieves it and puts it back on - cumbersome but better than nothing

Code:
Clipboard.SetDataObject(Clipboard.GetDataObject(),  True)
End
I have not tested this with images ... but I guess it should work ...
__________________
MOPEKS - a freeware program that generates programs that use each other to solve problems. Is this the correct route to a genuinely intelligent machine?
.

Last edited by bobcory; 09-19-2014 at 05:30 AM.
Reply With Quote
  #4  
Old 09-21-2014, 10:24 AM
Roger-U Roger-U is offline
Centurion
 
Join Date: Apr 2008
Location: Surrey, UK
Posts: 111
Default

Just a guess.. but maybe:

Clipboard.SetDataObject(Nothing, True)

Probably not... but if you don't ask. Yes I know ... I should try it myself!
Reply With Quote
  #5  
Old 09-22-2014, 03:49 AM
bobcory's Avatar
bobcory bobcory is offline
Contributor
 
Join Date: Jun 2003
Location: NW UK
Posts: 454
Default

Quote:
Originally Posted by Roger-U View Post
Just a guess.. but maybe:

Clipboard.SetDataObject(Nothing, True)

Probably not... but if you don't ask. Yes I know ... I should try it myself!
"Computer says no"

To be more precise, it causes an error. It is hard to see how it could work, really, because this method seems to work as follows:

1. Clear the clipboard
2. Clipboard content = u

So the above would, if it worked, just set the content to Nothing!?

But the original tip was very much appreciated, so thank you!

Edit:

So, why does the following work? On my logic it should wipe it out if it passes it ByRef

Code:
Clipboard.SetDataObject(Clipboard.GetDataObject(),  True)
Presumably, because it works as follows:

1. u = Clipboard.GetDataObject() ie passed ByVal
2. Clear clipboard
3. Clipboard = u

as opposed to:

1. Clear clipboard
1. u = Clipboard.GetDataObject() ' Giving nothing
3. Clipboard = u ' Giving nothing


Anyway it works!
__________________
MOPEKS - a freeware program that generates programs that use each other to solve problems. Is this the correct route to a genuinely intelligent machine?
.

Last edited by bobcory; 09-22-2014 at 04:02 AM.
Reply With Quote
  #6  
Old 09-22-2014, 08:15 AM
Roger-U Roger-U is offline
Centurion
 
Join Date: Apr 2008
Location: Surrey, UK
Posts: 111
Default

it works because it's just a normal function call - so it evaluates any functions used as parameters before calling the top function.

so by the time Clipboard.SetDataObject is called it knows nothing about how its parameters were derived.

If you use the result of a function as a ByRef parameter then the ByRef is pretty meaningless as there is no useable object for the method to pass the new value back into.

I don't think I explained that very well
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Clipboard Clears on Application Closure
Clipboard Clears on Application Closure
Clipboard Clears on Application Closure Clipboard Clears on Application Closure
Clipboard Clears on Application Closure
Clipboard Clears on Application Closure
Clipboard Clears on Application Closure Clipboard Clears on Application Closure Clipboard Clears on Application Closure Clipboard Clears on Application Closure Clipboard Clears on Application Closure Clipboard Clears on Application Closure Clipboard Clears on Application Closure
Clipboard Clears on Application Closure
Clipboard Clears on Application Closure
 
Clipboard Clears on Application Closure
Clipboard Clears on Application Closure
 
-->