如何禁用自定义任务窗格的调整大小和关闭按钮?
如何防止 Office 自定义任务窗格调整大小,以便它始终具有尺寸并且无法使用“关闭”按钮关闭。
myCustomTaskPane.Height = 500;
myCustomTaskPane.Width = 500;
How can I prevent an Office Custom Task Pane for resizing, so that it's only and always have the dimensions and can't be closing with the "close" button.
myCustomTaskPane.Height = 500;
myCustomTaskPane.Width = 500;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
至于调整大小,只需监视任务窗格的调整大小事件并重置大小即可。但是,您可能会考虑+为什么+您想要这样做。如果任务窗格有最小必要大小,则限制最小大小可能更有意义。如果内容可以调整大小,也许应该如此。
您还可以重写 OnLayout 方法。这通常会效果更好。
对于“关闭”按钮,我认为您需要拦截“VisibleChanged”事件并使窗格可见(如果它已隐藏)。我记得,任务窗格本身实际上并不是“关闭”的,只是设置为不可见。
As far as the resize, just monitor your task pane's resize event and reset the size. However you might consider +why+ you'd want to do that. If there's a minimum necessary size for your taskpane, it might make more sense to restrict the minimum. and if the contents are resizable, maybe they should be.
You might also override the OnLayout method. That will often work better.
For the Close button, I think you'd want to intercept the "VisibleChanged" event and make the pane visible if it's been hidden. As I recall, taskpanes are not actually "closed" per se, but just set invisible.
其中 _tp 是对任务窗格(不是 CustomTaskPane 容器)的引用,_ctp 是 CustomTaskPane 容器,iw 是 InspectorWrapperDictionary:
并且,在任务窗格代码中:
setvars() 是一个命令,用于拉入正确的 iw 并设置对 _tp 和 _ctp 的引用
Where _tp is a reference to your task pane (not the CustomTaskPane container), _ctp is the CustomTaskPane container, iw is the InspectorWrapperDictionary:
And, in your task pane code:
setvars() is a command to pull in the proper iw and set the references to _tp and _ctp
我找到了一个解决方案:
I find a Solution for this One :
对于“不得关闭”问题的一部分,您可以使用这个而不是计时器:
希望它有帮助,
约尔格
For the "Must not be closed"-Part of the problem you can maybe use this one instead of a timer:
Hope it helps,
Jörg