jiangsheng,帮帮忙

boybaby 2002-03-30 03:42:43
关于我的VC不支持IHTMLElement2接口,但系统肯定是支持的,我应该怎么调用这个接口。我不太懂COM,最好能给一些源码。谢谢
...全文
42 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
boybaby 2002-03-30
  • 打赏
  • 举报
回复
问题是很多网页不会一页显示完的,要用滚动栏才能看到全部,抓屏可能只能抓当前显示的页面。
蒋晟 2002-03-30
  • 打赏
  • 举报
回复
只能显示出来之后抓屏了
boybaby 2002-03-30
  • 打赏
  • 举报
回复
我不是要拷一个网页上的图像,而是要把整个网页页面所有的内容存为一个图像。包括图片和文字做为一个整体,然后存起来,是这样。
boybaby 2002-03-30
  • 打赏
  • 举报
回复
新的补丁太大了,在网上下载敢想像。
蒋晟 2002-03-30
  • 打赏
  • 举报
回复
1 升级你的SDK

http://www.microsoft.com/msdownload/platformsdk/sdkupdate/
2 示例

HOWTO: Programmatically Copy an IMG Element to the Clipboard

Q293125


--------------------------------------------------------------------------------
The information in this article applies to:

Microsoft Internet Explorer (Programming) versions 4.0, 4.01, 4.01 SP1, 4.01 SP2, 5, 5.01, 5.01 SP1, 5.5, 5.5 Service Pack 1
Microsoft Visual Studio, Enterprise Edition 6.0

--------------------------------------------------------------------------------


SUMMARY
This article illustrates how to programmatically copy an image on a Web page (an IMG element) to the clipboard.



MORE INFORMATION
The best way to copy an image on a Web page to the clipboard is to use the execCommand method of the controlRange object. The following code illustrates to do this from within script on the page itself (given the ID of the image to be copied):


function copyImage(sImgID)
{
var ctrlRange = document.body.createControlRange();
ctrlRange.add(document.all(sImgID));
ctrlRange.execCommand("Copy");
}
In Microsoft Visual C++, this method call translates to IHTMLControlRange::execCommand. The following code illustrates how to implement the same technique in Visual C++ given an IDispatch pointer to the document that contains the image and the ID of the IMG element wrapped in a VARIANT structure (with a type VT_BSTR):

STDMETHODIMP CMyBrowser::CopyImage(LPDISPATCH pDispDoc, VARIANT vImageID)
{
HRESULT hr = E_FAIL;
IHTMLDocument2* pDoc = NULL;
IHTMLElement* pelmBody = NULL;
IHTMLElement2* pelmBodyTwo = NULL;
IDispatch* pdispImgElement = NULL;
IDispatch* pdispCtrlRange = NULL;
IHTMLElementCollection* pColl = NULL;
IHTMLControlElement* pCtrlElement = NULL;
IHTMLControlRange* pCtrlRange = NULL;
BSTR bstrCommand = SysAllocString(L"Copy");
VARIANT_BOOL vbReturn;
VARIANT vEmpty;
VariantInit(&vEmpty);

if (pDispDoc == NULL)
goto Cleanup;

if (FAILED(pDispDoc->QueryInterface(IID_IHTMLDocument2, (void**) &pDoc)))
goto Cleanup;

if (FAILED(pDoc->get_all(&pColl)))
goto Cleanup;

if (FAILED(pColl->item(vImageID, vEmpty, &pdispImgElement))
|| pdispImgElement == NULL)
goto Cleanup;

if (FAILED(pDoc->get_body(&pelmBody)) || pelmBody == NULL)
goto Cleanup;

if (FAILED(pelmBody->QueryInterface(IID_IHTMLElement2, (void**) &pelmBodyTwo))
|| pelmBodyTwo == NULL)
goto Cleanup;

if (FAILED(pelmBodyTwo->createControlRange(&pdispCtrlRange))
|| pdispCtrlRange == NULL)
goto Cleanup;

if (FAILED(pdispCtrlRange->QueryInterface(IID_IHTMLControlRange, (void**) &pCtrlRange))
|| pCtrlRange == NULL)
goto Cleanup;

if (FAILED(pdispImgElement->QueryInterface(IID_IHTMLControlElement, (void**) &pCtrlElement))
|| pCtrlElement == NULL)
goto Cleanup;

hr = pCtrlRange->add(pCtrlElement);

if (SUCCEEDED(hr))
hr = pCtrlRange->execCommand(bstrCommand, VARIANT_FALSE, vEmpty, &vbReturn);

pCtrlElement->Release();
hr = S_OK;

Cleanup:

SysFreeString(bstrCommand);

if (pCtrlRange)
pCtrlRange->Release();

if (pdispCtrlRange)
pdispCtrlRange->Release();

if (pelmBodyTwo)
pelmBodyTwo->Release();

if (pelmBody)
pelmBody->Release();

if (pdispImgElement)
pdispImgElement->Release();

if (pColl)
pColl->Release();

if (pDispDoc)
pDispDoc->Release();

return hr;
}


16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧