如何不让其复制到Word上?
如何获取剪贴板信息?
10 个解决方案
#1
GetClipboardData ?
#2
估计因为它们一般会给剪贴板起个名字
假如
word_***
autocad_***
给你一段代码
UINT m_cfDraw=RegisterClipboardFormat("word_***");
COleDataObject dataObject;
//连接剪贴板
dataObject.AttachClipboard();
if (dataObject.IsDataAvailable(m_cfDraw)) //判断指定的格式是否存在
{}
假如
word_***
autocad_***
给你一段代码
UINT m_cfDraw=RegisterClipboardFormat("word_***");
COleDataObject dataObject;
//连接剪贴板
dataObject.AttachClipboard();
if (dataObject.IsDataAvailable(m_cfDraw)) //判断指定的格式是否存在
{}
#3
把文本放置到剪接板上:
CString source;
//put your text in source
if(OpenClipboard())
{
HGLOBAL clipbuffer;
char * buffer;
EmptyClipboard();
clipbuffer = GlobalAlloc(GMEM_DDESHARE, source.GetLength()+1);
buffer = (char*)GlobalLock(clipbuffer);
strcpy(buffer, LPCSTR(source));
GlobalUnlock(clipbuffer);
SetClipboardData(CF_TEXT,clipbuffer);
CloseClipboard();
}
从剪接板上获取文本:
char * buffer;
if(OpenClipboard())
{
buffer = (char*)GetClipboardData(CF_TEXT);
//do something with buffer here
//before it goes out of scope
}
CloseClipboard();
CString source;
//put your text in source
if(OpenClipboard())
{
HGLOBAL clipbuffer;
char * buffer;
EmptyClipboard();
clipbuffer = GlobalAlloc(GMEM_DDESHARE, source.GetLength()+1);
buffer = (char*)GlobalLock(clipbuffer);
strcpy(buffer, LPCSTR(source));
GlobalUnlock(clipbuffer);
SetClipboardData(CF_TEXT,clipbuffer);
CloseClipboard();
}
从剪接板上获取文本:
char * buffer;
if(OpenClipboard())
{
buffer = (char*)GetClipboardData(CF_TEXT);
//do something with buffer here
//before it goes out of scope
}
CloseClipboard();
#4
COleDataObject dataObject;
dataObject.AttachClipboard();
dataObject.AttachClipboard();
#5
HANDLE GetClipboardData(UINT Form)
Form为剪贴板数据格式
CF_TEXT为文本数据格式,也可以是图形数据格式或其它定义的数据格式,
返回值为剪的板数据的内存控制句柄,如果为NULL表示地址无效。
Form为剪贴板数据格式
CF_TEXT为文本数据格式,也可以是图形数据格式或其它定义的数据格式,
返回值为剪的板数据的内存控制句柄,如果为NULL表示地址无效。
#6
GetClipboardData
#7
char * buffer = NULL;
CString fromClipboard;
if ( OpenClipboard() ) //打开剪贴板
{
HANDLE hData = GetClipboardData(CF_TEXT);
char * buffer = (char*)GlobalLock(hData);
fromClipboard = buffer;
GlobalUnlock(hData);
CloseClipboard();
m_List.AddString(buffer);
}
CString fromClipboard;
if ( OpenClipboard() ) //打开剪贴板
{
HANDLE hData = GetClipboardData(CF_TEXT);
char * buffer = (char*)GlobalLock(hData);
fromClipboard = buffer;
GlobalUnlock(hData);
CloseClipboard();
m_List.AddString(buffer);
}
#8
那么如何把剪贴板中的内容保存下来,
准备以后进行恢复
准备以后进行恢复
#9
给你一个完整代码好了
CDC* pDC = GetDC();//获得DC
OnPrepareDC(pDC);//设置DC的滚动属性,与ScollView的滚动有关
UINT m_cfDraw=RegisterClipboardFormat("Draw_zgj");
CBase *m_usrCurrentObject;
CGraphDoc* pDoc = GetDocument();
COleDataObject dataObject;
//连接剪贴板
dataObject.AttachClipboard();
if (dataObject.IsDataAvailable(m_cfDraw)) //判断指定的格式是否存在
{
//得到内存文件指针
CFile* pFile = dataObject.GetFileData(m_cfDraw);
if (pFile != NULL)
{
//建立用于读取的文档对象
CArchive ar(pFile, CArchive::load);
TRY
{
//针对ar,调用对象的序列化函数。
pDoc->m_CopyaObjects.Serialize(ar);
}
CATCH_ALL(e)
{
ar.Close();
delete pFile;
THROW_LAST();
}
END_CATCH_ALL
ar.Close();
delete pFile;//关键是这里,利用内存文件
}
}
int xoffset=0,yoffset=0;
int i;
m_usrCurrentObject = pDoc->m_CopyaObjects[0];
xoffset=PastePoint.x-m_usrCurrentObject->m_x1;
yoffset=PastePoint.y-m_usrCurrentObject->m_y1;
for(i = pDoc->m_CopyaObjects.GetSize()-1; i >= 0; i--)
{
m_usrCurrentObject = pDoc->m_CopyaObjects[i];
m_usrCurrentObject->m_x1+=xoffset;
m_usrCurrentObject->m_x2+=xoffset;
m_usrCurrentObject->m_y1+=yoffset;
m_usrCurrentObject->m_y2+=yoffset;
}
if(pDoc->m_CopyaObjects.GetSize()>300&&pDoc->m_aObjects.GetSize()>300){AfxMessageBox("粘贴大量元件会造成程序长时间无响应");return;}
CopyToArray(&pDoc->m_CopyaObjects,&pDoc->m_aObjects,0);
CopyToArray(&pDoc->m_CopyaObjects,&pDoc->m_TemplateObjects,1);
//MoveSelGraph(&pDoc->m_CopyaObjects,point1.x,point1.y,5);
Invalidate();
CDC* pDC = GetDC();//获得DC
OnPrepareDC(pDC);//设置DC的滚动属性,与ScollView的滚动有关
UINT m_cfDraw=RegisterClipboardFormat("Draw_zgj");
CBase *m_usrCurrentObject;
CGraphDoc* pDoc = GetDocument();
COleDataObject dataObject;
//连接剪贴板
dataObject.AttachClipboard();
if (dataObject.IsDataAvailable(m_cfDraw)) //判断指定的格式是否存在
{
//得到内存文件指针
CFile* pFile = dataObject.GetFileData(m_cfDraw);
if (pFile != NULL)
{
//建立用于读取的文档对象
CArchive ar(pFile, CArchive::load);
TRY
{
//针对ar,调用对象的序列化函数。
pDoc->m_CopyaObjects.Serialize(ar);
}
CATCH_ALL(e)
{
ar.Close();
delete pFile;
THROW_LAST();
}
END_CATCH_ALL
ar.Close();
delete pFile;//关键是这里,利用内存文件
}
}
int xoffset=0,yoffset=0;
int i;
m_usrCurrentObject = pDoc->m_CopyaObjects[0];
xoffset=PastePoint.x-m_usrCurrentObject->m_x1;
yoffset=PastePoint.y-m_usrCurrentObject->m_y1;
for(i = pDoc->m_CopyaObjects.GetSize()-1; i >= 0; i--)
{
m_usrCurrentObject = pDoc->m_CopyaObjects[i];
m_usrCurrentObject->m_x1+=xoffset;
m_usrCurrentObject->m_x2+=xoffset;
m_usrCurrentObject->m_y1+=yoffset;
m_usrCurrentObject->m_y2+=yoffset;
}
if(pDoc->m_CopyaObjects.GetSize()>300&&pDoc->m_aObjects.GetSize()>300){AfxMessageBox("粘贴大量元件会造成程序长时间无响应");return;}
CopyToArray(&pDoc->m_CopyaObjects,&pDoc->m_aObjects,0);
CopyToArray(&pDoc->m_CopyaObjects,&pDoc->m_TemplateObjects,1);
//MoveSelGraph(&pDoc->m_CopyaObjects,point1.x,point1.y,5);
Invalidate();
#10
上面许多是与我程序相关的,你不必考虑那些
doc中
CTypedPtrArray<CObArray, CBase*> m_aObjects;//需在stafx.h中加入#include <afxtempl.h>
CTypedPtrArray<CObArray, CBase*> m_CopyaObjects;
CTypedPtrArray<CObArray, CBase*> m_TemplateObjects;
doc中
CTypedPtrArray<CObArray, CBase*> m_aObjects;//需在stafx.h中加入#include <afxtempl.h>
CTypedPtrArray<CObArray, CBase*> m_CopyaObjects;
CTypedPtrArray<CObArray, CBase*> m_TemplateObjects;
#1
GetClipboardData ?
#2
估计因为它们一般会给剪贴板起个名字
假如
word_***
autocad_***
给你一段代码
UINT m_cfDraw=RegisterClipboardFormat("word_***");
COleDataObject dataObject;
//连接剪贴板
dataObject.AttachClipboard();
if (dataObject.IsDataAvailable(m_cfDraw)) //判断指定的格式是否存在
{}
假如
word_***
autocad_***
给你一段代码
UINT m_cfDraw=RegisterClipboardFormat("word_***");
COleDataObject dataObject;
//连接剪贴板
dataObject.AttachClipboard();
if (dataObject.IsDataAvailable(m_cfDraw)) //判断指定的格式是否存在
{}
#3
把文本放置到剪接板上:
CString source;
//put your text in source
if(OpenClipboard())
{
HGLOBAL clipbuffer;
char * buffer;
EmptyClipboard();
clipbuffer = GlobalAlloc(GMEM_DDESHARE, source.GetLength()+1);
buffer = (char*)GlobalLock(clipbuffer);
strcpy(buffer, LPCSTR(source));
GlobalUnlock(clipbuffer);
SetClipboardData(CF_TEXT,clipbuffer);
CloseClipboard();
}
从剪接板上获取文本:
char * buffer;
if(OpenClipboard())
{
buffer = (char*)GetClipboardData(CF_TEXT);
//do something with buffer here
//before it goes out of scope
}
CloseClipboard();
CString source;
//put your text in source
if(OpenClipboard())
{
HGLOBAL clipbuffer;
char * buffer;
EmptyClipboard();
clipbuffer = GlobalAlloc(GMEM_DDESHARE, source.GetLength()+1);
buffer = (char*)GlobalLock(clipbuffer);
strcpy(buffer, LPCSTR(source));
GlobalUnlock(clipbuffer);
SetClipboardData(CF_TEXT,clipbuffer);
CloseClipboard();
}
从剪接板上获取文本:
char * buffer;
if(OpenClipboard())
{
buffer = (char*)GetClipboardData(CF_TEXT);
//do something with buffer here
//before it goes out of scope
}
CloseClipboard();
#4
COleDataObject dataObject;
dataObject.AttachClipboard();
dataObject.AttachClipboard();
#5
HANDLE GetClipboardData(UINT Form)
Form为剪贴板数据格式
CF_TEXT为文本数据格式,也可以是图形数据格式或其它定义的数据格式,
返回值为剪的板数据的内存控制句柄,如果为NULL表示地址无效。
Form为剪贴板数据格式
CF_TEXT为文本数据格式,也可以是图形数据格式或其它定义的数据格式,
返回值为剪的板数据的内存控制句柄,如果为NULL表示地址无效。
#6
GetClipboardData
#7
char * buffer = NULL;
CString fromClipboard;
if ( OpenClipboard() ) //打开剪贴板
{
HANDLE hData = GetClipboardData(CF_TEXT);
char * buffer = (char*)GlobalLock(hData);
fromClipboard = buffer;
GlobalUnlock(hData);
CloseClipboard();
m_List.AddString(buffer);
}
CString fromClipboard;
if ( OpenClipboard() ) //打开剪贴板
{
HANDLE hData = GetClipboardData(CF_TEXT);
char * buffer = (char*)GlobalLock(hData);
fromClipboard = buffer;
GlobalUnlock(hData);
CloseClipboard();
m_List.AddString(buffer);
}
#8
那么如何把剪贴板中的内容保存下来,
准备以后进行恢复
准备以后进行恢复
#9
给你一个完整代码好了
CDC* pDC = GetDC();//获得DC
OnPrepareDC(pDC);//设置DC的滚动属性,与ScollView的滚动有关
UINT m_cfDraw=RegisterClipboardFormat("Draw_zgj");
CBase *m_usrCurrentObject;
CGraphDoc* pDoc = GetDocument();
COleDataObject dataObject;
//连接剪贴板
dataObject.AttachClipboard();
if (dataObject.IsDataAvailable(m_cfDraw)) //判断指定的格式是否存在
{
//得到内存文件指针
CFile* pFile = dataObject.GetFileData(m_cfDraw);
if (pFile != NULL)
{
//建立用于读取的文档对象
CArchive ar(pFile, CArchive::load);
TRY
{
//针对ar,调用对象的序列化函数。
pDoc->m_CopyaObjects.Serialize(ar);
}
CATCH_ALL(e)
{
ar.Close();
delete pFile;
THROW_LAST();
}
END_CATCH_ALL
ar.Close();
delete pFile;//关键是这里,利用内存文件
}
}
int xoffset=0,yoffset=0;
int i;
m_usrCurrentObject = pDoc->m_CopyaObjects[0];
xoffset=PastePoint.x-m_usrCurrentObject->m_x1;
yoffset=PastePoint.y-m_usrCurrentObject->m_y1;
for(i = pDoc->m_CopyaObjects.GetSize()-1; i >= 0; i--)
{
m_usrCurrentObject = pDoc->m_CopyaObjects[i];
m_usrCurrentObject->m_x1+=xoffset;
m_usrCurrentObject->m_x2+=xoffset;
m_usrCurrentObject->m_y1+=yoffset;
m_usrCurrentObject->m_y2+=yoffset;
}
if(pDoc->m_CopyaObjects.GetSize()>300&&pDoc->m_aObjects.GetSize()>300){AfxMessageBox("粘贴大量元件会造成程序长时间无响应");return;}
CopyToArray(&pDoc->m_CopyaObjects,&pDoc->m_aObjects,0);
CopyToArray(&pDoc->m_CopyaObjects,&pDoc->m_TemplateObjects,1);
//MoveSelGraph(&pDoc->m_CopyaObjects,point1.x,point1.y,5);
Invalidate();
CDC* pDC = GetDC();//获得DC
OnPrepareDC(pDC);//设置DC的滚动属性,与ScollView的滚动有关
UINT m_cfDraw=RegisterClipboardFormat("Draw_zgj");
CBase *m_usrCurrentObject;
CGraphDoc* pDoc = GetDocument();
COleDataObject dataObject;
//连接剪贴板
dataObject.AttachClipboard();
if (dataObject.IsDataAvailable(m_cfDraw)) //判断指定的格式是否存在
{
//得到内存文件指针
CFile* pFile = dataObject.GetFileData(m_cfDraw);
if (pFile != NULL)
{
//建立用于读取的文档对象
CArchive ar(pFile, CArchive::load);
TRY
{
//针对ar,调用对象的序列化函数。
pDoc->m_CopyaObjects.Serialize(ar);
}
CATCH_ALL(e)
{
ar.Close();
delete pFile;
THROW_LAST();
}
END_CATCH_ALL
ar.Close();
delete pFile;//关键是这里,利用内存文件
}
}
int xoffset=0,yoffset=0;
int i;
m_usrCurrentObject = pDoc->m_CopyaObjects[0];
xoffset=PastePoint.x-m_usrCurrentObject->m_x1;
yoffset=PastePoint.y-m_usrCurrentObject->m_y1;
for(i = pDoc->m_CopyaObjects.GetSize()-1; i >= 0; i--)
{
m_usrCurrentObject = pDoc->m_CopyaObjects[i];
m_usrCurrentObject->m_x1+=xoffset;
m_usrCurrentObject->m_x2+=xoffset;
m_usrCurrentObject->m_y1+=yoffset;
m_usrCurrentObject->m_y2+=yoffset;
}
if(pDoc->m_CopyaObjects.GetSize()>300&&pDoc->m_aObjects.GetSize()>300){AfxMessageBox("粘贴大量元件会造成程序长时间无响应");return;}
CopyToArray(&pDoc->m_CopyaObjects,&pDoc->m_aObjects,0);
CopyToArray(&pDoc->m_CopyaObjects,&pDoc->m_TemplateObjects,1);
//MoveSelGraph(&pDoc->m_CopyaObjects,point1.x,point1.y,5);
Invalidate();
#10
上面许多是与我程序相关的,你不必考虑那些
doc中
CTypedPtrArray<CObArray, CBase*> m_aObjects;//需在stafx.h中加入#include <afxtempl.h>
CTypedPtrArray<CObArray, CBase*> m_CopyaObjects;
CTypedPtrArray<CObArray, CBase*> m_TemplateObjects;
doc中
CTypedPtrArray<CObArray, CBase*> m_aObjects;//需在stafx.h中加入#include <afxtempl.h>
CTypedPtrArray<CObArray, CBase*> m_CopyaObjects;
CTypedPtrArray<CObArray, CBase*> m_TemplateObjects;