Drag & Drop

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michi

    Drag & Drop

    Hi

    Does anybody know how I can display own icons for drag & drop ?

    thx


  • Oliver Sturm

    #2
    Re: Drag & Drop

    Michi wrote:
    [color=blue]
    >Does anybody know how I can display own icons for drag & drop ?[/color]

    You need to use a few Windows API functions ImageList_DragX XX to do this.
    There's a sample that shows how to do this here:




    Oliver Sturm
    --
    Expert programming and consulting services available
    See http://www.sturmnet.org (try /blog as well)

    Comment

    • Michi

      #3
      Re: Drag & Drop

      wow. much code for this little thing...

      thanks for the link/sample project







      "Oliver Sturm" <oliver@sturmne t.org> schrieb im Newsbeitrag
      news:xn0e7tfsbb aee6p001@msnews .microsoft.com. ..[color=blue]
      > Michi wrote:
      >[color=green]
      >>Does anybody know how I can display own icons for drag & drop ?[/color]
      >
      > You need to use a few Windows API functions ImageList_DragX XX to do this.
      > There's a sample that shows how to do this here:
      >
      > http://www.codeproject.com/cs/miscct...ewDragDrop.asp
      >
      >
      > Oliver Sturm
      > --
      > Expert programming and consulting services available
      > See http://www.sturmnet.org (try /blog as well)[/color]


      Comment

      • Danny Tuppeny

        #4
        Re: Drag &amp; Drop

        "Oliver Sturm" <oliver@sturmne t.org> wrote in message
        news:xn0e7tfsbb aee6p001@msnews .microsoft.com. ..[color=blue][color=green]
        >>Does anybody know how I can display own icons for drag & drop ?[/color]
        >
        > You need to use a few Windows API functions ImageList_DragX XX to do this.
        > There's a sample that shows how to do this here:
        >
        > http://www.codeproject.com/cs/miscct...ewDragDrop.asp[/color]

        Does this mean it can't be done with no/low-trust apps like those run via
        ClickOnce? :(


        Comment

        • Dan Neely

          #5
          Re: Drag &amp; Drop



          "Michi" wrote:
          [color=blue]
          > wow. much code for this little thing...
          >
          > thanks for the link/sample project[/color]

          The raw win32api is much more verbose than the .net wrappers written around
          it. Whenever you need something not provided by the wrappers you have to do
          it the old way, which as you saw requires much more userwritten code. The
          ..net classes do all of that too, it's just behind the scenes for you.

          Comment

          • Oliver Sturm

            #6
            Re: Drag &amp; Drop

            Danny Tuppeny wrote:
            [color=blue]
            >Does this mean it can't be done with no/low-trust apps like those run via
            >ClickOnce? :([/color]

            As soon as you don't have permissions to do interop, you're out of luck.


            Oliver Sturm
            --
            Expert programming and consulting services available
            See http://www.sturmnet.org (try /blog as well)

            Comment

            • Danny Tuppeny

              #7
              Re: Drag &amp; Drop

              "Oliver Sturm" <oliver@sturmne t.org> wrote in message
              news:xn0e7tkjzb gvd91003@msnews .microsoft.com. ..[color=blue][color=green]
              >>Does this mean it can't be done with no/low-trust apps like those run via
              >>ClickOnce? :([/color]
              >
              > As soon as you don't have permissions to do interop, you're out of luck.[/color]

              Doh!

              I understand that some MS controls (like the treeview) work like this
              anyway - is this just a case of "if microsoft wraps it, it doesn't need
              interop permission"?


              Comment

              • Oliver Sturm

                #8
                Re: Drag &amp; Drop

                Danny Tuppeny wrote:
                [color=blue][color=green][color=darkred]
                >>>Does this mean it can't be done with no/low-trust apps like those run via
                >>>ClickOnce? :([/color]
                >>
                >>As soon as you don't have permissions to do interop, you're out of luck.[/color]
                >
                >Doh!
                >
                >I understand that some MS controls (like the treeview) work like this
                >anyway - is this just a case of "if microsoft wraps it, it doesn't need
                >interop permission"?[/color]

                I don't know exactly what you're seeing with the TreeView, I don't
                normally use it. I just had a quick look and I saw that the TreeView does
                in fact have this line on its WndProc:

                [SecurityPermiss ion(SecurityAct ion.LinkDemand, Flags=SecurityP ermissionFlag.U nmanagedCode)]

                This is .NET 2, so it might have been changed from earlier versions - but
                I would think the TreeView couldn't possibly work in an environment where
                the UnmanagedCode permission is not granted.

                Now, once the TreeView can actually be used, it's a common control - so
                the code that calls into the imagelist APIs could be outside of the parts
                we can see in .NET code. And this code would no longer be caught by the
                ..NET interop layer, either.

                Finally, for the interop thing there's a special attribute called
                SuppressUnmanag edCodeSecurityA ttribute - guess what that one does... look
                here (MSDN) for a discussion: http://shrinkster.com/8cx

                And then, even more finally, nobody would keep you from implementing
                similar functionality yourself, without using the imagelist API. This
                would probably be a bit difficult as soon as you want the drag images to
                be displayed while data is being dragged between controls (as opposed to
                only above one control) - just the reason why MS chose to implement this
                stuff in as unlikely a place as the imagelist API.


                Oliver Sturm
                --
                Expert programming and consulting services available
                See http://www.sturmnet.org (try /blog as well)

                Comment

                • Danny Tuppeny

                  #9
                  Re: Drag &amp; Drop

                  "Oliver Sturm" <oliver@sturmne t.org> wrote in message
                  news:xn0e7ttsib tdm3c004@msnews .microsoft.com. ..[color=blue]
                  > I don't know exactly what you're seeing with the TreeView, I don't
                  > normally use it[/color]
                  <snip>[color=blue]
                  > This is .NET 2, so it might have been changed from earlier versions - but
                  > I would think the TreeView couldn't possibly work in an environment where
                  > the UnmanagedCode permission is not granted.[/color]

                  That's what I thought, but not for the reason you gave. My original question
                  is answered on the page you posted, I understand the security a lot more.
                  However, you said:
                  [color=blue]
                  > I saw that the TreeView does in fact have this line on its WndProc:
                  > [SecurityPermiss ion(SecurityAct ion.LinkDemand,
                  > Flags=SecurityP ermissionFlag.U nmanagedCode)][/color]

                  Now that confused me. For two reasons... One, I don't understand why it's
                  needed - surely the treeview is pretty safe?! Two - does this mean my
                  planned ClickOnce application can't use the TreeView?

                  Where did you get that info from? Is it based on the beta2 and could it
                  change? Or was it from msdn? :(

                  Danny


                  Comment

                  • Oliver Sturm

                    #10
                    Re: Drag &amp; Drop

                    Danny Tuppeny wrote:
                    [color=blue]
                    >That's what I thought, but not for the reason you gave. My original
                    >question is answered on the page you posted, I understand the security a
                    >lot more. However, you said:
                    >[color=green]
                    >>I saw that the TreeView does in fact have this line on its WndProc:
                    >>[SecurityPermiss ion(SecurityAct ion.LinkDemand,
                    >>Flags=Securit yPermissionFlag .UnmanagedCode)][/color]
                    >
                    >Now that confused me. For two reasons... One, I don't understand why it's
                    >needed - surely the treeview is pretty safe?! Two - does this mean my
                    >planned ClickOnce application can't use the TreeView?[/color]

                    Probably the TreeView is pretty safe, but apparently they didn't see this
                    as a valid reason to work around .NET code security - which I generally
                    find a good thing.

                    I haven't tried this and I also haven't used ClickOnce, apart from a
                    cursory test. But I think you can actually run ClickOnce applications that
                    require all kinds of permissions client side; what I meant was you'll have
                    to make sure you have these permissions because the TreeView certainly
                    seems to require them. To acquire the needed permissions, you'll need to
                    use a feature called "permission elevation". Here's a blog article with a
                    quick explanation:


                    But you can also find a lot of other docs, also on MSDN, by googling for
                    "permission elevation".
                    [color=blue]
                    >Where did you get that info from? Is it based on the beta2 and could it
                    >change? Or was it from msdn? :([/color]

                    This information is based on beta 2 and I got it by looking at the sources
                    for the TreeView with Reflector.



                    Oliver Sturm
                    --
                    Expert programming and consulting services available
                    See http://www.sturmnet.org (try /blog as well)

                    Comment

                    • Danny Tuppeny

                      #11
                      Re: Drag &amp; Drop

                      "Oliver Sturm" <oliver@sturmne t.org> wrote in message
                      news:xn0e7utsfc p0xu2005@msnews .microsoft.com. ..[color=blue]
                      > But I think you can actually run ClickOnce applications that require all
                      > kinds of permissions client side; what I meant was you'll have to make
                      > sure you have these permissions because the TreeView certainly seems to
                      > require them. To acquire the needed permissions, you'll need to use a
                      > feature called "permission elevation". Here's a blog article with a quick
                      > explanation: http://blogs.msdn.com/shawnfa/archiv.../14/57031.aspx[/color]

                      That's right, but your user would get a box (I hope) saying something like
                      "this app wants to do something dangerous. Please click no" if I want access
                      for unmanaged code. The ActiveX dialog doesn't seem to put people off, so
                      I'm hoping with ClickOnce it's a bit more obvious just what you're giving
                      permission for!

                      Besides, even if I *can* get it, I don't want a user to have to give my app
                      access to do "anything" just for a treeview :-(

                      Anyways, I'll wait for the final release, and try it :-)

                      [color=blue]
                      > This information is based on beta 2 and I got it by looking at the sources
                      > for the TreeView with Reflector.[/color]

                      Excellent - I was sure there was something out there, but I googled and
                      couldn't find it! Reflector it is! (duh, how obvious is that!)
                      :-)


                      Comment

                      Working...