Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / July 2007

Tip: Looking for answers? Try searching our database.

Drawing an Image from the cursor

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tom C - 02 Jul 2007 18:00 GMT
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?
mark.milley@binaryswitch.com - 02 Jul 2007 18:30 GMT
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
Tom C - 02 Jul 2007 19:17 GMT
On Jul 2, 12:30 pm, "mark.mil...@binaryswitch.com"
<mark.mil...@binaryswitch.com> wrote:
> This should do it:
>
[quoted text clipped - 10 lines]
>
> -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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.