IE编程的问题:IOleCommandTarget::Exec(., IDM_SAVEAS, .)后怎样取得用户保存的文件名称,(附代码)

mty 2002-09-19 02:35:29
问题如上,代码如下:
MSHTML::IHTMLDocument2Ptr pdoc;
_variant_t varinput,varoutput;
IOleCommandTarget *pCmd;
HRESULT hr;
pdoc=m_cBrowser.GetDocument();
hr=pdoc.QueryInterface(IID_IOleCommandTarget,&pCmd);
if(SUCCEEDED(hr))
{
varinput=_T("");
hr=pCmd->Exec(&CGID_MSHTML,IDM_SAVEAS,OLECMDEXECOPT_DODEFAULT,&varinput,&varoutput);
// 这里我怎么才能取得被保存的文件名,varoutput好像没用
}
请大虾帮忙!
...全文
163 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
mty 2002-09-20
  • 打赏
  • 举报
回复
救命啊。。。。期待中。。。。
mty 2002-09-20
  • 打赏
  • 举报
回复
Up
mty 2002-09-20
  • 打赏
  • 举报
回复
应该不会吧,微软应该对这么明显的问题进行过测试吧....
不过看了你给我的那个连接,确实好像是那么说的。。。。郁闷中。。。
蒋晟 2002-09-19
  • 打赏
  • 举报
回复
Bug?
mty 2002-09-19
  • 打赏
  • 举报
回复
thanks...
but when I do it as it describes, it doesn't affect but add a "filename.ext" on the SaveAs-Dialog's filename-EDIT control,
that is, it displays the SaveAs dialog also....
there is my coding follow:

.....

varinput.vt = VT_BSTR;
varinput.bstrVal = _bstr_t("f:\\test2.htm"); // set saveas name
//OLECMDEXECOPT_DODEFAULT; OLECMDEXECOPT_DONTPROMPTUSER
hr=pCmd->Exec(&CGID_MSHTML,IDM_SAVEAS,
OLECMDEXECOPT_DONTPROMPTUSER,
// set do not prompt, MSOCMDEXECOPT_DONTPROMPTUSER,
&varinput, NULL);

...
??
蒋晟 2002-09-19
  • 打赏
  • 举报
回复
Yes
but u should check the return value of DoModal first(do save if it is IDOK)

at
http://msdn.microsoft.com/workshop/browser/mshtml/reference/constants/saveas.asp
pvaIn VARIANT of type VT_BSTR that specifies the path and file name of the file to which to save the Web page. When the path contains more than one folder name, separate the folder names with two backward slashes (\\).
mty 2002-09-19
  • 打赏
  • 举报
回复
mty 2002-09-19
  • 打赏
  • 举报
回复
I get you..
CFileDialog file;
file.DoModal();
CString strFile = file.GetPathName();

// then send WM_COMMAND with IDM_SAVEAS to web control

but how can I send strFile to it..? that is, how can Exec accept strFile as it's parameter? by varinput?
mty 2002-09-19
  • 打赏
  • 举报
回复
能否说详细一点?你意思是
pCmd->Exec(&CGID_MSHTML,IDM_SAVEAS,
OLECMDEXECOPT_DONTPROMPTUSER , // no prompt
&varinput,&varoutput);

then use CFileDialog? or use it before calling pCmd->Exec()? or ?
Many thanks!
蒋晟 2002-09-19
  • 打赏
  • 举报
回复
prompt using CFileDialog,and send IDM_SAVEAS command without prompt
mty 2002-09-19
  • 打赏
  • 举报
回复
自己顶一下

16,550

社区成员

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

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

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