Autor
|
Tema: [VB] Ayuda Manejo Portapapeles(ClipBoard) (Leído 3,112 veces)
|
|Azrack|
Desconectado
Mensajes: 102
Enjoy The Silence
|
Hola disculpen quisiera un poco de ayuda sobre el mnejo del portapapeles en visual basic 6 por ejemplo quisiera saber como puedo copiar un archivo al portapapeles.
|
|
|
En línea
|
|
|
|
|
Deeo Raiser
Desconectado
Mensajes: 22
Se todo Sobre Ti.
|
Hola Firewall como estas espero que bien, bueno respecto a tu pregunta aquí te dejo el código que se necesita para copiar en este caso un TextBox a el portapapeles.
Insertar Un Command1, Y Un Text1
*********************************************************
Private Sub Command1_Click() Clipboard.Clear Clipboard.SetText Text1.Text End Sub
Private Sub Form_Load() Text1.Text = "Esto es lo que se va a copiar" Command1.Caption = "Copiar" End Sub
*********************************************************
|
|
|
En línea
|
"Recuerda siempre que tu propia resolución de triunfar es mas importante que cualquier otra cosa." Abraham Lincoln
|
|
|
ranslsad
Desconectado
Mensajes: 492
Dim Ranslsad as String * :P - Que Vicio!
|
Si.. pero el quiere copiar archivos no texto.. eso es facil xD..
Salu2
Ranslsad
|
|
|
En línea
|
|
|
|
cobein
|
Hola, mira esto lo saque de un modulo que tengo que es para otra cosa, asi que saca las declaraciones que esten de mas. Private Const INPUT_KEYBOARD As Long = 1
Private Const KEYEVENTF_KEYDOWN As Long = 0 Private Const KEYEVENTF_KEYUP As Long = &H2
Private Const RSH_REGISTER_TASKMAN As Long = 3 Private Const HSHELL_WINDOWACTIVATED As Long = 4
Private Const GWL_WNDPROC As Long = -4 Private Const RSH_DEREGISTER As Long = 0
Private Const GHND As Long = &H42 Private Const CF_HDROP As Long = &HF
'--------------------------------------------------------------------------------------- ' Types '--------------------------------------------------------------------------------------- Private Type KEYBDINPUT wVk As Integer wScan As Integer dwFlags As Long time As Long dwExtraInfo As Long End Type
Private Type GENERALINPUT dwType As Long xi(0 To 23) As Byte End Type
Private Type POINTAPI x As Long y As Long End Type
Private Type DROPFILES pFiles As Long pt As POINTAPI fNC As Long fWide As Long End Type
'--------------------------------------------------------------------------------------- ' Apis '--------------------------------------------------------------------------------------- Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _ ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _ ByVal lpParameters As String, ByVal lpDirectory As String, _ ByVal nShowCmd As Long) As Long
Private Declare Function GetShortPathName Lib "kernel32" Alias _ "GetShortPathNameA" (ByVal lLongPath As String, ByVal lShortPath As String, _ ByVal lBuffer As Long) As Long Private Declare Function EmptyClipboard Lib "user32" () As Long Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function CloseClipboard Lib "user32" () As Long Private Declare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, _ ByVal hMem As Long) As Long
Private Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, _ ByVal dwBytes As Long) As Long Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long Private Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long Private Declare Function GlobalUnlock Lib "kernel32" ( _ ByVal hMem As Long) As Long Private Declare Sub CopyMem Lib "kernel32" Alias "RtlMoveMemory" ( _ Destination As Any, Source As Any, ByVal Length As Long)
Private Declare Function RegisterWindowMessage Lib "user32" Alias _ "RegisterWindowMessageA" (ByVal lpString As String) As Long Private Declare Function RegisterShellHook Lib "Shell32" Alias "#181" ( _ ByVal hwnd As Long, ByVal nAction As Long) As Long Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" ( _ ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" ( _ ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" ( _ ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, _ ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" ( _ ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function SendInput Lib "user32.dll" (ByVal nInputs As Long, _ pInputs As GENERALINPUT, ByVal cbSize As Long) As Long ' '--------------------------------------------------------------------------------------- ' Procedure : CopyClipboard ' Purpose : Copy a coma delimited file list to the clipboard '--------------------------------------------------------------------------------------- Private Function CopyClipboard(ByVal hwnd As Long, ByVal sData As String) As Boolean Dim hGlobal As Long Dim DF As DROPFILES Dim lpGlobal As Long Dim strFiles As String Dim svFiles() As String Dim i As Long Clipboard.Clear svFiles = Split(sData, ",") For i = 0 To UBound(svFiles) svFiles(i) = Trim$(svFiles(i)) If File_Exists(svFiles(i)) Then strFiles = strFiles & svFiles(i) & Chr(0) End If Next Call OpenClipboard(hwnd)
Call EmptyClipboard hGlobal = GlobalAlloc(GHND, Len(DF) + Len(strFiles)) If hGlobal Then 'if the globalalloc worked lpGlobal = GlobalLock(hGlobal) 'lock the hGlobal DF.pFiles = Len(DF) 'set the size of the files Call CopyMem(ByVal lpGlobal, DF, Len(DF)) 'copy df to the lpglobal Call CopyMem(ByVal (lpGlobal + Len(DF)), ByVal strFiles, Len(strFiles)) 'copy strfiles to lpglobal Call GlobalUnlock(hGlobal) 'unlock hglobal again SetClipboardData CF_HDROP, hGlobal 'put files to the clipboard GlobalFree hGlobal End If Call CloseClipboard
End Function
|
|
|
En línea
|
|
|
|
|
|