|
-
Aug 23rd, 2000, 04:29 PM
#1
Thread Starter
Lively Member
Hi fellers,
the following code:
Code:
Clipboard.SetText txtHex.Text
seems to save the data in txtHex to a temporary clipboard that applies only to the application in which it is used. Let me give you an example. In txtHex is "#0080FF" and when I try to put that data in the system clipboard using the above function, it doesn't go. The only way I can retrieve "#0080FF" is by putting Clipboard.GetText into the application. However, I want people to be able to copy "#0080FF" and use it in another application, for instance NotePad.
Looking in win32api.txt, it appears there is an API call SetClipboardData out there! I've looked, but I don't have the foggiest how to use it, and whether it'll work for my purposes.
Anybody?
Cheers in advance!
-
Aug 23rd, 2000, 04:58 PM
#2
The reason why it's not going into the clipboard is because nothing is highlighted to copy.
Try this:
Code:
txtHex.SelStart = 0
txtHex.SelLength = Len(txtHex.text)
Clipboard.SetText txtHex.SelText
-
Aug 23rd, 2000, 05:08 PM
#3
Thread Starter
Lively Member
Now I'm confused...
Now then, I tried that by putting in your code and hitting F5 to test the app. It didn't work, but I thought just to be sure I should try compiling it. On compiling the application I've just found, to my surprise that it does in fact work. Is this a bug in VB, or have I done something crazy?!?!?!
-
Aug 23rd, 2000, 05:37 PM
#4
Samdv: I tried Clipboard.SetText Text1.Text and it works perfectly. The only other problem I can think of is that some of your other code can be causing conflicts with it.
If you want to use an API method, try the following.
Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_COPY = &H301
Private Sub Command1_Click()
Text1.SelStart = 0
Text1.SelLength = Len(Text1)
SendMessage Text1.hwnd, WM_COPY, 0, 0
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|