PB/cc - Write to Clipboard 
Author Message
 PB/cc - Write to Clipboard

Can anyone tell me if:
  1) this code will cause any problems in the windows environment
     that isn't readily noticable
  2) there is an easier way of doing this

TIA,

FUNCTION fWriteToClipBoard (BYVAL Text AS STRING) AS LONG

  DIM Bytes AS LOCAL LONG
  DIM B_ptr AS LOCAL BYTE PTR
  DIM T_ptr AS LOCAL BYTE PTR

  IF ISFALSE OpenClipboard(0) THEN EXIT FUNCTION

  EmptyClipboard
  Bytes = LEN(Text)
  B_ptr = GlobalAlloc(0,bytes+1)
  T_ptr = STRPTR(Text)


  DO
    DECR Bytes

  LOOP UNTIL Bytes = 0

  SetClipboardData 7, BYVAL B_ptr
  CloseClipboard

  FUNCTION = -1

END FUNCTION  
   ____    _    ____      ____  _____
  |  _ \  / \  / ___) __ | ___)(_   _) Don Schullian

  |____//_/ \_\(____/\__/|_|     |_|    www.DASoftVSS.com
  ___________________________________   www.basicguru.com
      Vertical Software Solutions



Wed, 06 Jun 2001 03:00:00 GMT  
 PB/cc - Write to Clipboard
Don, try this (from the PBDLL clipboard example)

LOCAL Buffer AS STRING
' data is in "buffer"
hData = GlobalAlloc(%GMEM_MOVEABLE OR %GMEM_DDESHARE, LEN(Buffer))
hGlob = GlobalLock(hData)
POKE$ hGlob, Buffer
GlobalUnlock hData

--Lance.

Quote:

> Can anyone tell me if:
>   1) this code will cause any problems in the windows environment
>      that isn't readily noticable
>   2) there is an easier way of doing this

> TIA,

> FUNCTION fWriteToClipBoard (BYVAL Text AS STRING) AS LONG

>   DIM Bytes AS LOCAL LONG
>   DIM B_ptr AS LOCAL BYTE PTR
>   DIM T_ptr AS LOCAL BYTE PTR

>   IF ISFALSE OpenClipboard(0) THEN EXIT FUNCTION

>   EmptyClipboard
>   Bytes = LEN(Text)
>   B_ptr = GlobalAlloc(0,bytes+1)
>   T_ptr = STRPTR(Text)


>   DO
>     DECR Bytes

>   LOOP UNTIL Bytes = 0

>   SetClipboardData 7, BYVAL B_ptr
>   CloseClipboard

>   FUNCTION = -1

> END FUNCTION
>    ____    _    ____      ____  _____
>   |  _ \  / \  / ___) __ | ___)(_   _) Don Schullian

>   |____//_/ \_\(____/\__/|_|     |_|    www.DASoftVSS.com
>   ___________________________________   www.basicguru.com
>       Vertical Software Solutions

--
============================
 Lance Edmonds
 Email contacts:



============================


Thu, 07 Jun 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. MX Lookup with PB/CC or PB/DLL

2. TCPADDR for PB/DLL & PB/CC

3. Info on new PB/CC and PB/DLL

4. Announcing the JazzAge COM Wizard for PB/DLL and PB/CC

5. animated characters, speech input/output in PB/DLL and PB/CC

6. email enable PB/DLL-PB/CC using Outlook

7. SQL, ADO/OLE-DB programming in PB/DLL and PB/CC

8. NUL device not working in PB/CC?

9. dir_trav.bas pb/cc 2.11 directory traverse program

10. pb/cc REGEXPR example misleading

11. pb/cc 2.11 FORMAT$ question / suggestion

12. Buying PB/CC....??

 

 
Powered by phpBB® Forum Software