0

wan't to write a outlook add-in which manipulate the email message when the user want to save the file local on the desk via drag and drop.

At the moment I'm not able to get the MouseDown event of the window. Is there an specific Windows Message which i can observe?

And is there any way to manipulate the data which is currently in the drag event?

Many thanks for you help!

I've already tried

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;
using System.Windows.Forms;

namespace OutlookAddIn1
{
    public partial class ThisAddIn
    {

        Outlook.Explorer explorer;

        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {

            explorer = Application.ActiveExplorer();

            explorer.BeforeItemCopy += new Outlook.ExplorerEvents_10_BeforeItemCopyEventHandler(Explorer_BeforeItemCopy);

        }

        private void OnDragEnter(object sender, System.Windows.Forms.DragEventArgs e)
        {
            MessageBox.Show("OnDragEnter");
        }

        void Explorer_BeforeItemCopy(ref bool cancel)
        {
            MessageBox.Show("copied");
        }
    }
}
AppVault
  • 65
  • 7

1 Answers1

0

There is no need to use Windows Messages, nor MouseDown event for this. You are simply using the wrong event. What you need to handle is:

  • DragEnter
  • DragOver
  • DragDrop
  • DragLeave

See this sample:

https://www.codeproject.com/articles/9017/a-simple-drag-and-drop-how-to-example

Oscar
  • 13,594
  • 8
  • 47
  • 75
  • Sorry but I have no form behind my add in. It's just an outlook addin which should handle the drag behavior in outlook mail list (Application.ActiveExplorer();). – AppVault Mar 21 '17 at 13:23
  • @AppVault You don't need a code behind file. Just add event handlers as needed in you add in constructor and react to those event appropriately. – Oscar Mar 21 '17 at 13:25
  • like this? explorer.BeforeItemCopy += new Outlook.ExplorerEvents_10_BeforeItemCopyEventHandler(Explorer_BeforeItemCopy); – AppVault Mar 21 '17 at 13:31
  • Normal Drag events will not work thats the reason why I try to get the DragDrop Windows Message from the application. But I don't know how to do this :( – AppVault Mar 21 '17 at 16:19