Moving Character Glyphs
-
Hello Everyone: I have an interesting problem. I modified a C# application written by Bob Powell that demonstrated how to move graphic primitives to Visual Basic 2005 .NET. I want to take this a step further and be able to move alphanumeric characters around on the screen using the mouse. My problem is I can draw a series of characters using the DrawPath method, but when I point to a specific character to hit test it the application’s HitTest Function does not recognize the character. I’m guessing the problem lies in the class I created for the text, but I don’t know how to solve the problem. I wrote to Bob Powell and he suggested using glyphs. I’m assuming he wanted me to take the fonts and convert them to glyphs. This is where I get confused; a font is just a glyph. It seems redundant to create a glyph out of a glyph. A single font character has a height and a width. The hit test function returns those values and uses them to create a rectangle around the graphic primitive I’m pointing too. Once the primitive is highlighted I can move it elsewhere on the screen by holding down the left mouse button and move the mouse to another position on the screen dragging the highlighted primitive with it. Does anyone have any ideas? Quecumber256
-
Hello Everyone: I have an interesting problem. I modified a C# application written by Bob Powell that demonstrated how to move graphic primitives to Visual Basic 2005 .NET. I want to take this a step further and be able to move alphanumeric characters around on the screen using the mouse. My problem is I can draw a series of characters using the DrawPath method, but when I point to a specific character to hit test it the application’s HitTest Function does not recognize the character. I’m guessing the problem lies in the class I created for the text, but I don’t know how to solve the problem. I wrote to Bob Powell and he suggested using glyphs. I’m assuming he wanted me to take the fonts and convert them to glyphs. This is where I get confused; a font is just a glyph. It seems redundant to create a glyph out of a glyph. A single font character has a height and a width. The hit test function returns those values and uses them to create a rectangle around the graphic primitive I’m pointing too. Once the primitive is highlighted I can move it elsewhere on the screen by holding down the left mouse button and move the mouse to another position on the screen dragging the highlighted primitive with it. Does anyone have any ideas? Quecumber256
I assuming the hit test fails because you can't click exactly on the drawn part of the character and not the white space inside it. You're, basically, trying to click on a very thin line and missing. I hope anyway... I have no idea if this solution would work for you, but you already know how to click and move a graphic image, so draw the text onto a small bitmap and left the user click and drag the bitmap around.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
I assuming the hit test fails because you can't click exactly on the drawn part of the character and not the white space inside it. You're, basically, trying to click on a very thin line and missing. I hope anyway... I have no idea if this solution would work for you, but you already know how to click and move a graphic image, so draw the text onto a small bitmap and left the user click and drag the bitmap around.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008Hi Dave: Thanks for the input. The experiment I'm running uses a 50 point font, which in turn produces an image large enough to know you are clicking on the character itself. The bitmap approch did occur to me as a possible solution, but considering the work involved producing 255 bitmaps, one for each ANSI character it didn't seem like it would be practical. Obviously there is a fundimental difference between shapes drawn using GDI+ and how GDI+ handles fonts. There has got to be some method out there that will allow me to capture the font, but so far my searches have produced ziltch. Quecumber256