• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 404
  • Last Modified:

How to write code in MFC to show that label of a circle can move with the moving of the circle?

On a map, I created a circle zone with a label, ex. Zone 1, and set the lable to be visible in my MFC code. There is a feature for this circle that it can be moved to anywhere on the map. But the problem is that the label with the circle does not move with the circle.
0
yangfang_mun
Asked:
yangfang_mun
  • 2
1 Solution
 
cookreCommented:
You know the coordinates of the circle before and after the move.  That gives you a delta-x and delta-y you can apply to the .Top and .Left of the label.
0
 
cookreCommented:
Note that if the circle is moved to a position such that the label goes off the visible part of the window, you may want to add some code to adjust the label's position so that it stays visible.  It's a bit of busy-work code, but quite user friendly.

It would be something like this:
deltaX - circle's horizontal change
deltaY - circle's vertical change

if ((label.left+deltax)<0) label.left=0;
if ((label.left+label.width+deltax)>window.width) label.left=window.width-label.width;
if ((label.top+deltay)<0) label.top=0;
if ((label.top+label.height+deltay)>window.height) label.top=window.height-label.height;
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now