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

Posted on 2005-05-04
Last Modified: 2006-11-18
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.
Question by:yangfang_mun
    LVL 23

    Expert Comment

    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.
    LVL 23

    Accepted Solution

    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 ((<0);
    if ((>window.height);

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    tripleUp challenge 7 54
    NotAlone Challenge 20 65
    sumHeights  challenge 17 50
    Enhanced For loop vs ForEach Loop 4 42
    Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
    This is about my first experience with programming Arduino.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    729 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

    18 Experts available now in Live!

    Get 1:1 Help Now