tedunni
asked on
Workaround to maximum size for Custom Cursors
Earlier I asked a question about having a circle tool follow the mouse around. I was drawing the circle over the mouse and Idle_Mind gave a great suggestion (his solution is in the code snippet below) of using a Custom Cursor. However, when I try to use a radius of say 48, it only draws part of the circle, and not the entire circle. It seems that there is a maximum size for custom cursors and I was wondering how to get around that issue. Additionally when I try to draw a very large circle (With a radius of say 576), I get a generic occurred in GDI+.
However, the bottom line is that I would like to have a circle tool follow the mouse and there is a possibility that this circle tool might get fairly large.
Thanks.
However, the bottom line is that I would like to have a circle tool follow the mouse and there is a possibility that this circle tool might get fairly large.
Thanks.
Public Class Form1
Private radius As Integer = 20
Private startAngle As Integer = 0
Private sweepAngle As Integer = 360
Private currentColor As Color = Color.Red
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CreateCursor()
End Sub
Private Sub CreateCursor()
Dim bmp As New Bitmap(radius * 2, radius * 2)
Dim g As Graphics = Graphics.FromImage(bmp)
Dim myPen As New Pen(currentColor, 1)
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias
g.DrawArc(myPen, 0, 0, bmp.Width - 1, bmp.Height - 1, startAngle, sweepAngle)
g.Dispose()
myPen.Dispose()
Dim C As New Cursor(bmp.GetHicon)
Me.Cursor = C
End Sub
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER