Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DrawString MDI Form
Message
From
25/01/2012 11:15:46
 
General information
Forum:
ASP.NET
Category:
Forms
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01533626
Message ID:
01533708
Views:
38
Hi Pete,

I suppose what I'm asking is, how do I know if the mouse is over my *drawn text* ?

I haven't done anything with Graphics or Drawing, so I may be totally out to lunch on this ... but it seems to me that all you have to do is check the mouse position in the mouse event handler and compare that to the location of the drawn text, given that you know x, y and s.Width and s.Height. (You could save those variable as fields or properties on your Form).

~~Bonnie



>Hi All, I draw a user defined message on a MDI Form using DrawString() in the Paint event, what I would like to do, is , if the user clicks or double clicks on the text , popup some method which enables them to specify the text, I suppose what I'm asking is, how do I know if the mouse is over my *drawn text* ? This is the code I use called from Paint() .
>
>
>void DrawMyText(Graphics g, string MyText)
>{
>    SizeF s = g.MeasureString(MyText, MyFont);
>    float x = this.Width / 2 - s.Width / 2;
>    float y = this.Height / 2 - s.Height / 2;
>    g.DrawString(MyText,MyFont,Brushes.Gold,x,y,StringFormat.GenericTypoGraphic);
>}
>
>
>This just centres the text on the form.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform