Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DrawString MDI Form
Message
De
25/01/2012 11:15:46
 
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
01533626
Message ID:
01533708
Vues:
36
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform