Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MFC app that draw a circle & rectangle object (resizable,movable)

Posted on 2004-10-20
5
Medium Priority
?
2,126 Views
Last Modified: 2013-11-20
Hi,
I need to write an mfc application that by pushing a button draws a circle object and by pushing another button draws a rectangle object. I need those objects to be movable and resizable by mouse. I am using Visual C++ 6.0.

I am almost an expert in java and therefore I do understand programming well but I am just beggining to learn Vis.C++. So far:
- I have created an mfc app using the wizard.
- I created my own toolbar with the 2 required buttons.

Do the circle and rectangle I need exist as ready-to-use classes derived from CObject ?
If yes, whats their name and how do i call them?
Do I have to design them manually using Brush or sth and then programm manually the controls that will resize and/or move them?

Thanks in advance..

0
Comment
Question by:Invader
[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
5 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 750 total points
ID: 12360313
I think you are refering to vectorial objects, if so, there are not MFC objects ready made for this.

You can paint rectangles and circles with WinAPI's Rectangle() and Ellipse() functions, but you can't interactivelly make them resizable by mouse because just paint in bitmap fashion on the screen.

Have a look to this great example about implementing vectorial graphics with MFC:
http://www.codeproject.com/miscctrl/diagrameditor.asp

Good luck,
Jaime.
0
 
LVL 6

Expert Comment

by:Amritpal Singh
ID: 12366754
a simpler example at the following link

http://www.thecodeproject.com/cs/miscctrl/tracker.asp
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 12367196
Check out MFC sample DRAWCLI.
0
 
LVL 2

Expert Comment

by:Ruskialt
ID: 12372613
There is alot to this. First you need to hit test the drawn object (circle and rectangle is easy enough, ofcause..). Then if you hit something, you may want a "manipulator", a square around the now selected object.

You can make you own manipulator square deriving from CFrameWnd, and draw its client area yourself. The client area is the frame borders and the title areas of a window. In your case you would need to draw this as a single pixel wide rectangle.

You also want to write the NcHitTest function, to return to the system what border was hit.

Then when your manipulator window changes size or position, you can redraw the circle/rectangle the new place. Delete the manipulator and create a new one if another object in the drawing is hit.

I have such a system running, but I won't post more info if it's not interesting for you, please let me know :-)
0
 
LVL 2

Expert Comment

by:Ruskialt
ID: 12378314
Ooops, took a quick look at my code - I used CWnd, not CFrameWnd..
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

704 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