CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: MousePosition

  1. #1
    Join Date
    Jan 2000
    Location
    Colorado, United States
    Posts
    12

    MousePosition

    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

  2. #2
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    hi,
    now its known as

    ( System.Windows.Forms.Control class)

    1) PointToClient
    2) PointToScreen


    you can make use of
    1) RectangleToClient
    2) RectangleToScreen



    Paresh
    - Software Architect

  3. #3
    Join Date
    Jan 2000
    Location
    Colorado, United States
    Posts
    12

    Thanks

    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.

  4. #4
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    there is no such list exist that I know off
    but you can however have a keyword comparision list

    follow MSDN
    Keyword Compairision

    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
    - Software Architect

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured