文件夹主页中的用户控件未初始化

发布于 2024-07-08 20:00:48 字数 969 浏览 4 评论 0原文

我正在使用 Visual Studio 2008 对 Outlook 2003 加载项进行编程。

加载项在文件夹的主页中使用嵌入式用户控件,就像以前一样 受到推崇的。 以下是文件夹主页的 HTML 代码:

<html><head><style type="text/css">body{overflow: hidden}</style></head>
    <body rightmargin = '0' leftmargin ='0' topmargin ='0' bottommargin = '0' onload='OnBodyLoad()'>
        <script>
            function OnBodyLoad()
            {
                var outlook = window.external.OutlookApplication;
                FolderView.Initialize(outlook);
            }
        </script>
        <object classid='clsid:C718A848-6C31-4897-8DA8-0EDE3A4C6F14'
            id='FolderView' VIEWASTEXT width='100%' height='100%' />
    </body>
</html>

HTML 代码在活动浏览器的 HTMLDocument 属性中插入 文件夹切换事件。

在控件的 OnLoad 事件中,使用对应用程序实例的引用 (作为参数传递给它的 Initialize 方法),但有时 在触发 OnLoad 事件之前控件未初始化。 它刚刚创建, 但初始化方法永远不会被调用。

有人有类似的经历吗? 这是正常行为吗?

I am programming Outlook 2003 add-in using Visual Studio 2008.

Add-in uses embedded user control in folder's home page, like as it was
recommended. Here is HTML code for folder's home page:

<html><head><style type="text/css">body{overflow: hidden}</style></head>
    <body rightmargin = '0' leftmargin ='0' topmargin ='0' bottommargin = '0' onload='OnBodyLoad()'>
        <script>
            function OnBodyLoad()
            {
                var outlook = window.external.OutlookApplication;
                FolderView.Initialize(outlook);
            }
        </script>
        <object classid='clsid:C718A848-6C31-4897-8DA8-0EDE3A4C6F14'
            id='FolderView' VIEWASTEXT width='100%' height='100%' />
    </body>
</html>

HTML code is inserted in HTMLDocument property of the active explorer during
FolderSwitch event.

In control's OnLoad event, a reference to application instance is used
(which was passed as a parameter to its Initialize method), but sometimes
control is not initialized before OnLoad event is fired. It is just created,
but Initialize method is never invoked.

Does somebody has similar experiences? Is this usual behavior?

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

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

发布评论

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

评论(1

淡淡の花香 2024-07-15 20:00:48

我没有使用 Outlook 2003 或任何其他版本的经验,但我了解 html 和 JavaScript,因此我建议不要立即触发该方法,因为在某些“浏览器/客户端”中,内部使用的值或需要它的东西方法内的 continue 尚不可用。 您最好在调用该方法时添加延迟,也许这会解决您的问题,因为这已经解决了我过去的许多问题。

示例:

document.addEventListener('onload', function (e) { yourFunction(params); }, false);

注意:它可能是 onload 或 onbodyload。

I have no experience with Outlook 2003 or any other version of it, BUT I know about html and JavaScript, so I would recommend to not fire the method instantly cause in some "browsers/clients" the values used inside or the things need it to continue inside the method are not available yet. You better add a delay when calling the method and maybe that will fix your problem, cause that have solved many of my problems in the past.

Example:

document.addEventListener('onload', function (e) { yourFunction(params); }, false);

NOTE: it might be onload or onbodyload.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文