谁知道一个第三方控件能将WORD窗口嵌入Winform 请问哪位仙人知道阿?比如我们在CSDN发帖的时候有个WORD编辑窗口 这个是怎么嵌进来的是第三方控件吗? 我在网上找的都是什么WebBrowser 不好用阿。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 去下载个fckeditor ,类似word,vs工具箱右键=》选择项 =》浏览 fckeditor 是类似回复时候这个WORD编辑区域吗? http://blog.sina.com.cn/s/blog_4ed18f290100f9ci.html public partial class Form1 : Form { public Form1() { InitializeComponent(); } [DllImport("user32.dll")] private static extern int SetParent(IntPtr hWndChild, IntPtr hWndParent); [DllImport("user32.dll")] private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); [DllImport("user32.dll", SetLastError = true)] private static extern bool PostMessage(IntPtr hWnd, uint Msg, int wParam, int lParam); [DllImport("user32.dll", EntryPoint = "SetWindowPos")] private static extern bool SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); [DllImport("user32.dll")] private static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam); [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] private static extern uint SetWindowLong(IntPtr hwnd, int nIndex, uint newLong); [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] private static extern uint GetWindowLong(IntPtr hwnd, int nIndex); [DllImport("user32.dll", CharSet = CharSet.Auto)] private static extern bool ShowWindow(IntPtr hWnd, short State); private const int HWND_TOP = 0x0; private const int WM_COMMAND = 0x0112; private const int WM_QT_PAINT = 0xC2DC; private const int WM_PAINT = 0x000F; private const int WM_SIZE = 0x0005; private const int SWP_FRAMECHANGED = 0x0020; public enum ShowWindowStyles : short { SW_HIDE = 0, SW_SHOWNORMAL = 1, SW_NORMAL = 1, SW_SHOWMINIMIZED = 2, SW_SHOWMAXIMIZED = 3, SW_MAXIMIZE = 3, SW_SHOWNOACTIVATE = 4, SW_SHOW = 5, SW_MINIMIZE = 6, SW_SHOWMINNOACTIVE = 7, SW_SHOWNA = 8, SW_RESTORE = 9, SW_SHOWDEFAULT = 10, SW_FORCEMINIMIZE = 11, SW_MAX = 11 } private void Form1_Load(object sender, EventArgs e) { Process p = new Process(); // 需要启动的程序 p.StartInfo.FileName = @"C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE"; // 为了美观,启动的时候最小化程序 p.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; // 启动 p.Start(); // 这里必须等待,否则启动程序的句柄还没有创建,不能控制程序 Thread.Sleep(1000); // 最大化启动的程序 ShowWindow(p.MainWindowHandle, (short)ShowWindowStyles.SW_MAXIMIZE); // 设置被绑架程序的父窗口 SetParent(p.MainWindowHandle, this.Handle); // 改变尺寸 ResizeControl(p); } // 控制嵌入程序的位置和尺寸 private void ResizeControl(Process p) { SendMessage(p.MainWindowHandle, WM_COMMAND, WM_PAINT, 0); PostMessage(p.MainWindowHandle, WM_QT_PAINT, 0, 0); SetWindowPos(p.MainWindowHandle, HWND_TOP, 0, // 设置偏移量,把原来窗口的菜单遮住 0, (int)this.Width, (int)this.Height, SWP_FRAMECHANGED); SendMessage(p.MainWindowHandle, WM_COMMAND, WM_SIZE, 0); } } 上面的这个代码,不能够保证100%,每次都可以将Word嵌入到Winform中, 楼主还可以多参考一下其他代码http://www.codeproject.com/KB/miscctrl/google_earth_embed.aspx 我印象中好像.NET3.5中不是有VSTO工具吗 winfrom 自己有 word组件 按一楼说的一定行,我之前用过,和CSDN上回复功能基本一样,好象还多些功能 WebBrowser???不好用?为什么,我找不出任何理由,我们都已经开发出成型的产品了. winform的文本编辑器DHTML Edit Control http://www.codeproject.com/KB/edit/editor_in_windows_forms.aspxhttp://windowsclient.net/downloads/folders/applications/entry1281.aspx 确实是第三方的控件 fckeditor 这个也不错的呀 那个,调用Word的组件不是能操作Word并且显示在窗体中么,,,,,...[align=center]*********************************************************** 欢迎使用 CSDN 小秘书 .Net 学习QQ群,欢迎加入: 67784580***********************************************************[/align] 我按照网上的步骤做的WEBBROWER做的小程序,在Winform里显示不了WORD,显示的是找不到该网页,是什么原因呢 http://www.cnblogs.com/peterzb/archive/2009/07/06/1517399.html c#中怎么打包一个完成的程序? checkBox1.Font.Height = 15;为什么不能附值 删除问题 C#调用Dll,调试速度奇慢 关于Repeater 的四星级难题,求教高手 同过.NET的前台界面来管理MS SQL的数据库(数据库备份,恢复)可以调用SQL 里的存储过程吗? 如何開啟一個對話框 怎么取消Treeview节点选中时蓝色背景 .NET控件的问题 有关字段问题 关于正则表达式的写法!(在线等) c# 如何读写*.dat,重点是写
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("user32.dll")]
private static extern int SetParent(IntPtr hWndChild, IntPtr hWndParent);
[DllImport("user32.dll")]
private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll", SetLastError = true)]
private static extern bool PostMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
private static extern bool SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
[DllImport("user32.dll")]
private static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern uint SetWindowLong(IntPtr hwnd, int nIndex, uint newLong);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern uint GetWindowLong(IntPtr hwnd, int nIndex);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern bool ShowWindow(IntPtr hWnd, short State); private const int HWND_TOP = 0x0; private const int WM_COMMAND = 0x0112; private const int WM_QT_PAINT = 0xC2DC; private const int WM_PAINT = 0x000F; private const int WM_SIZE = 0x0005; private const int SWP_FRAMECHANGED = 0x0020;
public enum ShowWindowStyles : short { SW_HIDE = 0, SW_SHOWNORMAL = 1, SW_NORMAL = 1, SW_SHOWMINIMIZED = 2, SW_SHOWMAXIMIZED = 3, SW_MAXIMIZE = 3, SW_SHOWNOACTIVATE = 4, SW_SHOW = 5, SW_MINIMIZE = 6, SW_SHOWMINNOACTIVE = 7, SW_SHOWNA = 8, SW_RESTORE = 9, SW_SHOWDEFAULT = 10, SW_FORCEMINIMIZE = 11, SW_MAX = 11 } private void Form1_Load(object sender, EventArgs e)
{
Process p = new Process();
// 需要启动的程序
p.StartInfo.FileName = @"C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE";
// 为了美观,启动的时候最小化程序
p.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
// 启动
p.Start();
// 这里必须等待,否则启动程序的句柄还没有创建,不能控制程序
Thread.Sleep(1000); // 最大化启动的程序
ShowWindow(p.MainWindowHandle, (short)ShowWindowStyles.SW_MAXIMIZE);
// 设置被绑架程序的父窗口
SetParent(p.MainWindowHandle, this.Handle);
// 改变尺寸
ResizeControl(p);
}
// 控制嵌入程序的位置和尺寸
private void ResizeControl(Process p)
{
SendMessage(p.MainWindowHandle, WM_COMMAND, WM_PAINT, 0);
PostMessage(p.MainWindowHandle, WM_QT_PAINT, 0, 0); SetWindowPos(p.MainWindowHandle, HWND_TOP,
0,
// 设置偏移量,把原来窗口的菜单遮住
0, (int)this.Width, (int)this.Height,
SWP_FRAMECHANGED);
SendMessage(p.MainWindowHandle, WM_COMMAND, WM_SIZE, 0);
}
}
http://www.codeproject.com/KB/miscctrl/google_earth_embed.aspx
DHTML Edit Control
http://www.codeproject.com/KB/edit/editor_in_windows_forms.aspx
http://windowsclient.net/downloads/folders/applications/entry1281.aspx
[align=center]***********************************************************
欢迎使用 CSDN 小秘书
.Net 学习QQ群,欢迎加入: 67784580
***********************************************************
[/align]
是什么原因呢