How to reset Mouse Postion in Visual C++ 6

Posted on 2007-10-12
Last Modified: 2013-11-20
Hi expert!
 In my project I have  to draw Polygons. I laid out them in a StaticText. and my problem is how to prevent mouse from moving out the Static Text if a polygon isn't drawn completely. (in order to draw a polygon.I choose several Point and  drawing polygon is complete if the last  point  coincide the firstpoint).
Thanks for help
Question by:trung85gn
    LVL 4

    Expert Comment

    You want to set the mouse capture, so that you can get mouse messages from all windows in the system. Then, in your message processing function, you want to check the coordinates of the mouse, and if it isn't within your predetermined region, you can set the mouse position back to the region. This has the effect of keeping the mouse within your region, similar to how maximum window size is implemented.

    More information on mouse capture:
    LVL 4

    Accepted Solution

    An easier solution than my previous comment:

    CRect myRect;

    Of course, you can get the Rect of any control, and then use that for clipping the mouse as well.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
    What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
    The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
    The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

    737 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

    17 Experts available now in Live!

    Get 1:1 Help Now