[WinForm]axWebBrowser调用IE的添加到收藏夹对话框

huing 2007-08-02 03:09:24
这是伴水的方法
using System.Runtime.InteropServices;

[DllImport("User32.DLL")]
public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam,
int lParam);
[DllImport("User32.DLL")]
public static extern IntPtr FindWindowEx(IntPtr hwndParent,
IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
public int IDM_ADDFAVORITES = 2261;
public uint WM_COMMAND = 0x0111;

private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("http://blog.sina.com.cn/zswang");
}

private void button1_Click(object sender, EventArgs e)
{
IntPtr vHandle = webBrowser1.Handle;

vHandle = FindWindowEx(vHandle, IntPtr.Zero, "Shell Embedding", null);//我这里得到的是0
vHandle = FindWindowEx(vHandle, IntPtr.Zero, "Shell DocObject View", null);//我这里得到的是0
vHandle = FindWindowEx(vHandle, IntPtr.Zero, "Internet Explorer_Server", null);//我这里得到的是0
SendMessage(vHandle, WM_COMMAND, IDM_ADDFAVORITES, (int)Handle);
}

请麻烦解释下那3行代码的含义,就是那3个FindWindowEx

还有,就是我装的是IE7,会有区别不?
...全文
231 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
huing 2007-08-15
  • 打赏
  • 举报
回复
up
huing 2007-08-14
  • 打赏
  • 举报
回复
怎么没有看见 伴水 来呢
shinaterry 2007-08-10
  • 打赏
  • 举报
回复
JF...
zhchg6666 2007-08-10
  • 打赏
  • 举报
回复
mark
huing 2007-08-10
  • 打赏
  • 举报
回复
up
huing 2007-08-09
  • 打赏
  • 举报
回复
up
vainnetwork 2007-08-03
  • 打赏
  • 举报
回复
关注,帮顶了
huing 2007-08-03
  • 打赏
  • 举报
回复
ShellUIHelper helper = new ShellUIHelper();
IHTMLDocument2 document = (IHTMLDocument2)axWebBrowser1.Document;
object t = document.title;
helper.AddFavorite(document.url, ref t);//调用添加到收藏夹对话框


这样子好像可以的
huing 2007-08-03
  • 打赏
  • 举报
回复
先尝试一下
zxkid 2007-08-03
  • 打赏
  • 举报
回复
模式窗口必须调用DoAddToFavDlg()
参照 http://blog.csdn.net/lzmtw/archive/2007/03/15/1530746.aspx
huing 2007-08-03
  • 打赏
  • 举报
回复
这个又带来一个新的问题,就是如果form最大化后, 这个添加到收藏夹对话框窗口就在后面看不到了
zxkid 2007-08-02
  • 打赏
  • 举报
回复
怎么没人回答
先用 AxImp c:\windows\system32\shdocvw.dll
产生二个文件AxShdocvw.dll和shdocvw.dll

在项目中引用这二个DLL

在cs中引用:
using SHDocVw;

代码:
ShellUIHelper helper = new ShellUIHelper();
object t = webBrowser1.Document.Title;//我这里是vs2005的WebBrowser控件
helper.AddFavorite(webBrowser1.Url.ToString(), ref t);//调用添加到收藏夹对话框
object o = null;
helper.ShowBrowserUI("OrganizeFavorites", ref o);//调用整理收藏夹对话框
huing 2007-08-02
  • 打赏
  • 举报
回复
还有那个管理收藏夹的 对话框如何调用?

110,566

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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