Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Code Samples & Tips > Additional Libraries
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Additional Libraries Users contributed libraries.
This sub-forum is only available to licensed users.

Clippboard access library

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-01-2008, 10:34 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default Clippboard access library

This small library provides access to the clipboard. It is very simple so the help is in the demo app. Requires .NET 2.0 and should run on both device and desktop. The clipboard.cs source file is supplied for merging the dll. Put it in the Basic4ppc Desktop\Libraries folder.

EDIT :- It appears that this library will only operate correctly when in an optimised compiled app due to what seems to be a threading issue in the IDE and legacy compiled apps.
Attached Files
File Type: zip Clipboard1.0.zip (3.2 KB, 243 views)

Last edited by agraham : 06-04-2008 at 03:17 PM.
Reply With Quote
  #2 (permalink)  
Old 06-02-2008, 10:18 AM
Senior Member
 
Join Date: Apr 2007
Location: Copenhagen
Posts: 173
Default

Thank you Andrew, very nice !

Best wishes / Björn
Reply With Quote
  #3 (permalink)  
Old 06-03-2008, 05:21 PM
Senior Member
 
Join Date: Apr 2007
Location: Copenhagen
Posts: 173
Default

Sorry Andrew, despite it being very simple I still have problems with it

In the attached program I can copy the content of a richtextbox with no problems. When I try to do the same from a "normal" textbox I get an error message however. Does this mean that only objects added from a .dll count as objects for the clipboard dll?

all the best / Björn
Attached Files
File Type: zip Test clipboard.zip (8.4 KB, 58 views)
Reply With Quote
  #4 (permalink)  
Old 06-03-2008, 06:32 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

I think it is some obscure threading problem as your code seems to work fine when optimised compiled and and my demo worked in the IDE when I was testing.

The IDE error implies that textbox1.text is null (which is not the case) however if you continue after the error it now works OK. It also works if you copy the RTF first! If I legacy compile both my demo and your code I get this error :

"Current thread must be set to single thread apartment mode before OLE calls can be made. Ensure that your Main function has STA ThreadAttribute marked on it."

This is required as the clipboard in .NET calls the native clipboard code which is a COM object which needs an STA host. However Erel has told me that Basic4ppc IS now STA threaded (which is why I couldn't produce this library and the WebBrowser before as both are COM objects needing STA) so I have no idea why it is throwing this error.

Perhaps Erel can shed some light on this if he reads this!

The RichTextTextbox has a workaround for this threading problem, which I thought had now gone away with the change in threading for B4ppc so I will try to to produce a version of the clipboard library incorporating this workaround.
Reply With Quote
  #5 (permalink)  
Old 06-03-2008, 09:51 PM
Senior Member
 
Join Date: Apr 2007
Location: Copenhagen
Posts: 173
Default

Thank you for explaining that - I couldn't understand what the error was about... / Björn
Reply With Quote
  #6 (permalink)  
Old 06-04-2008, 11:13 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

I'm sorry Björn but there seems to be a fundamental incompatibility between the .NET clipboard object and both the IDE and legacy compiler on both desktop and device. While things work as I expect when optimised compiling they don't otherwise. I can't even get the workaround that I used in RichTextDesktop to work in this library while it still seems to work fine in the RichTextDesktop libray

It looks like this is a device and desktop optimised compile library only.
Reply With Quote
  #7 (permalink)  
Old 06-04-2008, 11:27 AM
Senior Member
 
Join Date: Apr 2007
Location: Copenhagen
Posts: 173
Default

Dear Andrew, thank you for looking into it.

The most important thing is that it does work in the optimised, compiled version. Perhaps we can hope for a new compiler for the IDE

all the best / Björn
Reply With Quote
  #8 (permalink)  
Old 06-04-2008, 03:53 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

The thread which runs the code in the IDE is set to "single thread apartment".
Maybe the problem is caused due to the fact that there is another thread (the main thread in the IDE) that is STA in the same process.
For now you will only be able to use this library with the optimized compiler.
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Support for Access databases Peter Basic4ppc Wishlist 3 03-18-2008 11:39 AM
Control properties library (access TabIndex & TabStop) agraham Additional Libraries 1 02-21-2008 02:15 PM
Network access skipper Questions (Windows Mobile) 4 02-19-2008 08:21 AM
Access to Outlook contacts Big JR Code Samples & Tips 3 09-26-2007 10:16 AM
How to access the 2nd dimension hung Questions (Windows Mobile) 4 08-15-2007 04:24 AM


All times are GMT. The time now is 10:38 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0