473,324 Members | 2,002 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,324 software developers and data experts.

Drag Bitmap tutorial/code anywhere?

Hi,

Can anyone point me towards a good drag/drop tutorial that allows me to
create/render my own drag-cursor (i.e. for instance, if I wish to drag a
list item, I can render the list item at the cursor location as the user
drags it around the screen). Has anyone successfully done this in VB.NET?
How does it perform? Any pitfalls?

Thanks,

Robin
Oct 5 '06 #1
2 3185
Hi this sample shows how to create a cutsom cursor, haven't tested it with
dragging and dropping.

Dim myCur As Cursor()
Dim g As Graphics
Dim cur As Cursor

g = TextBox1.CreateGraphics
Dim myBmp As New Bitmap(CInt(g.MeasureString(TextBox1.Text,
TextBox1.Font).Width), 20)
g = Graphics.FromImage(myBmp)
g.Clear(Color.Red)
g.DrawString(TextBox1.Text, TextBox1.Font, Brushes.White, 2, 2)
g.Dispose()
Dim ptrCur As IntPtr = myBmp.GetHicon
cur = New Cursor(ptrCur)
Cursor.Current = cur

hope this helps,

Greetz, Peter
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"Robinson" <to******************@myinboxtoomuchtoooften.comsc hreef in
bericht news:eg*******************@news.demon.co.uk...
Hi,

Can anyone point me towards a good drag/drop tutorial that allows me to
create/render my own drag-cursor (i.e. for instance, if I wish to drag a
list item, I can render the list item at the cursor location as the user
drags it around the screen). Has anyone successfully done this in VB.NET?
How does it perform? Any pitfalls?

Thanks,

Robin


Oct 5 '06 #2

"Peter Proost" <pp*****@nospam.hotmail.comwrote in message
news:OA*************@TK2MSFTNGP05.phx.gbl...
Hi this sample shows how to create a cutsom cursor, haven't tested it with
dragging and dropping.

Dim myCur As Cursor()
Dim g As Graphics
Dim cur As Cursor

g = TextBox1.CreateGraphics
Dim myBmp As New Bitmap(CInt(g.MeasureString(TextBox1.Text,
TextBox1.Font).Width), 20)
g = Graphics.FromImage(myBmp)
g.Clear(Color.Red)
g.DrawString(TextBox1.Text, TextBox1.Font, Brushes.White, 2, 2)
g.Dispose()
Dim ptrCur As IntPtr = myBmp.GetHicon
cur = New Cursor(ptrCur)
Cursor.Current = cur

hope this helps,

Greetz, Peter
--
Thanks for that Peter. I also found some samples like this one:
http://www.planet-source-code.com/vb...3855&lngWId=10.
I'm going to give it a try this afternoon.

Robin
Oct 6 '06 #3

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

Similar topics

0
by: Frank Rizzo | last post by:
I have an app where users can drag and drop a file onto the app. I catch the event and do processing based on the dropped file. Sometimes the processing takes long time. For some reason, the...
5
by: Clyde | last post by:
I am trying to implement the user feedback provided by Windows Explorer when draggng a filename from one place to another. I have the drag and drop action worked out but have had no luck in...
1
by: | last post by:
I put two picture boxes on my main form. I was not able to drag and drop on any of them. Also, the AllowDrop property is not available at design time for the picture box. Any advice on an easy...
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...
6
by: Alfonso2968 | last post by:
Hello, If someone can help plz. I have searched everything and all I can find is how to drag and drop within a form from panel to panel. What I need to do is Drag an image from the desktop...
0
by: Truevision .Net | last post by:
Hi, I have a problem with drag and drop functionality when it comes to dropping pictures from sources like for example internet explorer and the webbrowser control. Dragging and dropping from...
1
by: sCryptKeeper | last post by:
I'm trying to change the cursor while a drag and drop occurs between two lists in a winforms. I tried several ways (several tutorial and solutions) found over the web. I even tried to simply...
1
by: Eric von Horst | last post by:
Hi, I need some advice on Drag&Drop. What I want to achieve is the following: - I have a window that is divided in two : on the left hand I have a wx.TreeCtlr and on the other hand a...
1
by: ashwinigopi | last post by:
Hi I am trying to drag and drop image to a picture box in the form. I using this code but doesnt seem to work. Here is the code, private void Form1_DragEnter(object sender, DragEventArgs e) ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.