在标题中的 Word 2003 自动化中使用拖放的奇怪行为
我正在为Word 2003 开发一个基于模板的插件,它允许用户将元素从列表框拖放到word 文档中。不幸的是,当我尝试在文档标题中删除元素时,我遇到了非常奇怪的行为。
- 打开模板并在标题中键入内容
- 关闭标题并在页面上插入一些内容
- 添加分页符。
- 切换到页面布局模式,并将缩放级别设置为“两页”
- 打开标题
- 缓慢地将列表项从列表框拖放到标题。
- 查看出现多个页面设置对话框,导致 Word 崩溃。
这是我的代码:
// in ThisDocument.cs
public MyUserControl _control;
public void Init()
{
_control = new MyUserControl();
ActionsPane.Controls.Add(_control);
ActionsPane.Visible = true;
}
// in MyUserControl.cs
public void listBox1_MouseDown(object sender, MouseEventArgs e)
{
DoDragDrop("something", DragDropEffects.Copy);
}
我在实现拖放时是否犯了一些错误?对于这种奇怪的行为有解决方法吗?
预先感谢,
Oliver Hanappi
视频
我制作了一个小视频来展示该错误。您可以从这里下载: http://rapidshare.com/files/364907873 /word-2003-bug.rar
不幸的是,我使用的工具没有注意到我更改了显示设置,所以虽然我使用了1280x768,但它记录的是1920x1200,所以对于奇怪的视频尺寸感到抱歉。如果您无法观看视频,则可能缺少编解码器。您可以在这里获取它: http://camstudio.org/
我还忘了提及该错误也发生在Word 2007。因为我本地机器上只有Word 2007,所以我用Word 2007录制视频,但与Word 2003基本相同(我发现了错误)
I am developing a template based addin for Word 2003 which allows the user to drag and drop elements from a listbox into the word document. Unfortunately I'm getting a really strange behaviour when trying to drop elements in the document's header.
- Open the template and type something in the header
- Close the header and insert some content on the page
- Add a page break.
- Switch to page layout mode where and set zoom level to "Two Pages"
- Open the header
- Slowly Drag and Drop an list item from the list box to the header.
- See multiple Page Setups dialogs occur which cause Word to crash.
Here is my code:
// in ThisDocument.cs
public MyUserControl _control;
public void Init()
{
_control = new MyUserControl();
ActionsPane.Controls.Add(_control);
ActionsPane.Visible = true;
}
// in MyUserControl.cs
public void listBox1_MouseDown(object sender, MouseEventArgs e)
{
DoDragDrop("something", DragDropEffects.Copy);
}
Have I done somethinkg wrong with implementing Drag and Drop? Is there a workaround for this strange behaviour?
Thanks in advance,
Oliver Hanappi
Video
I've made a little video which shows the bug. You can download it from here: http://rapidshare.com/files/364907873/word-2003-bug.rar
Unfortunately the tool I used didn't notice that I changed the display settings, so although I used 1280x768, it recorded 1920x1200, so sorry for the strange video size. If you cannot watch the video, maybe the codec is missing. You can get it here: http://camstudio.org/
I also forgot to mention that the bug also occurs in Word 2007. Because on my local machine I have only Word 2007, I recorded the video with Word 2007, but it is basically the same for Word 2003 (where I found the bug)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这在 Word 2007 中对我有用,但它似乎是一个糟糕的解决方法。尝试使用剪贴板在文档中设置关键字,然后处理 WindowSelectionChange 事件,该事件似乎在文本插入后可靠地触发,以执行您真正想要完成的操作。
This worked for me in Word 2007, but it seems like an awful work-around. Try using the clipboard to set a keyword in the document, then handle the WindowSelectionChange event that seems to fire reliably after text insertion to do what you really want to get done.
在 Word 2011 for mac 中,对于 doc 和 docx 文件也会发生这种情况
还有一个问题是标题和光标的视觉重复。前两个问题是 Windows 2007 的已知问题。
Also happens in Word 2011 for mac both with doc and docx files
there is also a problem with visual duplication of headers and artifacts from cursors. The first two problems were known issues with 2007 for windows.