none
Determine the location of Outlook 2010 ActiveExplorer relative to the screen using C# RRS feed

  • Question

  • I just wrote an Outlook 2010 Add-In using Visual Studio 2012 and Visual Basic. One of the key requirements I needed to perform required identifying the location (the top/left origin) of the Outlook application. In Visual Basic, I was able to accomplish this by accessing the Top and Left properties of the ActiveExplorer using:

    appLocation.X = Globals.ThisAddIn.Application.ActiveExplorer.Left + My.Settings.FormItemsLocation.X
    appLocation.Y = Globals.ThisAddIn.Application.ActiveExplorer.Top + My.Settings.FormItemsLocation.Y
    

    However, this seems to be not possible using C#. Does anyone have any suggestions on how to accomplish this with C#? Please provide examples if possible.

    Thank you.

    Friday, April 26, 2013 5:12 PM

Answers

All replies

  • which part of vb code give you trouble in conversion to c#?
    Friday, April 26, 2013 5:20 PM
  • Hello DamianD,

    I guess I spoke prematurely. After I posted this message, I discovered where my problem was. In Visual Basic it is done it like so:

        Private Sub frmItemsForm_Load(sender As Object, e As System.EventArgs) Handles Me.Load
            Dim appLocation As New Drawing.Point(0, 0)
            appLocation.X = Globals.ThisAddIn.Application.ActiveExplorer.Left + My.Settings.FormItemsLocation.X
            appLocation.Y = Globals.ThisAddIn.Application.ActiveExplorer.Top + My.Settings.FormItemsLocation.Y
            Me.Location = appLocation
            UpdateItemList(lstView)
            UpdateDisplay(Me, lstView)
        End Sub

    But in C#, it is done like this:

            private void FormItemsForm_Load(object sender, EventArgs e)
            {
                Point appLocation = new Point(0, 0);
                appLocation.X = Globals.ThisAddIn.Application.ActiveExplorer().Left + Properties.Settings.Default.FormItemsLocation.X;
                appLocation.Y = Globals.ThisAddIn.Application.ActiveExplorer().Top + Properties.Settings.Default.FormItemsLocation.Y;
                this.Location = appLocation;
                UpdateItemList(lstView);
                UpdateDisplay(Me, lstView);
            }

    Thanks for your help though.

    Friday, April 26, 2013 5:40 PM
  • there is no such thing as 'Me' in C#, change it to 'this'
    Saturday, April 27, 2013 5:50 AM