Hallo,
ich versuche seit einer Woche erfolglos, aus meiner .NET Anwendung heraus die Möglichkeit zu implementieren, ein Bitmap Objekt mittels Drag und Drop in eine Win32-Anwendung zu kopieren. Folgender Code lässt das ebenfalls nicht zu:
using System;
using System.Drawing;
using System.Windows.Forms;
class DragDrop: Form
{
Bitmap bmp;
bool button;
public new static void Main()
{
Application.Run(new DragDrop());
}
public DragDrop()
{
bmp = new Bitmap(200, 200);
Graphics grfx = Graphics.FromImage(bmp);
grfx.DrawLine(Pens.Black, 0, 0, 200, 200);
grfx.Dispose();
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (button == true)
DoDragDrop(bmp, DragDropEffects.Copy | DragDropEffects.Move);
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
button = true;
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
button = false;
}
}
Wenn man vom Formularfeld aus DragDrop ausführen will, zum Beispiel in Word hinein, wird klar, was ich meine. DragDrop scheint bei Bitmaps nicht zu funktionieren! Wisst Ihr, was ich da falsch mache?
Danke und Gruß
Alex