Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Explorer DragImage?

Explorer DragImage?

Scheduled Pinned Locked Moved C#
linuxdata-structuresbeta-testingquestioncode-review
9 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TylerBrinks
    wrote on last edited by
    #1

    Does ANYONE know of a way to access the drag image created by the drag source (in this case Windows Explorer) so the same image can be displayed when dragging over the target control? It's easy enough to drag files from Explorer to another app since the FileDrop flag allows you to access a string array of file names. However, I'm trying to display the same drag image created by Explorer in order to give the user more meaningful feedback while dragging. All I've seen so far is that the IDragTargetHelper and IDragSourceHelper interfaces are helpful for shell drag operations. Of course, those interfaces are as well documented as everything on MSDN.... I'm desperate for an answer at this point, so anything helps, even if it seems elementary! Thanks!

    H 1 Reply Last reply
    0
    • T TylerBrinks

      Does ANYONE know of a way to access the drag image created by the drag source (in this case Windows Explorer) so the same image can be displayed when dragging over the target control? It's easy enough to drag files from Explorer to another app since the FileDrop flag allows you to access a string array of file names. However, I'm trying to display the same drag image created by Explorer in order to give the user more meaningful feedback while dragging. All I've seen so far is that the IDragTargetHelper and IDragSourceHelper interfaces are helpful for shell drag operations. Of course, those interfaces are as well documented as everything on MSDN.... I'm desperate for an answer at this point, so anything helps, even if it seems elementary! Thanks!

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      I find them and everything else on MSDN well documented enough. There is no functionality in the .NET BCL to help you - you will have to interop those interfaces (or find a library that does) and use the COM implementation of drag-n-drop. The IDataObject interface is similar to COM's interface and is eventually marshaled as COM's IDataObject, and Control.DoDragDrop uses the shell's DoDragDrop function. The interoperability between drag-n-drop/clipboard formats and structures in .NET and COM has been discussed extensively in the past. I have accomplished this and made use of COM's implementation to use other storage mediums and have directed another person in it as well. If you want to know more, click "Search comments" directly above the the message board and search for various keywords, like "STGMEDIUM" and/or "FORMATETC". Otherwise, read the MSDN documentation and related links and try to figure it out. I didn't have any problems when I learned many, many years ago when MSDN wasn't nearly as helpful as it is now - and it certainly beats reading *nix man pages!

      Microsoft MVP, Visual C# My Articles

      T 1 Reply Last reply
      0
      • H Heath Stewart

        I find them and everything else on MSDN well documented enough. There is no functionality in the .NET BCL to help you - you will have to interop those interfaces (or find a library that does) and use the COM implementation of drag-n-drop. The IDataObject interface is similar to COM's interface and is eventually marshaled as COM's IDataObject, and Control.DoDragDrop uses the shell's DoDragDrop function. The interoperability between drag-n-drop/clipboard formats and structures in .NET and COM has been discussed extensively in the past. I have accomplished this and made use of COM's implementation to use other storage mediums and have directed another person in it as well. If you want to know more, click "Search comments" directly above the the message board and search for various keywords, like "STGMEDIUM" and/or "FORMATETC". Otherwise, read the MSDN documentation and related links and try to figure it out. I didn't have any problems when I learned many, many years ago when MSDN wasn't nearly as helpful as it is now - and it certainly beats reading *nix man pages!

        Microsoft MVP, Visual C# My Articles

        T Offline
        T Offline
        TylerBrinks
        wrote on last edited by
        #3

        You’re making the assumption that assumption that I’m proficient in C++. Frankly I’m no further now that I was before. I’ve found plenty of articles that state the COM IDataObject interface is necessary, but I’ve found nothing that discusses it in VB or C#. I searched the keywords you suggested, but there’s still little that shows or explains how one might implement this in a language other than cpp. Can you perhaps elaborate or at least point to an article that has substance to it?

        H 1 Reply Last reply
        0
        • T TylerBrinks

          You’re making the assumption that assumption that I’m proficient in C++. Frankly I’m no further now that I was before. I’ve found plenty of articles that state the COM IDataObject interface is necessary, but I’ve found nothing that discusses it in VB or C#. I searched the keywords you suggested, but there’s still little that shows or explains how one might implement this in a language other than cpp. Can you perhaps elaborate or at least point to an article that has substance to it?

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          I assumed nothing - just told you what needs to be done. If you don't understand it, you can always read about it in the Platform SDK and .NET Framework SDK available at http://msdn.microsoft.com/library[^] - that's how I learned some time ago. I have a todo item for such an article on my list, but have little time to work on stuff like that - especially since this is a rather complicated solution. If you don't want to research the solution, then consider that you really don't need it - it's only for glit; not having a bitmap drag image won't impeed functionality at all.

          Microsoft MVP, Visual C# My Articles

          T 1 Reply Last reply
          0
          • H Heath Stewart

            I assumed nothing - just told you what needs to be done. If you don't understand it, you can always read about it in the Platform SDK and .NET Framework SDK available at http://msdn.microsoft.com/library[^] - that's how I learned some time ago. I have a todo item for such an article on my list, but have little time to work on stuff like that - especially since this is a rather complicated solution. If you don't want to research the solution, then consider that you really don't need it - it's only for glit; not having a bitmap drag image won't impeed functionality at all.

            Microsoft MVP, Visual C# My Articles

            T Offline
            T Offline
            TylerBrinks
            wrote on last edited by
            #5

            I've already spent 3 weeks trying to find a suitable solution, including every article I can find on the platform SDK... but, like I said, most every solution is in c++ and would be extremely difficult to port to c# or vb because of the MFC underworkings and abilities c++ has to do things like creating co-classes. The reason I'm pursuing it at this point is that the project itself is done (shy of marketing) and this is the last step. You're right, it won't impeed functionality, but I also wouldn't drive a car withouth a front windshield if I had a choice :)

            H 1 Reply Last reply
            0
            • T TylerBrinks

              I've already spent 3 weeks trying to find a suitable solution, including every article I can find on the platform SDK... but, like I said, most every solution is in c++ and would be extremely difficult to port to c# or vb because of the MFC underworkings and abilities c++ has to do things like creating co-classes. The reason I'm pursuing it at this point is that the project itself is done (shy of marketing) and this is the last step. You're right, it won't impeed functionality, but I also wouldn't drive a car withouth a front windshield if I had a choice :)

              H Offline
              H Offline
              Heath Stewart
              wrote on last edited by
              #6

              If you can't or don't want to interop and P/Invoke all that's required in C#, you're forgetting a good alternative: write a mixed-mode Managed C++ assembly and port your drag-n-drop code to that. Using a mixed-mode (as opposed to pure; the difference being what APIs you use) assembly gives you full access to unmanaged and managed APIs. What do you want me to tell you? As I said, it's a complex problem to solve and I'm a very busy person. I'll get around to an article when I can, and I haven't seen a decent one regarding this.

              Microsoft MVP, Visual C# My Articles

              T 1 Reply Last reply
              0
              • H Heath Stewart

                If you can't or don't want to interop and P/Invoke all that's required in C#, you're forgetting a good alternative: write a mixed-mode Managed C++ assembly and port your drag-n-drop code to that. Using a mixed-mode (as opposed to pure; the difference being what APIs you use) assembly gives you full access to unmanaged and managed APIs. What do you want me to tell you? As I said, it's a complex problem to solve and I'm a very busy person. I'll get around to an article when I can, and I haven't seen a decent one regarding this.

                Microsoft MVP, Visual C# My Articles

                T Offline
                T Offline
                TylerBrinks
                wrote on last edited by
                #7

                Alright - One more question then I'm putting this issue on the back burner for a while... I scoured the net last night and finally found (after translating a site from German to English) an ATL component that provides the shell dragimage support I'm looking for. The test project is in VB6 and works fine as long as the target control has its DragMode property set to Manual (1). Then I referenced the ATL dll in a new windows forms project and ported all 3 lines in VB to c# (also tried vb.net). I'm sure you'll be shocked that it didn't work. I did set the AllowDrop property of the form (also tried other controls) to true, and I also tried setting the drageffect manually in the dragenter and dragover events, and still no dice. I'm sure there's something very basic I'm missing here, and if I can get over this hurdle I'm home free. Any thoughts on the way a VB6 control handles dragging vs a .net control? Thanks!

                H 1 Reply Last reply
                0
                • T TylerBrinks

                  Alright - One more question then I'm putting this issue on the back burner for a while... I scoured the net last night and finally found (after translating a site from German to English) an ATL component that provides the shell dragimage support I'm looking for. The test project is in VB6 and works fine as long as the target control has its DragMode property set to Manual (1). Then I referenced the ATL dll in a new windows forms project and ported all 3 lines in VB to c# (also tried vb.net). I'm sure you'll be shocked that it didn't work. I did set the AllowDrop property of the form (also tried other controls) to true, and I also tried setting the drageffect manually in the dragenter and dragover events, and still no dice. I'm sure there's something very basic I'm missing here, and if I can get over this hurdle I'm home free. Any thoughts on the way a VB6 control handles dragging vs a .net control? Thanks!

                  H Offline
                  H Offline
                  Heath Stewart
                  wrote on last edited by
                  #8

                  Anything that'll work in VB6 will work in .NET (doesn't matter if you use C# or VB.NET - it all compiles to IL and you only need class library support for this, which all manages languages can access). That doesn't always mean it's as easy (since the VB VM hides the automation details). First, make sure you've registered your ATL server you found and create an interop assembly from it (using either tlbimp.exe or have VS.NET create it - it all works the same). Make sure that is referenced by your project. This is the RCW (Runtime Callable Wrapper) that you need. As far as how to use it, I really can't help you there, especially since I have no idea of what project you're talking about (a link would've helped). Finally, don't assume that types in .NET translate to types used by the ATL component. For example, the DragDropEffects may not have the same values as what the ATL component is expecting, just like the IDataObject interfaces are not the same between .NET and the Shell APIs (though they are transformed internally at a point).

                  Microsoft MVP, Visual C# My Articles

                  T 1 Reply Last reply
                  0
                  • H Heath Stewart

                    Anything that'll work in VB6 will work in .NET (doesn't matter if you use C# or VB.NET - it all compiles to IL and you only need class library support for this, which all manages languages can access). That doesn't always mean it's as easy (since the VB VM hides the automation details). First, make sure you've registered your ATL server you found and create an interop assembly from it (using either tlbimp.exe or have VS.NET create it - it all works the same). Make sure that is referenced by your project. This is the RCW (Runtime Callable Wrapper) that you need. As far as how to use it, I really can't help you there, especially since I have no idea of what project you're talking about (a link would've helped). Finally, don't assume that types in .NET translate to types used by the ATL component. For example, the DragDropEffects may not have the same values as what the ATL component is expecting, just like the IDataObject interfaces are not the same between .NET and the Shell APIs (though they are transformed internally at a point).

                    Microsoft MVP, Visual C# My Articles

                    T Offline
                    T Offline
                    TylerBrinks
                    wrote on last edited by
                    #9

                    Here's the english version: http://www.glimt.dk/code/clipx.zip Register the altBind.dll and run clipx.exe. You can drag a object from Explorer to the "Clip/Drop" button. All the VB source is included.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups