Drag and Drop Cursor Width Limit?

kriswinner

Member
Joined
Apr 23, 2009
Messages
23
Programming Experience
10+
I'm having an issue with the size of the drag and drop 'text cursor' on my application.

The code is very similar to this reference
Microsoft Visual C#: Listboxes - drag drop & reorder ,Microsoft Visual C#. - msdn.itags.org

Looking at the drawcursor sub,

VB.NET:
Sub drawcursor(ByVal text As String, ByVal fnt As Font)
Dim bmp As New Bitmap(1, 1)
Dim g As Graphics = Graphics.FromImage(bmp)
Dim sz As SizeF = g.MeasureString(text, fnt)
bmp = New Bitmap(CInt(sz.Width), CInt(sz.Height))
g = Graphics.FromImage(bmp)
g.Clear(Color.White)
g.DrawString(text, fnt, Brushes.Black, 0, 0)
g.Dispose()
textcursor = New Cursor(bmp.GetHicon)
bmp.Dispose()
End Sub

within g.DrawString the text and fnt appear to be correct, but there seems to be a limit on how wide the cursor can be. Whatever that pixel limit is, it chops the cursor down to that size if I exceed it. As long as I keep my text down to 7 characters or so, the width restriction isn't an issue.

Is there a limit set somewhere that I'm not accounting for?


Thanks.
-KW
 
I can't see any limit, not even by screen width. You're sure the text input is correct? Does the generated bitmap display ok, before converted to cursor? You said the code is similar, and not exactly the same, so your code could have other errors.
 
Good suggestion.

I've got this working in another part of the program. I just noticed that THAT text is even wider, but doesn't have the issue. There's got to be a difference.

Once I discover the difference, I'll post back so others can learn from my stupidity! :)


Thanks, JohnH.
 

Latest posts

Back
Top