Click to See Complete Forum and Search --> : MousePosition


Brian Lasota
March 14th, 2003, 10:52 AM
I have a control where I get the MousePosition and want to see if a part of my control is at that position. The MousePosition is in screen coordinates and my control is based on the client coordinates.

In VC++ I would simply call ScreenToClient or ClientToScreen depending on the direction you want to go. Is there any ScreenToClient equivelants in C#. Or does anyone know the logic invloved with calculating that?

Thank you,

Brian

pareshgh
March 14th, 2003, 11:10 AM
hi,
now its known as ;)

( System.Windows.Forms.Control class)

1) PointToClient
2) PointToScreen


you can make use of
1) RectangleToClient
2) RectangleToScreen
:D


Paresh

Brian Lasota
March 14th, 2003, 11:25 AM
I wish there was a list where each VC++ function was listed with it's equivelant(s) in C#, or at least if I type ScreenToClient in the C# help it should find the PointToClient. Would be nce anyways.

Perhaps you can answer another question...

I have a Graphics object where I do a MeasureString passing in a string and StringFormat. The MeasureString passes back the size of the text. At that point I create my rectangle to do the drawing with a 2 pixel padding added to each side. I then do a DrawString to draw the text in the rectangle.

I was wondering if there was anyway to tell where exacly the X and Y starting point of where the text was drawn. For example if my StringFormat indicated center text, then the text would not start and the left or right of the padding but rather somewhere in the middle. I could problably compute this, but it would be nice to have something like the MeasureString to tell me where the DrawString is going to place the text.

pareshgh
March 14th, 2003, 11:35 AM
there is no such list exist that I know off
but you can however have a keyword comparision list

follow MSDN
Keyword Compairision (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxorilanguageequivalentskeywords.asp)

the stuff that you are doing really matters of x,y pixel relative to the control that you are doing on.

for example you have paint of form then x,y is of that and so on

Paresh