Copying to Clipboard using API calls 
Author Message
 Copying to Clipboard using API calls

Hi,
I am trying to copy to the clipboard using API calls.
The following code doesn't seem to work, can anybody please help me!!!!
Thanks
GRaham

Private Sub Command1_Click()

Dim hMem As Long
Dim lmem As Long
Dim clip As Long
Dim x As Long
Dim J As String
strX = "Test"

hMem = GlobalAlloc(ghnd, Len(strX) + 1)

lmem = GlobalLock(hMem)
lmem = lstrcpy(lmem, strX)
dd = Me.hwnd
If GlobalUnlock(hMem) <> 0 Then '
    MsgBox "Memory Error"
End If

x = OpenClipboard(dd)
x = EmptyClipboard()

clip = SetClipboardData(CF_TEXT, hMem)

x = CloseClipboard
End Sub

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sat, 15 Jun 2002 03:00:00 GMT  
 Copying to Clipboard using API calls
There is a complete sample near the bottom of my web page
that may be of some use to you.

http://www.users.uswest.net/~sdiggins/bcx.htm

Quote:

> Hi,
> I am trying to copy to the clipboard using API calls.
> The following code doesn't seem to work, can anybody please help me!!!!
> Thanks
> GRaham

> Private Sub Command1_Click()

> Dim hMem As Long
> Dim lmem As Long
> Dim clip As Long
> Dim x As Long
> Dim J As String
> strX = "Test"

> hMem = GlobalAlloc(ghnd, Len(strX) + 1)

> lmem = GlobalLock(hMem)
> lmem = lstrcpy(lmem, strX)
> dd = Me.hwnd
> If GlobalUnlock(hMem) <> 0 Then '
>     MsgBox "Memory Error"
> End If

> x = OpenClipboard(dd)
> x = EmptyClipboard()

> clip = SetClipboardData(CF_TEXT, hMem)

> x = CloseClipboard
> End Sub

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sat, 15 Jun 2002 03:00:00 GMT  
 Copying to Clipboard using API calls
why not just make a clipboard object?

trippz


Quote:
> Hi,
> I am trying to copy to the clipboard using API calls.
> The following code doesn't seem to work, can anybody please help me!!!!
> Thanks
> GRaham

> Private Sub Command1_Click()

> Dim hMem As Long
> Dim lmem As Long
> Dim clip As Long
> Dim x As Long
> Dim J As String
> strX = "Test"

> hMem = GlobalAlloc(ghnd, Len(strX) + 1)

> lmem = GlobalLock(hMem)
> lmem = lstrcpy(lmem, strX)
> dd = Me.hwnd
> If GlobalUnlock(hMem) <> 0 Then '
>     MsgBox "Memory Error"
> End If

> x = OpenClipboard(dd)
> x = EmptyClipboard()

> clip = SetClipboardData(CF_TEXT, hMem)

> x = CloseClipboard
> End Sub

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sun, 16 Jun 2002 03:00:00 GMT  
 Copying to Clipboard using API calls
I need to be able to do it using API as I am writing it for a program
called Saleslogix which does not support objects.

Thanks
Graham



Quote:
> why not just make a clipboard object?

> trippz



> > Hi,
> > I am trying to copy to the clipboard using API calls.
> > The following code doesn't seem to work, can anybody please help
me!!!!
> > Thanks
> > GRaham

> > Private Sub Command1_Click()

> > Dim hMem As Long
> > Dim lmem As Long
> > Dim clip As Long
> > Dim x As Long
> > Dim J As String
> > strX = "Test"

> > hMem = GlobalAlloc(ghnd, Len(strX) + 1)

> > lmem = GlobalLock(hMem)
> > lmem = lstrcpy(lmem, strX)
> > dd = Me.hwnd
> > If GlobalUnlock(hMem) <> 0 Then '
> >     MsgBox "Memory Error"
> > End If

> > x = OpenClipboard(dd)
> > x = EmptyClipboard()

> > clip = SetClipboardData(CF_TEXT, hMem)

> > x = CloseClipboard
> > End Sub

> > Sent via Deja.com http://www.deja.com/
> > Before you buy.

Sent via Deja.com http://www.deja.com/
Before you buy.


Sun, 16 Jun 2002 03:00:00 GMT  
 Copying to Clipboard using API calls

Quote:

> Hi,
> I am trying to copy to the clipboard using API calls.
> The following code doesn't seem to work, can anybody please help
me!!!!
> Thanks
> GRaham

> Private Sub Command1_Click()

> Dim hMem As Long
> Dim lmem As Long
> Dim clip As Long
> Dim x As Long
> Dim J As String
> strX = "Test"

> hMem = GlobalAlloc(ghnd, Len(strX) + 1)

> lmem = GlobalLock(hMem)
> lmem = lstrcpy(lmem, strX)
> dd = Me.hwnd
> If GlobalUnlock(hMem) <> 0 Then '
>     MsgBox "Memory Error"
> End If

> x = OpenClipboard(dd)
> x = EmptyClipboard()

> clip = SetClipboardData(CF_TEXT, hMem)

> x = CloseClipboard
> End Sub

> Sent via Deja.com http://www.deja.com/
> Before you buy.

Ken Getz and Mike Gilbert explain this topic very well in their VBA
Developer's Handbook (pp. 300 - 306).  I would show you the code but I
think their might be a copyright issue.  Ken, if you see this, can you
confirm this?
--
-Jamie Weinstein, Senior Programmer Analyst
Morgan Stanley Dean Witter, Investment Banking Division
1585 Broadway, 34th Floor
New York, NY 10019

Sent via Deja.com http://www.deja.com/
Before you buy.



Sun, 16 Jun 2002 03:00:00 GMT  
 Copying to Clipboard using API calls

Quote:

> Hi,
> I am trying to copy to the clipboard using API calls.
> The following code doesn't seem to work, can anybody please help
me!!!!
> Thanks
> GRaham

> Private Sub Command1_Click()

> Dim hMem As Long
> Dim lmem As Long
> Dim clip As Long
> Dim x As Long
> Dim J As String
> strX = "Test"

> hMem = GlobalAlloc(ghnd, Len(strX) + 1)

> lmem = GlobalLock(hMem)
> lmem = lstrcpy(lmem, strX)
> dd = Me.hwnd
> If GlobalUnlock(hMem) <> 0 Then '
>     MsgBox "Memory Error"
> End If

> x = OpenClipboard(dd)
> x = EmptyClipboard()

> clip = SetClipboardData(CF_TEXT, hMem)

> x = CloseClipboard
> End Sub

> Sent via Deja.com http://www.deja.com/
> Before you buy.

I have a copy to clipboard function in my Graphics editing program,
Have you tried using some class modules and doing it through that?

Sent via Deja.com http://www.deja.com/
Before you buy.



Sun, 16 Jun 2002 03:00:00 GMT  
 Copying to Clipboard using API calls

Quote:

> Hi,
> I am trying to copy to the clipboard using API calls.
> The following code doesn't seem to work, can anybody please help
me!!!!
> Thanks
> GRaham

The following API simulates the keyboard action of <Alt> <Print Screen>
to move the active form or the screen to the clipboard.
This is something I found on Matt Hart's home page.

Hope this helps.

Levance

'====================================================================
Option Explicit
Private Declare Sub keybd_event Lib "user32" _
       (ByVal bVk As Byte, _
        ByVal bScan As Byte, _
        ByVal dwFlags As Long, _
        ByVal dwExtraInfo As Long)

Private Sub Command1_Click()

Const VK_SNAPSHOT As Byte = &H2C 'DEFINES  BEYBOARD KEYS <Alt-Print>
Const bScan As Byte = 0 '0 = MOVE FORM, 1 = MOVE SCREEN TO CLIPBOARD
Clipboard.Clear '           CLEAR CLIPBOARS IN CASE SOMETHING IS THERE

Call keybd_event(VK_SNAPSHOT, bScan, 0, 0) ' MOVE  TO CLIPBOARD
DoEvents ' THIS IS ABSOLUTELY NECESSARY. THIS WILL NOT WORK WITHOUT IT.

End Sub
'======================================================================

Sent via Deja.com http://www.deja.com/
Before you buy.



Sun, 16 Jun 2002 03:00:00 GMT  
 Copying to Clipboard using API calls

Quote:

> Hi,
> I am trying to copy to the clipboard using API calls.
> The following code doesn't seem to work, can anybody please help
me!!!!
> Thanks
> GRaham

====================================================================
Option Explicit
Private Declare Sub keybd_event Lib "user32" _
      (ByVal bVk As Byte, _
        ByVal bScan As Byte, _
        ByVal dwFlags As Long, _
        ByVal dwExtraInfo As Long)

Private Sub Command1_Click()

Const VK_SNAPSHOT As Byte = &H2C 'DEFINES  BEYBOARD KEYS <Alt-Print>
Const bScan As Byte = 0 '0 = MOVE FORM, 1 = MOVE SCREEN TO CLIPBOARD
Clipboard.Clear '          CLEAR CLIPBOARS IN CASE SOMETHING IS THERE

Call keybd_event(VK_SNAPSHOT, bScan, 0, 0) ' MOVE  TO CLIPBOARD
DoEvents ' THIS IS ABSOLUTELY NECESSARY. THIS WILL NOT WORK WITHOUT IT.

End Sub
'======================================================================

Sent via Deja.com http://www.deja.com/
Before you buy.



Sun, 16 Jun 2002 03:00:00 GMT  
 Copying to Clipboard using API calls
Yes, we prefer (strongly) that people not post copyrighted code here.
If you have the original author send me email, I'll see what I can do. -
- Ken


Quote:



> > Hi,
> > I am trying to copy to the clipboard using API calls.
> > The following code doesn't seem to work, can anybody please help
> me!!!!
> > Thanks
> > GRaham

> > Private Sub Command1_Click()

> > Dim hMem As Long
> > Dim lmem As Long
> > Dim clip As Long
> > Dim x As Long
> > Dim J As String
> > strX = "Test"

> > hMem = GlobalAlloc(ghnd, Len(strX) + 1)

> > lmem = GlobalLock(hMem)
> > lmem = lstrcpy(lmem, strX)
> > dd = Me.hwnd
> > If GlobalUnlock(hMem) <> 0 Then '
> >     MsgBox "Memory Error"
> > End If

> > x = OpenClipboard(dd)
> > x = EmptyClipboard()

> > clip = SetClipboardData(CF_TEXT, hMem)

> > x = CloseClipboard
> > End Sub

> > Sent via Deja.com http://www.deja.com/
> > Before you buy.

> Ken Getz and Mike Gilbert explain this topic very well in their VBA
> Developer's Handbook (pp. 300 - 306).  I would show you the code but I
> think their might be a copyright issue.  Ken, if you see this, can you
> confirm this?
> --
> -Jamie Weinstein, Senior Programmer Analyst
> Morgan Stanley Dean Witter, Investment Banking Division
> 1585 Broadway, 34th Floor
> New York, NY 10019

> Sent via Deja.com http://www.deja.com/
> Before you buy.

Sent via Deja.com http://www.deja.com/
Before you buy.


Mon, 17 Jun 2002 03:00:00 GMT  
 Copying to Clipboard using API calls
it doesnt support objects? then why are you using VB? what do you think
forms, command buttons, text boxes, labels, etc. are?

trippz


Quote:
> I need to be able to do it using API as I am writing it for a program
> called Saleslogix which does not support objects.

> Thanks
> Graham



> > why not just make a clipboard object?

> > trippz



> > > Hi,
> > > I am trying to copy to the clipboard using API calls.
> > > The following code doesn't seem to work, can anybody please help
> me!!!!
> > > Thanks
> > > GRaham

> > > Private Sub Command1_Click()

> > > Dim hMem As Long
> > > Dim lmem As Long
> > > Dim clip As Long
> > > Dim x As Long
> > > Dim J As String
> > > strX = "Test"

> > > hMem = GlobalAlloc(ghnd, Len(strX) + 1)

> > > lmem = GlobalLock(hMem)
> > > lmem = lstrcpy(lmem, strX)
> > > dd = Me.hwnd
> > > If GlobalUnlock(hMem) <> 0 Then '
> > >     MsgBox "Memory Error"
> > > End If

> > > x = OpenClipboard(dd)
> > > x = EmptyClipboard()

> > > clip = SetClipboardData(CF_TEXT, hMem)

> > > x = CloseClipboard
> > > End Sub

> > > Sent via Deja.com http://www.deja.com/
> > > Before you buy.

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Mon, 17 Jun 2002 03:00:00 GMT  
 Copying to Clipboard using API calls
The langauge is "Cypress Enable" which for your information is based on
VB. It does not support programmable objects, such as the Clipboard
object in VB. It does support API calls though!



Quote:
> it doesnt support objects? then why are you using VB? what do you
think
> forms, command buttons, text boxes, labels, etc. are?

> trippz



> > I need to be able to do it using API as I am writing it for a
program
> > called Saleslogix which does not support objects.

> > Thanks
> > Graham



> > > why not just make a clipboard object?

> > > trippz



> > > > Hi,
> > > > I am trying to copy to the clipboard using API calls.
> > > > The following code doesn't seem to work, can anybody please help
> > me!!!!
> > > > Thanks
> > > > GRaham

> > > > Private Sub Command1_Click()

> > > > Dim hMem As Long
> > > > Dim lmem As Long
> > > > Dim clip As Long
> > > > Dim x As Long
> > > > Dim J As String
> > > > strX = "Test"

> > > > hMem = GlobalAlloc(ghnd, Len(strX) + 1)

> > > > lmem = GlobalLock(hMem)
> > > > lmem = lstrcpy(lmem, strX)
> > > > dd = Me.hwnd
> > > > If GlobalUnlock(hMem) <> 0 Then '
> > > >     MsgBox "Memory Error"
> > > > End If

> > > > x = OpenClipboard(dd)
> > > > x = EmptyClipboard()

> > > > clip = SetClipboardData(CF_TEXT, hMem)

> > > > x = CloseClipboard
> > > > End Sub

> > > > Sent via Deja.com http://www.deja.com/
> > > > Before you buy.

> > Sent via Deja.com http://www.deja.com/
> > Before you buy.

Sent via Deja.com http://www.deja.com/
Before you buy.


Mon, 17 Jun 2002 03:00:00 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Copy to Clipboard using API Calls

2. Clipboard Manipulation using API Calls

3. Clipboard Manipulation using API Calls

4. Copying DBGrid contents to clipboard (Or copying a table from a Data component to clipboard)

5. Problem copying large files using SHFileOperation API call

6. Setting number of copies using Print Spooler API calls

7. Copy to Clipbard Using API Calls

8. Copy screen to clipboard via API

9. API: Copy to clipboard

10. Window's API Call: GetClipboardData to retrieve a Bitmap from Clipboard

11. using vba to copy to clipboard

12. Copy to clipboard using VBA

 

 
Powered by phpBB® Forum Software