Clipbaord Library

Discussion in 'Questions (Windows Mobile)' started by albertstc01, Feb 10, 2015.

  1. albertstc01

    albertstc01 Member Licensed User

    How is a text string put on the clipboard using "SetData"?

    A simple one line code example would be appreciated.

    Thanks in advance.

    albertstc01
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Are you asking about B4A or Basic4ppc?
     
  3. albertstc01

    albertstc01 Member Licensed User

    I'm Asking about Basic4ppc.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    If I remember correctly you need to call Hardware.SetClipboardData.
     
  5. albertstc01

    albertstc01 Member Licensed User

    Erel
    >If I remember correctly you need to call Hardware.SetClipboardData.

    You are remembering the use of the Hardware Library not the Clipboard Library.
    I have already successfully used the Hardware Library with Code Line examples such as
    hw.SetClipboardData(StringVariable)and/or hw.SetClipboardData("This is put on the clipboard")
    And for getting clipboard text into a string variable
    clip = hw.GetClipboardData
    This is documented in the Hardware Library help file.
    The Hardware Library only works in the device NOT on the Desk Top
    The Clipboard Library should work in the device and on the Desk Top
    The only documentation for the Clipboard Library is from the Demo Program Below
    Sub Globals
    'Declare the global variables here.
    Dim formats(0)
    End Sub
    Sub App_Start
    cb.New1
    Form1.Show
    image1.Image = AppPath & "\MGAHue.bmp"
    cb.SetData(Image1.Image)
    formats() = cb.GetdataFormats
    If ArrayLen(formats()) > 0 Then
    For i = 0 To ArrayLen(formats()) - 1
    msg = msg & formats(i) & CRLF
    Next
    Msgbox(msg, "Formats on clipboard")
    Msgbox(cb.GetData("Text"))
    Else
    Msgbox("Clipboard empty!")
    End If
    End Sub
    ' the library requires .NET 2.0 and should work on device and desktop
    ' the most likely useful sorts of data are probably "Text" and "Bitmap"
    'DllVersion : returns the version of the library
    'SetData(thing AS Object) : puts 'thing' on the clipboard
    'GetData(sort As String) : returns any data of type 'sort' on the clipboard - sort is case sensitive
    'GetDataPresent(sort As String) : returns true if data of type 'sort' is on the clipboard - sort is case
    sensitive
    'GetDataFormats : returns an array of strings describing the sort of data on the clipboard

    I can successfully get text from the desk top clipboard into the text variable Stuff using my own programming
    code Line “stuff=cb.GetData("Text")”
    The example for setdata in the demo program “cb.SetData(Image1.Image)” is for a graphic not text.
    Can you work out how from this how set data can be used for text?
     
  6. agraham

    agraham Expert Licensed User

    The demo actually places some text data on the Clipboard in Sub bCopy_Click. Basically you just stick the object on the Clipboard and it works out what it is.
     
  7. albertstc01

    albertstc01 Member Licensed User

    Agraham, Yesterday at 4:36 PM
    >The demo actually places some text data on the Clipboard in Sub bCopy_Click. Basically you just >stick the object on the Clipboard and it works out what it is.

    Thanks Agraham for your response but I'm somewhat perplexed.
    >The demo actually places some text data on the Clipboard in Sub bCopy_Click. ???
    I can't see any Sub bCopy_Click in the demo code.
    >Basically you just stick the object on the Clipboard and it works out what it is. ???
    How do I stick the object on the clipboard that needs to be text from a text variable?
    Can you give me program code lines to do this?
    This what my original post asked for?

    Can Anyone Else provide the program code?

    My simple test program code runs only once. Form “form1” will need to be created with a control for “TextBox1” installed. The Cliboard.ddl has been installed for both device and desk top.
    When run on the PC the contents of what ever has been selected and put on the clipboard is placed in into the string variable “stuff” which is then put into TextBox1. Lines 8 & 9.
    This is working.

    Now can anyone provide the line of code or lines of code needed for the Clipboard Library (not the hardware library) to put the text content of a string variable such as the variable “clip” shown in my example into the clipboard?

    MY EXAMPLE:
    Sub Globals
    Form1.Show 'Declare the global variables here.
    End Sub
    Sub App_Start
    Form1.Show
    cb.New1
    stuff=cb.GetData("Text")
    TextBox1.Text=stuff

    '''''''''''''''''''''''''''''''''''''''''
    'This piece of my test program needs to have code added for placing text into the clipboard.

    clip="This text needs to be placed on the clipboard for pasting into a Notepad OR other text editor"

    'Can anyone provide the line or lines of code needed to put clip variable's text_
    'into the Clipboard?
    '''''''''''''''''''''''''''''''''''''''''
    End Sub
     
  8. agraham

    agraham Expert Licensed User

    Perhaps you don't have the correct demo.
     

    Attached Files:

  9. albertstc01

    albertstc01 Member Licensed User

    Thanks Agraham
    > Perhaps you don't have the correct demo.
    You are correct and thanks for the link.

    But! A problem, first on loading the new demo into my b4ppc. A warning came up that it was created for a later version and might not work properly. It doesn't.

    On clicking the copy button I get the error message “cb.SetData(Textbox1.Text) Error description. Value cannot be null. Parameter name data.”

    My current b4ppc version details are
    Basic4ppc Desktop
    Anywhere Software Version: 6.90
    Net Version 2.0.50727.5485

    It looks like I need to download an update for my b4ppc can any one tell me from where?

    Many Thanks in advance
    albertstc01
     
  10. agraham

    agraham Expert Licensed User

    You have the latest published version of Basic4ppc. I have my own rather highly modified private version that produces desktop applications only and that is the reason for the version warning. However I would have expected that code to run under version 6.90 anyway. Tomorrow I'll try loading 6.90 again and try it for myself and get back to you.
     
  11. agraham

    agraham Expert Licensed User

    I forgot about this comment in the demo code because this limitation does not apply to my modified desktop only version of Basic4ppc.
    Code:
    ' The library works properly only when optimised compiled
    '   as the IDE cannot pass most things to the Object parameter of SetData
    That error is expected behaviour for version 6.90 when run in the IDE. Compile it and it should run fine.

    There seems to be a Clipboard.dll, size of 4096 bytes, already in the Libraries folder of a version 6.90 installation. This version looks like it might run on the device as well as the desktop as it is marked "retargetable" internally. The available methods in this version differ from those in the Clipboard.dll in the archive I posted, size of 4,608, which looks like it will only run on the desktop. The demo in my archive documents that later desktop library. In the earlier library Clear is not present and ContainsData(format As String) is replaced by GetDataPresent(format As String) which has a different implementation internally, probably for compatibility with the Compact Framework which is a subset of the full Framework.

    Code:
    'GetDataPresent(sort As String) As Boolean : returns true if data of type 'sort' is on the clipboard - sort is case insensitive
    'DllVersion : returns the version of the library
    'GetData(sort As String) As Object : returns any data of type 'sort' on the clipboard - sort is case insensitive
    'GetDataFormats As String() : returns an array of strings describing the sort of data on the clipboard
    'SetData(thing As Object) : puts 'thing' on the clipboard
     
  12. albertstc01

    albertstc01 Member Licensed User

    Hi Agraham
    Thanks for the latest post.
    When my programming using the Clipboard Library is compiled to a Windows executable it it will get and set data to the PC clipboard.

    The target program listing I had running and using the hardware library for clipboard get and set data in the device has had the clipboard library installed in a copy and the code line references and syntax changed for the Clipboard Library.
    When compiled to a Windows executable it it will get and set data to the clipboard.

    I have and was using another program written in BBCbasic For Windows, but, by now using the b4ppc programming I can make updates easily for the device an (Axim X51) and the PC. A lot less work and frustration.

    I could not compile it to an executable for the Device using the desk top IDE. I could not run the listing in b4ppc on the Axim X51 using the Clipboard Library. But! Changing libraries and a few lines of code is simple and not time consuming.

    The programming I have is useful and I use it Daily.
    So many thanks for your time and consideration.
    albertstc01
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice