GSerg писал(а):Если ты делаешь "типа свой формат", то тебе сойдёт обычный string, содержащий такую-то фигню.
Если ты делаешь реально свой формат, то обрати стопы сначала к функции registerclipboardformat.
GSerg писал(а):varptr - это не указатель на строку, указатель на строку strptr.
VB писал(а):Can't find entry point
GSerg писал(а)::shock:![]()
Ты чё там делаешь?
GSerg писал(а):Кто-то из нах двоих извращенец
Я не исключаю, что это я, но код позырить бы, а?
Public Function PutInClipboard(FORMAT_ID As Variant, StrData As String) As Integer
Dim CF_FORMAT As Long
Select Case TypeName(FORMAT_ID)
Case "Long"
CF_FORMAT = FORMAT_ID
Case "String"
CF_FORMAT = RegisterClipboardFormat(FORMAT_ID)
Case Else
Exit Function
End Select
'open the clipboard
OpenClipboard MainWindow.hwnd
'Clear the clipboard
EmptyClipboard
SetClipboardData CF_FORMAT, StrPtr(StrData)
CloseClipboard
PutInClipboard = 1
End Function
Public Declare Function SetClipboardData Lib "user32" _
(ByVal wFormat As Long, ByVal hMem As Long) As Long
'sRTF represents the rich text formatted string to paste into Word
Dim sRTF As String
sRTF = "{\rtf1\ansi\ansicpg1252\deff0\deftab720{\fonttbl" & _
"{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}" & _
"{\f2\froman\fprq2 Times New Roman;}}" & _
"{\colortbl\red0\green0\blue0;\red255\green0\blue0;}" & _
"\deflang1033\horzdoc{\*\fchars }{\*\lchars }" & _
"\pard\plain\f2\fs24 Line 1 of \plain\f2\fs24\cf1" & _
"inserted\plain\f2\fs24 file.\par }"
'Copy the contents of the Rich Text to the clipboard
Dim lSuccess As Long
Dim lRTF As Long
Dim hGlobal As Long
Dim lpString As Long
lSuccess = OpenClipboard(Me.hwnd)
lRTF = RegisterClipboardFormat("Rich Text Format")
lSuccess = EmptyClipboard
hGlobal = GlobalAlloc(GMEM_MOVEABLE Or GMEM_DDESHARE, Len(sRTF))
lpString = GlobalLock(hGlobal)
CopyMemory lpString, ByVal sRTF, Len(sRTF)
GlobalUnlock hGlobal
SetClipboardData lRTF, hGlobal
CloseClipboard
GlobalFree hGlobal
'Paste into a new Word document
Dim oWord As Object
Dim oDoc As Object
Set oWord = CreateObject("word.application")
Set oDoc = oWord.Documents.Add
oWord.Selection.Paste
oWord.Visible = True
Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function RegisterClipboardFormat Lib "user32" Alias _
"RegisterClipboardFormatA" (ByVal lpString As String) As Long
Private Declare Function EmptyClipboard Lib "user32" () 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 Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
ByVal Destination As Long, Source As Any, ByVal Length As Long)
Private Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Function GlobalFree Lib "kernel32" Alias "GlobalFree" ( _
ByVal hMem As Long) As Long
Private Const GMEM_DDESHARE = &H2000
Private Const GMEM_MOVEABLE = &H2
Eugenio писал(а):Я, просто, видел пример, где в качестве handl'а передавлась переменная, куда записали результат LoadPicture
OpenClipboard MainWindow.hwnd
hStrPtr = GetClipboardData(CF_FORMAT)
lpString = GlobalLock(hStrPtr)
If lpString <> 0 Then
lLength = lstrlen(lpString)
If lLength > 0 Then
sBuffer = Space$(lLength)
CopyMemory sBuffer, hStrPtr, lLength
End If
End If
GlobalUnlock lpString
CloseClipboard
CopyMemory StrPtr(sBuffer), hStrPtr, lLength
CopyMemory ByVal sBuffer, hStrPtr, lLength
Konst_One писал(а):ну так преобразуй строку в ANSI
lstrlen
The lstrlen function returns the length in bytes (ANSI version) or WCHARs (Unicode version) of the specified string (not including the terminating null character).
int lstrlen(
LPCTSTR lpString // string to count
);
Parameters
lpString
[in] Pointer to a null-terminated string.
Return Values
The return value specifies the length of the string, in TCHARs. This refers to bytes for ANSI versions of the function or WCHARs for Unicode versions.
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 2