473,386 Members | 1,775 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,386 software developers and data experts.

Drawing an Image from the cursor

I see a lot of posts about creating a cursor from an image but is it
possible to do the opposite?

We have added code to allow a text box on a statusbar to be dragged to
allow dropping an open window on another icon, grid, etc. It would be
very intuitive for the user if we could grab the default cursor and
render this as an image next to the text box.

Anyone have any ideas how this could be done?

Jul 2 '07 #1
2 2972

This should do it:

Dim cur As Cursor = Me.Cursor 'Or whichever cursor
Dim bmp As New Drawing.Bitmap(cur.Size.Width, cur.Size.Height)
Dim g As Graphics = Graphics.FromImage(bmp)
me.Cursor.Draw(g,new
Rectangle(0,0,cur.Size.Width,cur.Size.Height)
g.Dispose()
PictureBox1.Image = bmp
bmp.Dispose()
Good luck,

-Mark

Jul 2 '07 #2
On Jul 2, 12:30 pm, "mark.mil...@binaryswitch.com"
<mark.mil...@binaryswitch.comwrote:
This should do it:

Dim cur As Cursor = Me.Cursor 'Or whichever cursor
Dim bmp As New Drawing.Bitmap(cur.Size.Width, cur.Size.Height)
Dim g As Graphics = Graphics.FromImage(bmp)
me.Cursor.Draw(g,new
Rectangle(0,0,cur.Size.Width,cur.Size.Height)
g.Dispose()
PictureBox1.Image = bmp
bmp.Dispose()

Good luck,

-Mark
Mark,

Thanks very much for the input. I had to comment out the dispose of
the bitmap. That was causing a very nasty error. I ended up with this:

Dim cur As Cursor = Cursors.Default
Dim bmp As New Drawing.Bitmap(cur.Size.Width,
cur.Size.Height)
Dim g As System.Drawing.Graphics =
System.Drawing.Graphics.FromImage(bmp)
Try
Me.Cursor.Draw(g, New System.Drawing.Rectangle(0, 0,
cur.Size.Width, cur.Size.Height))
Me.ToolStripStatusLabelObjectId.Image = bmp
Finally
' bmp.Dispose()
g.Dispose()
End Try

Jul 2 '07 #3

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

Similar topics

19
by: Atif | last post by:
Hello all, In my html page I want to add an image say of 800x600. Now I want that when ever I am given two coordinates on this image say (x1, y1)=(50, 100) and (x2, y2)=(200, 300), the java script...
1
by: news.microsoft.com | last post by:
Hello group, My goal is to attach an image over another image. Top image should be transparent so the back image is visible through the top one. Bellow is a test code in VB.NET. You need to...
7
by: Toby Mathews | last post by:
Hi, In an ASP.Net application I want to convert open create a FileStream object from a System.Drawing.Image - is this possible? I create an instance of an Image object using the FromFile method,...
2
by: James Coburn's Grey Helmet Hair | last post by:
When I try to compile my GTK# app, the compiler says: jbailo@linux:~/mono> mcs buttons.cs -r gtk-sharp.dll -r glib-sharp.dll -r -o buttons.exe error CS2001: Source file 'buttons.exe' could not...
5
by: Jerry J | last post by:
I want to use the System.Drawing.Image class. According to the help file, this is an abstract base class. Because it is supposedly abstract, I created another class that inherits from it. However,...
3
by: Dave Keen | last post by:
Hi all. Hope you can help me. This should be easy but I can't make this work. In brief I am building a page of thumbnails using images held in a SQLServer 2000 database. I do this by creating...
2
by: luckyguy4ru | last post by:
Hello every body, I just joined today this forum hopping that i will get really good help here, My final project is to refashioned an artist work which is mostly pencil work, i have fake color...
1
by: Andrew | last post by:
Hello Everyone I am receiving an error in an application I am working on. The application when its done will be a Dungeons and Dragons Network game. I am having problems with the Networked...
2
by: ThatsIT.net.au | last post by:
I have this code that writes a pie chart in a asp.net page, but I want to use it in a server control. When I try I get a error on the last line "Response.OutputStream" Obviously there is no...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.