Solved

Moving Objects with a Mouse

Posted on 1998-06-18
3
193 Views
Last Modified: 2013-11-20
I have made some menu selections that when chosen an object such as a rectangle or circle appear on the view screen for the user.  I want the user to be able to select an object on the screen and then move it around.  I am currently trying to do this by checking if an object is in a rectangular region located at the cursor when the user clicks the left mouse button.  If it is then I change the location of the object based on the cursor's location as the user moves it.  However, I have not been successful in checking to see if the object is in the cursor location (when the user is trying to grab the object).  I know how to move the object.  I just can't grab it.  

Some info (code preferable) on how to check whether the cursor is pointing to an object on the screen when the user is trying to grab the object is what I need.
0
Comment
Question by:scs1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Expert Comment

by:TAMC
ID: 1318161
If you have the dimensions of the rectangle you can use the function CRect function PtInRect to see whether or not the cursor lies inside your rectangle, if you have odd shapes like ellipses or such use the CRgn function PtInRegion, if you need to know more, just comment.
0
 

Author Comment

by:scs1
ID: 1318162
Thanks for the help.  During the short time that I was waiting for the answer, I figured out what I needed (at least for now).
0
 
LVL 1

Accepted Solution

by:
amby earned 50 total points
ID: 1318163
You can create a Region....

in this case, your region seems to be quite simple, it is a round or a rect... but it is not much more difficult to use a Microsoft-called 'Complex' region, you can build such a region by combination... (use mfc's CRgn or API CreateRectRgn, ... and CombineRgn)

after that, a very interesting function in this case is PtInRegion...

mor interesting yet:
you offset the region to the (x-y) coords of your objects, and you simply call CDC::SelectClipRgn (region here is supposed to be a perfect calc of your object) then if your object is monochrome, use CDC::FillSolidRect... much faster than redrawing a complex object... (in this case, you just have to CDC::SelectClipRgn(NULL) to set the clipping region back to the standard one, = the window...

this should be good for you
(never forget to OffsetRgn to set the region coords same as your object coords...)


0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
lucky13 challenge 11 167
post4 challenge 28 122
Annoying "thing" blocks my view 4 146
how to use laptop or pad camera in vb.net windows application 2 131
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

739 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