Danny Tuppeny wrote:
Does this mean it can't be done with no/low-trust apps like those run via
ClickOnce? :(
As soon as you don't have permissions to do interop, you're out of luck.
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"?
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:
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.UnmanagedCode)]
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
SuppressUnmanagedCodeSecurityAttribute - 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)