<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>oliana.de &#187; Outlook</title>
	<atom:link href="http://oliana.de/blog/tag/outlook/feed/" rel="self" type="application/rss+xml" />
	<link>http://oliana.de/blog</link>
	<description>Das Problem zwischen Stuhl und Bildschirm</description>
	<lastBuildDate>Mon, 12 Apr 2010 14:20:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Registerkarte zum Outlook Optionen-Dialog hinzuf&#252;gen</title>
		<link>http://oliana.de/blog/2008/04/09/registerkarte-zum-outlook-optionen-dialog-hinzufgen/</link>
		<comments>http://oliana.de/blog/2008/04/09/registerkarte-zum-outlook-optionen-dialog-hinzufgen/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 22:02:41 +0000</pubDate>
		<dc:creator>Denis</dc:creator>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Add-In]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Office 2007]]></category>
		<category><![CDATA[Outlook]]></category>

		<guid isPermaLink="false">http://oliana.de/blog/2008/04/09/registerkarte-zum-outlook-optionen-dialog-hinzufgen/</guid>
		<description><![CDATA[Nachdem ich jetzt ca. 1 Std. gebraucht habe um herauszufinden wie es geht beschreibe ich das einfache Verfahren.

Zunächst fügt man seinem Outlook Add-In Projekt ein Benutzersteuerelement hinzu welches die Registerkarte die man später im Optionen-Dialog haben möchte darstellt. Ich habe dieses in diesem Beispiel ctlOptionen genannt. Wichtig ist, dass man die erste Zeile (&#8221; &#8230; [...]]]></description>
			<content:encoded><![CDATA[<p>Nachdem ich jetzt ca. 1 Std. gebraucht habe um herauszufinden wie es geht beschreibe ich das einfache Verfahren.</p>
<p><span id="more-75"></span><br />
Zunächst fügt man seinem Outlook Add-In Projekt ein Benutzersteuerelement hinzu welches die Registerkarte die man später im Optionen-Dialog haben möchte darstellt. Ich habe dieses in diesem Beispiel ctlOptionen genannt. Wichtig ist, dass man die erste Zeile (&#8221; &#8230; ComVisible(true)&#8221;) hinzufügt, da das Steuerelement ansonsten nicht als ActiveX COM Element sichtbar ist. (Dies war übrigens auch mein großes Problem, aber da muss man erst einmal ohne Fehlermeldung drauf kommen&#8230; <a href="http://ahmed0192.blogspot.com/2006/01/adding-new-page-to-outlook-options.html">Hier</a> habe ich endlich die Lösung gefunden.)
</p>
<p>Ausserdem habe ich <a href="http://blog.irm.se/blogs/eric/archive/2006/12/22/Adding-a-Property-Page-to-Oulook-2007-Options-Dialog.aspx">hier</a> eine Methode gefunden um das PropertyPageSite Objekt zu bekommen welches man braucht um das Optionen Formular durch aufrufen des OnStatusChange Ereignisses darüber zu benachrichtigen, dass sich etwas in den Optionen geändert hat. Es sollte beachtet werden, dass in diesem Beispiel beim Ändern von Einstellungen die isDirty-Variable über die entsprechende Eigenschaft auf true gesetzt werden muss, damit das Optionen-Formular benachrichtigt wird.</p>
<div>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">[System.Runtime.InteropServices.ComVisible(<span style="color: #0000ff">true</span>)]
<span style="color: #0000ff">public</span> <span style="color: #0000ff">partial</span> <span style="color: #0000ff">class</span> ctlOptionen : UserControl,
    Microsoft.Office.Interop.Outlook.PropertyPage
{
    <span style="color: #0000ff">private</span> <span style="color: #0000ff">bool</span> isDirty = <span style="color: #0000ff">false</span>;
    <span style="color: #0000ff">private</span> Microsoft.Office.Interop.Outlook.PropertyPageSite site;

    <span style="color: #0000ff">public</span> ctlOptionen()
    {
        InitializeComponent();
    }

    <span style="color: #cc6633">#region</span> PropertyPageSite Objekt holen
    <span style="color: #008000">/// &lt;summary&gt;</span>
    <span style="color: #008000">/// Hier wird die entpsrechende PropertyPageSite geholt, bei der das OnStatusChange()</span>
    <span style="color: #008000">/// Ereignis ausgelöst wird um das Optionen-Formular zu benachrichtigen, dass etwas</span>
    <span style="color: #008000">/// geändert wurde.</span>
    <span style="color: #008000">/// &lt;/summary&gt;</span>
    <span style="color: #008000">/// &lt;param name="sender"&gt;&lt;/param&gt;</span>
    <span style="color: #008000">/// &lt;param name="e"&gt;&lt;/param&gt;</span>
    <span style="color: #0000ff">private</span> <span style="color: #0000ff">void</span> ctlOptionen_Load(<span style="color: #0000ff">object</span> sender, EventArgs e)
    {
        Type type = <span style="color: #0000ff">typeof</span>(UserControl);
        Type oleType = type.Assembly.GetType(
            <span style="color: #006080">"System.Windows.Forms.UnsafeNativeMethods+IOleObject"</span>);
        <span style="color: #0000ff">if</span> (oleType == <span style="color: #0000ff">null</span>) <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> InvalidOperationException(
            <span style="color: #006080">"Could not get 'System.Windows.Forms.UnsafeNativeMethods+IOleObject'."</span>);

        System.Reflection.MethodInfo method =
            oleType.GetMethod(<span style="color: #006080">"GetClientSite"</span>);
        <span style="color: #0000ff">if</span> (method == <span style="color: #0000ff">null</span>) <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> InvalidOperationException(
            <span style="color: #006080">"Could not get method 'IOleObject.GetClientSite'."</span>);

        site = method.Invoke(<span style="color: #0000ff">this</span>, <span style="color: #0000ff">null</span>) <span style="color: #0000ff">as</span>
            Microsoft.Office.Interop.Outlook.PropertyPageSite;
    }
    <span style="color: #cc6633">#endregion</span>

    <span style="color: #cc6633">#region</span> PropertyPage Member

    <span style="color: #008000">/// &lt;summary&gt;</span>
    <span style="color: #008000">/// Wird aufgerufen wenn die gemachten Änderungen gespeichert werden sollen </span>
    <span style="color: #008000">/// (Klick auf OK bzw. Übernehmen)</span>
    <span style="color: #008000">/// &lt;/summary&gt;</span>
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> Apply()
    {
    }
    <span style="color: #008000">/// &lt;summary&gt;</span>
    <span style="color: #008000">/// Gibt true zurück, wenn die Optionen der Seite sich geändert haben. </span>
    <span style="color: #008000">/// Wird von Outlook benutzt um zu entscheiden ob der Übernehmen-Button aktiviert ist.</span>
    <span style="color: #008000">/// Beim setzen wird hier das Optionen-Formular benachrichtigt, dass sich etwas </span>
    <span style="color: #008000">/// geändert hat.</span>
    <span style="color: #008000">/// &lt;/summary&gt;</span>
    [Browsable(<span style="color: #0000ff">false</span>)]
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">bool</span> Dirty
    {
        get { <span style="color: #0000ff">return</span> isDirty; }
        set
        {
            <span style="color: #0000ff">if</span> (isDirty != <span style="color: #0000ff">value</span>)
            {
                isDirty = <span style="color: #0000ff">value</span>;
                <span style="color: #0000ff">if</span> (site != <span style="color: #0000ff">null</span>) site.OnStatusChange();
            }
        }
    }

    <span style="color: #008000">/// &lt;summary&gt;</span>
    <span style="color: #008000">/// Hier kann man eine Hilfedatei angeben die mit dieser Seite verknüpft ist.</span>
    <span style="color: #008000">/// &lt;/summary&gt;</span>
    <span style="color: #008000">/// &lt;param name="HelpFile"&gt;&lt;/param&gt;</span>
    <span style="color: #008000">/// &lt;param name="HelpContext"&gt;&lt;/param&gt;</span>
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> GetPageInfo(<span style="color: #0000ff">ref</span> <span style="color: #0000ff">string</span> HelpFile, <span style="color: #0000ff">ref</span> <span style="color: #0000ff">int</span> HelpContext)
    {
    }

    <span style="color: #cc6633">#endregion</span>
}</pre>
</div>
<p>Als nächstes fügt man einen Ereignishandler (Das ist tatsächlich die deutsche Übersetzung laut MSDN&#8230;) für das OptionPagesAdd-Event hinzu. Dieses Ereignis wird jedes mal angestoßen wenn der Optionen-Dialog geöffnet wird. Dieser kann gut in der ThisAddIn_Startup Methode der ThisAddIn-Klasse untergebracht werden.</p>
<div>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">Application.OptionsPagesAdd += <span style="color: #0000ff">new</span> Microsoft.Office.Interop.Outlook
    .ApplicationEvents_11_OptionsPagesAddEventHandler
        (Application_OptionsPagesAdd);</pre>
</div>
<p>Dementsprechend wird auch die Methode erstellt welche dann nichts anderes tut als die Registerkarte hinzuzufügen.</p>
<div>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">void</span> Application_OptionsPagesAdd
    (Microsoft.Office.Interop.Outlook.PropertyPages Pages)
{
    Pages.Add(<span style="color: #0000ff">new</span> ctlOptionen(), <span style="color: #006080">"Meine Optionen"</span>);
}</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://oliana.de/blog/2008/04/09/registerkarte-zum-outlook-optionen-dialog-hinzufgen/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.701 seconds -->
