Cursor position Error

Posted on 2008-11-05
Last Modified: 2013-12-17
I have have developed an application which is working fine in my laptop (which has a wide-screen 15.4 in)
and I have taken this application to another PC (which has a 17 in screen)
now I have user-friendly button which is working in my laptop but not in PC .. what I am doing is that there is a picture box control changing it's image depending on the cursor position that I put it in my code ..
now is there any or equation that I can do to avoid changing the absolute position values ?
here is a code sample:
private void WindowStatePicBox_MouseMove(object sender, MouseEventArgs e) 


            if (!isPressed)


                if (((Cursor.Position.X >= 933) && (Cursor.Position.X <= 975)) && (Cursor.Position.Y <= 139))

                    WindowStatePicBox.Cursor.Image = global::FRSystem.Properties.Resources._2;

                if (((Cursor.Position.X >= 908) && (Cursor.Position.X < 933)) && (Cursor.Position.Y <= 139))

                    WindowStatePicBox.Image = global::FRSystem.Properties.Resources._3;

                if (((Cursor.Position.X < 908) || (Cursor.Position.X > 975)))

                    WindowStatePicBox.Image = global::FRSystem.Properties.Resources._1;

                if(Cursor.Position.Y > 139)

                    WindowStatePicBox.Image = global::FRSystem.Properties.Resources._1;



Open in new window

Question by:Ameerh24
    LVL 1

    Expert Comment

    I think that MouseEventArgs contains mouse location on form, so you can combine that with picture box location and size on form in order to achieve desired behavior. All those values are relative to form and not to screen. This way you don't need to use mouse absolute position.
    LVL 8

    Accepted Solution

    you should be using e.Location not cursor position.  The mouse eventargs contains the location of the mouse in respect to your form and controls.  when using Cursor.Position you need to use your control and call PointToClient with the position.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Suggested Solutions

    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now