Drag & Drop of Bitmap between applications

G

Guest

I am pretty sure that I am just missing some little piece of knowledge...

I have a test application. It has a text box and a picture box in a panel
(so I can get drag/drop for the picture box.)

The issue I have is that I can NOT drag a picture box object into another
application (either a second image of the test program or MS Word.) Here is
what I have:

1. I can drag the text of text box to another text box in the application
2. I can drag the text of text box to msWord (or any other app)
3. I can drag the bitmap in the picture box to another picture box in the
application
4. I can NOT drag the bitmap in the picture box to msWord (or any other app)
4a. I can put the bitmap on the clipboard and then paste it into msWord.
5. msWord can drag text and bitmaps to my test application.

So it smells like my code for starting the drag drop operation is not
complete when I am going to drag between applications. It's C#, and here is
the line of code from the pictureBox_MouseDown:

this.pictureBox1.DoDragDrop(this.pictureBox1.Image,DragDropEffects.Copy);

The clipboard copy is:
Clipboard.SetDataObject(this.pictureBox1.Image,false);

I thought I might need to create and DoDragDrop on a DataObject object; but
that was a dead end. Yes, I could write a file like IE does; but that seems
like unnecessary disk i/o.

Any ideas are appreciated...Chuck
 
T

TT \(Tom Tempelaere\)

Hi Chuck,

chuck rudolph said:
I am pretty sure that I am just missing some little piece of knowledge...

I have a test application. It has a text box and a picture box in a panel
(so I can get drag/drop for the picture box.)

The issue I have is that I can NOT drag a picture box object into another
application (either a second image of the test program or MS Word.) Here
is
what I have:

1. I can drag the text of text box to another text box in the application
2. I can drag the text of text box to msWord (or any other app)
3. I can drag the bitmap in the picture box to another picture box in the
application
4. I can NOT drag the bitmap in the picture box to msWord (or any other
app)
4a. I can put the bitmap on the clipboard and then paste it into msWord.
5. msWord can drag text and bitmaps to my test application.

So it smells like my code for starting the drag drop operation is not
complete when I am going to drag between applications. It's C#, and here
is
the line of code from the pictureBox_MouseDown:

this.pictureBox1.DoDragDrop(this.pictureBox1.Image,DragDropEffects.Copy);

The clipboard copy is:
Clipboard.SetDataObject(this.pictureBox1.Image,false);

I thought I might need to create and DoDragDrop on a DataObject object;
but
that was a dead end. Yes, I could write a file like IE does; but that
seems
like unnecessary disk i/o.

Any ideas are appreciated...Chuck

The following link might help

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/dragndropops.asp

Hope this helps,
Tom T.
 
G

Guest

Although I was not getting an error displayed (because I was probably not
waiting long enough), Tom's post prompted me to add try/catch to the code.
When I did, I found that I was getting the following exception out of
system.windows.forms.dll: "This remoting proxy has no channel sink which
means either the server has no registered server channels that are listening,
or this application has no suitable client channel to talk to the server."
The error id is E0434F4D, which looks to be just a general COM+ error. I have
reinstalled .Net framework 1.1 and it's sp.

I didn't find anything in the kb. Here's the full details of the error...

************** Exception Text **************
System.Runtime.Remoting.RemotingException: This remoting proxy has no
channel sink which means either the server has no registered server channels
that are listening, or this application has no suitable client channel to
talk to the server.
at
System.Runtime.Remoting.Proxies.RemotingProxy.InternalInvoke(IMethodCallMessage reqMcmMsg, Boolean useDispatchMessage, Int32 callType)
at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(IMessage reqMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type)
at System.Drawing.Image.get_FrameDimensionsList()
at System.Drawing.ImageAnimator.CanAnimate(Image image)
at System.Drawing.ImageInfo..ctor(Image image)
at System.Drawing.ImageAnimator.Animate(Image image, EventHandler
onFrameChangedHandler)
at System.Windows.Forms.PictureBox.Animate(Boolean animate)
at System.Windows.Forms.PictureBox.Animate()
at System.Windows.Forms.PictureBox.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e,
Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///d:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
killme1
Assembly Version: 1.0.1947.22176
Win32 Version: 1.0.1947.22176
CodeBase: file:///D:/Source%20Files/DragDrop/bin/Debug/killme1.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///d:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///d:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///d:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
IntegerTextBox
Assembly Version: 1.1.1839.19384
Win32 Version: 1.1.1839.19384
CodeBase: file:///D:/Source%20Files/DragDrop/bin/Debug/IntegerTextBox.DLL
----------------------------------------
System.Data
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///d:/windows/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///d:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
System.Runtime.Remoting
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///d:/windows/assembly/gac/system.runtime.remoting/1.0.5000.0__b77a5c561934e089/system.runtime.remoting.dll
----------------------------------------
 
J

Jean-Luc Henrotte

I experienced exactly the same, from a VB.net approach...
If someone solved this, a little help would be welcome.
I am using the ClipBoard as a workaround but this is not my goal...

Regards,
Jean-Luc.

The Effects and DataFormats are correctly retrieved but the drop operation is only working within the same application for bitmaps (texts are ok).
Between applications, I faced the same problem as Chuck.
Mike Gunderloy's article is OK for texts but not for bitmaps !


Droping a bitmap from MS-Word (Office 2003) to my application works well, but the contrary fails... The only workaround I found consists in using the clipboard and paste the bitmap into MS-Word.

I used a "To ClipBoard" button that way:

Private Sub B_CB_Click(ByVal s As System.Object, ByVal e As System.EventArgs) _
Handles B_CB.Click

' creates the bitmap to send to the clipboard (same size as a PictureBox PB)
Dim BM As New Bitmap(PB.Width, PB.Height)

' sets a reference to the Graphics of the bitmap
Dim g As Graphics = Graphics.FromImage(BM)

' builds the graphics (with g.DrawEllipse, g.DrawCurve, etc...)
BuildGraphics(g)

' sends the painted bitmap to the clipboard
Clipboard.SetDataObject(BM)

' --- this works also...
' Dim MyData As New DataObject(DataFormats.Bitmap, BM)
' Clipboard.SetDataObject(MyData)

End Sub





From http://www.developmentnow.com/g/29_2005_4_0_0_511368/Drag-Drop-of-Bitmap-between-applications.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top