- 注册时间
- 2008-9-13
- 最后登录
- 1970-1-1
- 在线时间
- 0 小时
- 阅读权限
- 200
- 积分
- 0
- 帖子
- 24482
- 精华
- 4
- UID
- 9
|
word自选图形复制后,我想通过读取剪贴板在自己的程序中显示出来!
问题点数:100、回复次数:39Top
[url=]1 楼[/url]cbc(逍遥子)回复于 2004-09-15 20:57:13 得分 0 upTop
[url=]2 楼[/url]cbc(逍遥子)回复于 2004-09-16 16:22:04 得分 0 up
高手快来帮帮我啊
Top
[url=]3 楼[/url]cbc(逍遥子)回复于 2004-09-16 18:04:06 得分 0 help,怎么没人回复啊?Top
[url=]4 楼[/url]yuzhu2003(yuzhu)回复于 2004-09-17 09:37:35 得分 0 试试这样:
HBITMAP hBitmap = (HBITMAP) GetCLipBoardData(CF_BITMAP);
然后利用hBitmap在程序中显示试试Top
[url=]5 楼[/url]cbc(逍遥子)回复于 2004-09-17 12:45:05 得分 0 用IsClipboardFormatAvailable(CF_BITMAP)检测不是CF_BITMAP这种类型
也不是CF_DIB类型Top
[url=]6 楼[/url]cbc(逍遥子)回复于 2004-09-17 16:30:42 得分 0 upTop
[url=]7 楼[/url]cbc(逍遥子)回复于 2004-09-20 10:27:26 得分 0 再问Top
[url=]8 楼[/url]cbc(逍遥子)回复于 2004-09-20 16:02:34 得分 0 try,upTop
[url=]9 楼[/url]liuxianzhi(碧渊)回复于 2004-09-20 16:11:11 得分 0 gzTop
[url=]10 楼[/url]cbc(逍遥子)回复于 2004-09-21 13:34:09 得分 0 呵呵,没办法啊,再顶Top
[url=]11 楼[/url]cbc(逍遥子)回复于 2004-09-27 14:25:05 得分 0 等待高手......Top
[url=]12 楼[/url]crystal521(【云淡风轻】)回复于 2004-09-27 14:59:38 得分 30如何在剪贴板上放置图元文件(用OLE)
(1)如果你的项目中不支持OLE,请加上下列代码:
#include < afxole.h >
并在初始化时加入:
OleInitialize(NULL);
(2)下面是具体实现的代码:
void CMyView::OnEditCopyWmf()
{
tagSTGMEDIUM * data;
CClientDC dcRef( this );
data = new tagSTGMEDIUM;
CMetaFileDC * dcMeta;
dcMeta = new CMetaFileDC();
COleDataSource* pData = new COleDataSource;
CRect lmbr;
GetClientRect(lmbr);
//replace "ImageName" with a description of this image
dcMeta->CreateEnhanced(&dcRef, NULL, NULL,"ImageName\0Copy\0\0" );
dcMeta->SetMapMode(MM_TEXT);
//actually draw to the device context
OnDraw(dcMeta);
//done drawing
data->tymed = TYMED_ENHMF;
data->hEnhMetaFile = dcMeta->CloseEnhanced();
pData->CacheData( CF_ENHMETAFILE, data );
pData->SetClipboard();
delete dcMeta;
delete data;
}Top
[url=]13 楼[/url]crystal521(【云淡风轻】)回复于 2004-09-27 15:00:33 得分 0 用GetClipboardData 从系统剪贴板中读取数据Top
[url=]14 楼[/url]cbc(逍遥子)回复于 2004-09-29 08:34:12 得分 0 好,谢谢,我回去试一下
Top
[url=]15 楼[/url]cbc(逍遥子)回复于 2004-10-05 03:18:08 得分 0 能不能作为位图处理Top
[url=]16 楼[/url]techgopher(米粒之珠也放光华)回复于 2004-10-05 07:26:28 得分 0 关于格式: 旧版的Word是Windows Meta File (WMF)格式,新的(XP以上?) 是Enhanced Meta File(EMF).Top
[url=]17 楼[/url]nwpulipeng(☆→【★海阔天空★】)回复于 2004-10-05 11:00:29 得分 0 帮顶混分Top
[url=]18 楼[/url]fbmsf(FBM)回复于 2004-10-05 11:20:42 得分 0 研究了一下:
结果如下:
invoke OpenClipboard,0
invoke EnumClipboardFormats,0
pp:
cmp eax,0
je @F
push eax
invoke GetClipboardFormatName,eax,addr buf,1024
invoke MessageBox,0,addr buf,0,0
pop eax
invoke EnumClipboardFormats,eax
jmp pp
运行结果:(copy word 的自定义图形后)
的几种类型GetClipboardFormatName得到)
DataObject
Office Drawing Shape Format
Office Drawing Shape Format
Office Drawing Shape Format
PNG+Office Art
JFIF+Office Art
GIF+Office Art
PNG
JFIF
GIF
Ole Private Data
看样子应该是Office Drawing Shape Format
Top
[url=]19 楼[/url]cbc(逍遥子)回复于 2004-10-07 00:03:46 得分 0 楼上的怎么研究的啊?Top
[url=]20 楼[/url]fcf128(Hacker)回复于 2004-10-07 04:14:42 得分 0 同楼上,
我也很想知道Top
[url=]21 楼[/url]fbmsf(FBM)回复于 2004-10-07 08:50:47 得分 50
word 中选图按Ctrl+V 的后那么可以让Clipboard中的CF_ENHMETAFILE可以用
IsClipboardFormatAvailable(CF_ENHMETAFILE) == nonzero
现在问题是我通过GetClipboardData的到一个hemf.
HENHMETAFILE hemf, // handle to an enhanced metafile
但是就是显示不出来.
我是想通过metafile来显示的应该可以实现。
cbc(逍遥子) 你也看看这方法行的通不.Top
[url=]22 楼[/url]laker_tmj(laker)回复于 2004-10-07 08:52:44 得分 0 up learnTop
[url=]23 楼[/url]fbmsf(FBM)回复于 2004-10-07 14:26:19 得分 0 啊。ok 了
方法如下:
invoke OpenClipboard,0
invoke IsClipboardFormatAvailable,CF_ENHMETAFILE
.if eax!=0
invoke GetClipboardData,CF_ENHMETAFILE
mov hemf,eax
invoke GetClientRect,hwnd,addr rc
invoke PlayEnhMetaFile,hdc,hemf,addr rc
.endif
invoke CloseClipboard
就这个几个api 函数,
代码加在 WM_PAINT 下面或是按下Ctrl+V的时候。
我用win32asm 语法 invoke 表示调用,eax 是返回直
要个hdc 你自己用GetDC得到吧。
Top
[url=]24 楼[/url]dawning371(风刃)回复于 2004-10-07 17:03:41 得分 0 dingTop
[url=]25 楼[/url]dawning371(风刃)回复于 2004-10-07 17:20:57 得分 0 to fbmsf(FBM):
用win32asm 语法?你的语句能直接嵌在C++中执行吗?菜鸟问,谢谢Top
[url=]26 楼[/url]fbmsf(FBM)回复于 2004-10-08 08:22:54 得分 20这样吧,改了个VC的, 先新键一个hello word(win32 app)
然后在WM_PAINT下面加代码:
case WM_PAINT:
HANDLE hemf ;
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
RECT rt;
GetClientRect(hWnd, &rt);
OpenClipboard(0);
if (IsClipboardFormatAvailable(CF_ENHMETAFILE)!=0)
{
hemf=GetClipboardData(CF_ENHMETAFILE);
PlayEnhMetaFile(hdc,HENHMETAFILE(hemf),&rt);
}
CloseClipboard();
EndPaint(hWnd, &ps);
break;
运行以前,记得开word, Copy一次自选图形,不然没有反应。
Top
[url=]27 楼[/url]liuxianzhi(碧渊)回复于 2004-10-08 08:48:54 得分 0 gz!Top
[url=]28 楼[/url]nineclock(闭关中。。。)回复于 2004-10-08 09:11:00 得分 0 强,牛人
佩服的要死~~Top
[url=]29 楼[/url]cbc(逍遥子)回复于 2004-10-08 15:31:04 得分 0 谢谢,我试试
Top
[url=]30 楼[/url]cbc(逍遥子)回复于 2004-10-08 15:56:33 得分 0 好的,可以显示出来
另外我还想问一下,能否把它们保存起来啊!Top
[url=]31 楼[/url]fbmsf(FBM)回复于 2004-10-09 07:54:42 得分 0 可以msdn 里面有现成的代码。
我现在没有msdn,你查查msdn。Top
[url=]32 楼[/url]dawning371(风刃)回复于 2004-10-09 09:59:22 得分 0 强,但是结果好象是图象的方式显示出来的,而且是拉伸的,能不能以原大小显示啊?--估计不行?Top
[url=]33 楼[/url]cbc(逍遥子)回复于 2004-10-09 15:46:47 得分 0 对,是以位图的方式显示出来的,我现在也不知道如何以原始大小显示啊Top
[url=]34 楼[/url]fbmsf(FBM)回复于 2004-10-11 09:10:34 得分 0 Displaying a Picture and Storing It in an Enhanced Metafile
This section contains an example demonstrating the creation of a picture and the process of storing the corresponding records in a metafile. The example draws a picture to the display or stores it in a metafile. If a display device context handle is given, it draws a picture to the screen using various GDI functions. If an enhanced metafile device context is given, it stores the same picture in the enhanced metafile.
void DrawOrStore(HWND hwnd, HDC hdcMeta, HDC hdcDisplay)
{
RECT rect;
HDC hDC;
int fnMapModeOld;
HBRUSH hbrOld;
// Draw it to the display DC or store it in the metafile device context.
if (hdcMeta)
hDC = hdcMeta;
else
hDC = hdcDisplay;
// Set the mapping mode in the device context.
fnMapModeOld = SetMapMode(hDC, MM_LOENGLISH);
// Find the midpoint of the client area.
GetClientRect(hwnd, (LPRECT)&rect);
DPtoLP(hDC, (LPPOINT)&rect, 2);
// Select a gray brush.
hbrOld = SelectObject(hDC, GetStockObject(GRAY_BRUSH));
// Draw a circle with a one inch radius.
Ellipse(hDC, (rect.right/2 - 100), (rect.bottom/2 + 100),
(rect.right/2 + 100), (rect.bottom/2 - 100));
// Perform additional drawing here.
// Set the device context back to its original state.
SetMapMode(hDC, fnMapModeOld);
SelectObject(hDC, hbrOld);
}
Top
[url=]35 楼[/url]fbmsf(FBM)回复于 2004-10-11 09:11:42 得分 0 Creating an Enhanced Metafile
This section contains an example that demonstrates the creation of an enhanced metafile that is stored on a disk, using a file name specified by the user.
The example uses a device context for the application window as the reference device context. (The system stores the resolution data for this device in the enhanced-metafile's header.) The application retrieves a handle identifying this device context by calling the GetDC function.
The example uses the dimensions of the application's client area to define the dimensions of the picture frame. Using the rectangle dimensions returned by the GetClientRect function, the application converts the device units to .01-millimeter units and passes the converted values to the CreateEnhMetaFile function.
The example displays a Save As common dialog box that enables the user to specify the file name of the new enhanced metafile. The system appends the three-character .emf extension to this file name and passes the name to the CreateEnhMetaFile function.
The example also embeds a text description of the picture in the enhanced-metafile header. This description is specified as a resource in the string table of the application's resource file. However, in a working application, this string would be retrieved from a custom control in a common dialog box or from a separate dialog box displayed solely for this purpose.
// Obtain a handle to a reference device context.
hdcRef = GetDC(hWnd);
// Determine the picture frame dimensions.
// iWidthMM is the display width in millimeters.
// iHeightMM is the display height in millimeters.
// iWidthPels is the display width in pixels.
// iHeightPels is the display height in pixels
iWidthMM = GetDeviceCaps(hdcRef, HORZSIZE);
iHeightMM = GetDeviceCaps(hdcRef, VERTSIZE);
iWidthPels = GetDeviceCaps(hdcRef, HORZRES);
iHeightPels = GetDeviceCaps(hdcRef, VERTRES);
// Retrieve the coordinates of the client
// rectangle, in pixels.
GetClientRect(hWnd, &rect);
// Convert client coordinates to .01-mm units.
// Use iWidthMM, iWidthPels, iHeightMM, and
// iHeightPels to determine the number of
// .01-millimeter units per pixel in the x-
// and y-directions.
rect.left = (rect.left * iWidthMM * 100)/iWidthPels;
rect.top = (rect.top * iHeightMM * 100)/iHeightPels;
rect.right = (rect.right * iiWidthMM * 100)/iWidthPels;
rect.bottom = (rect.bottom * iHeightMM * 100)/iHeightPels;
// Load the filename filter from the string table.
LoadString(hInst, IDS_FILTERSTRING,
(LPSTR)szFilter, sizeof(szFilter));
// Replace the '%' separators that are embedded
// between the strings in the string-table entry
// with '\0'.
for (i=0; szFilter!='\0'; i++)
if (szFilter == '%')
szFilter = '\0';
// Load the dialog title string from the table.
LoadString(hInst, IDS_TITLESTRING,
(LPSTR)szTitle, sizeof(szTitle));
// Initialize the OPENFILENAME members.
szFile[0] = '\0';
Ofn.lStructSize = sizeof(OPENFILENAME);
Ofn.hwndOwner = hWnd;
Ofn.lpstrFilter = szFilter;
Ofn.lpstrFile= szFile;
Ofn.nMaxFile = sizeof(szFile);
Ofn.lpstrFileTitle = szFileTitle;
Ofn.nMaxFileTitle = sizeof(szFileTitle);
Ofn.lpstrInitialDir = (LPSTR)NULL;
Ofn.Flags = OFN_SHOWHELP | OFN_OVERWRITEPROMPT;
Ofn.lpstrTitle = szTitle;
// Display the Filename common dialog box. The
// filename specified by the user is passed
// to the CreateEnhMetaFile function and used to
// store the metafile on disk.
GetSaveFileName(&Ofn);
// Load the description from the string table.
LoadString(hInst, IDS_DESCRIPTIONSTRING,
(LPSTR)szDescription, sizeof(szDescription));
// Replace the '%' string separators that are
// embedded between strings in the string-table
// entry with '\0'.
for (i=0; szDescription!='\0'; i++)
{
if (szDescription == '%')
szDescription = '\0';
}
// Create the metafile device context.
hdcMeta = CreateEnhMetaFile(hdcRef,
(LPTSTR) Ofn.lpstrFile,
&rect, (LPSTR)szDescription);
if (!hdcMeta)
errhandler("CreateEnhMetaFile", hWnd);
// Release the reference device context.
ReleaseDC(hWnd, hdcRef);
Top
[url=]36 楼[/url]fbmsf(FBM)回复于 2004-10-11 09:12:41 得分 0
这段代码可能就是(我没有试)
// Determine the picture frame dimensions.
// iWidthMM is the display width in millimeters.
// iHeightMM is the display height in millimeters.
// iWidthPels is the display width in pixels.
// iHeightPels is the display height in pixels
iWidthMM = GetDeviceCaps(hdcRef, HORZSIZE);
iHeightMM = GetDeviceCaps(hdcRef, VERTSIZE);
iWidthPels = GetDeviceCaps(hdcRef, HORZRES);
iHeightPels = GetDeviceCaps(hdcRef, VERTRES);
// Retrieve the coordinates of the client
// rectangle, in pixels.
GetClientRect(hWnd, &rect);
// Convert client coordinates to .01-mm units.
// Use iWidthMM, iWidthPels, iHeightMM, and
// iHeightPels to determine the number of
// .01-millimeter units per pixel in the x-
// and y-directions.
rect.left = (rect.left * iWidthMM * 100)/iWidthPels;
rect.top = (rect.top * iHeightMM * 100)/iHeightPels;
rect.right = (rect.right * iiWidthMM * 100)/iWidthPels;
rect.bottom = (rect.bottom * iHeightMM * 100)/iHeightPels; |
|