Powerpoint 中的 VSTO:更改 WindowSelectionChange 中的自定义任务窗格可见性会移动选定的形状

发布于 2024-12-24 18:52:12 字数 480 浏览 0 评论 0原文

我想我发现了一个错误。 我正在为 Powerpoint 2010 开发一个加载项。当选择/取消选择形状(例如图片)时,将触发 WindowSelectionChange 事件。 但是,如果我使用此事件更改自定义任务窗格的可见性属性,则形状会在幻灯片上向左/向右移动。示例:

Private Sub Application_WindowSelectionChange(Sel As Microsoft.Office.Interop.PowerPoint.Selection) Handles Application.WindowSelectionChange
    cTaskPane.Visible = Not cTaskPane.Visible
End Sub

我尝试监视形状的 Left 属性,并且该属性从 WindowSelectionChange 子项的开始到结束都没有改变。因此,这件事必须是事后发生的。

我怎样才能避免这种情况? 有什么解决办法吗?

I think I have found a bug.
I am developing a add-in for Powerpoint 2010. The event WindowSelectionChange is fired when a shape (e.g. a picture) is selected/deselected.
However, if I use this event to change the Visibility property of a Custom Task Pane, then the shape moves left/right on the slide. Example:

Private Sub Application_WindowSelectionChange(Sel As Microsoft.Office.Interop.PowerPoint.Selection) Handles Application.WindowSelectionChange
    cTaskPane.Visible = Not cTaskPane.Visible
End Sub

I have tried to monitor the Left property of the shape, and that does not change from the beginning to the end of the WindowSelectionChange sub. Thus, it must happen afterwards.

How can I avoid this?
Any workaround?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

九八野马 2024-12-31 18:52:12

这是因为你的鼠标按住了形状,当窗口缩小时,形状会向右移动。

更详细地说,移动分 4 个步骤进行:

  1. 按下鼠标,导致窗口选择发生变化,然后窗格变得可见,这使得幻灯片视图窗口缩小;
  2. 由于幻灯片视图窗口缩小了,而鼠标的位置保持不变,因此您的鼠标会向右移动到幻灯片;
  3. 由于按下鼠标,形状会锚定在鼠标上,从而移动到鼠标的当前位置;
  4. 当窗格再次变得不可见时,幻灯片视图窗口会变回其大小,形状也会相应地再次移动。

为了避免这种情况,我建议您使用 WindowSelectionChange 事件并检查选择是否为形状(代码在 c# 中):

private void WindowSelectionChangedHandler(PowerPoint.Selection selection)
{
    if (selection.Type == PowerPoint.PpSelectionType.ppSelectionShapes)
    {
         //do your stuff
    }
}

It's because your mouse is holding the shape, and the shape gets moved to the right when the window is shrunk.

In more detail, the moving occurs in 4 steps:

  1. You press mouse, caused window selection change, then the pane becomes visible, which makes the slide view window shrink;
  2. Since the slide view window shrunk while your mouse's position remains to be the same, your mouse is moved right w.r.t the slide;
  3. Since your mouse is pressing, the shape is anchored with your mouse, thus move to the current position of the mouse;
  4. When pane becomes invisible again, the slide view window changes its size back, the shape is moving accordingly again.

To avoid this, I suggest you use WindowSelectionChange event and check if the selection is shape (code is in c#):

private void WindowSelectionChangedHandler(PowerPoint.Selection selection)
{
    if (selection.Type == PowerPoint.PpSelectionType.ppSelectionShapes)
    {
         //do your stuff
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文