473,395 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Drag & Drop

Hi

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

thx
Nov 17 '05 #1
10 1662
Michi wrote:
Does anybody know how I can display own icons for drag & drop ?


You need to use a few Windows API functions ImageList_DragXXX 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)
Nov 17 '05 #2
wow. much code for this little thing...

thanks for the link/sample project



"Oliver Sturm" <ol****@sturmnet.org> schrieb im Newsbeitrag
news:xn****************@msnews.microsoft.com...
Michi wrote:
Does anybody know how I can display own icons for drag & drop ?


You need to use a few Windows API functions ImageList_DragXXX 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)

Nov 17 '05 #3
"Oliver Sturm" <ol****@sturmnet.org> wrote in message
news:xn****************@msnews.microsoft.com...
Does anybody know how I can display own icons for drag & drop ?


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

http://www.codeproject.com/cs/miscct...ewDragDrop.asp


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


"Michi" wrote:
wow. much code for this little thing...

thanks for the link/sample project


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.
Nov 17 '05 #5
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.
Oliver Sturm
--
Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)
Nov 17 '05 #6
"Oliver Sturm" <ol****@sturmnet.org> wrote in message
news:xn****************@msnews.microsoft.com...
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"?
Nov 17 '05 #7
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)
Nov 17 '05 #8
"Oliver Sturm" <ol****@sturmnet.org> wrote in message
news:xn****************@msnews.microsoft.com...
I don't know exactly what you're seeing with the TreeView, I don't
normally use it <snip> 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.
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:
I saw that the TreeView does in fact have this line on its WndProc:
[SecurityPermission(SecurityAction.LinkDemand,
Flags=SecurityPermissionFlag.UnmanagedCode)]


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
Nov 17 '05 #9
Danny Tuppeny wrote:
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:
I saw that the TreeView does in fact have this line on its WndProc:
[SecurityPermission(SecurityAction.LinkDemand,
Flags=SecurityPermissionFlag.UnmanagedCode)]
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?


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:
http://blogs.msdn.com/shawnfa/archiv.../14/57031.aspx

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


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)
Nov 17 '05 #10
"Oliver Sturm" <ol****@sturmnet.org> wrote in message
news:xn****************@msnews.microsoft.com...
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
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 :-)

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


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!)
:-)
Nov 17 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Karsten Schramm | last post by:
Hi, if I drag an Outlook.MailItem to a Windows-Explorer window a <subject>.msg file will be created. Now I try to drag & drop a mail item to my own WinForm app. Unfortunately it doesn't work....
0
by: Plumer | last post by:
Hello everyone, Yesterday I posted a message about implementing drag & drop in a TreeView control. I'm having real difficulty getting this to work -- the process seems to be incredibly...
2
by: Grey | last post by:
I need to design a workflow application with C#. I want to design an UI with some workflow components which they can be drag & drop anywhere in order to design the workflow for the application...
2
by: Ivo Tcholakov | last post by:
Is it possible to drag and drop controls in an aspx page at runtime ? Meaning i have developed a ASP.NET web form, the web form is now downloaded in IE - now can i have this form to detect mouse...
6
by: jojobar | last post by:
Hello, I look at the asp.net 2.0 web parts tutorial on the asp.net web site. I tried to run it under firefox browser but it did not run. If I want to use this feature in a commercial product...
3
by: Goldwind | last post by:
Hi, I"m trying to use drag & drop of text from one text box to another but without suceess. Microsoft presented an example in "101 code samples" BUT in this example the code select and drag all...
1
by: Terry Olsen | last post by:
My first time using TreeViews. I have TreeView1 set up to display my directory structure just like Windows Explorer. I can drag & drop files and folders over to TreeView2. I can re-arrange the...
3
by: VB Programmer | last post by:
In VB.NET 2005 (winform) any sample code to drag & drop items between 2 listboxes? Thanks!
5
by: sesar | last post by:
How can I impement drag&drop for simple 'dialog base' application... I want to drag&drop txt file and load the text to variable
5
by: Romulo NF | last post by:
Greetings, I´m back here to show the new version of the drag & drop table columns (original script ). I´ve found some issues with the old script, specially when trying to use 2 tables with...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.