Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 237
  • Last Modified:

How to draw a line just below to the main line in VC++

I want to draw a line in the MDI application of the MFC(VC++).
On each OnLButtonDown(UINT nFlags, CPoint point), i'll get the point & those points i'll save it in the CArray<CPoint,CPoint> member variable.
OnLButtonDblClk(UINT nFlags, CPoint point) by using for loop i'll draw the line based on the CArray<CPoint,CPoint> member variable.
As soon as line will be visible on the view. I want  another line just below to the main line. I've to calculate the points for this another line based on the Main line stored point. How should i do that.
If you have any solution for this please let me know.
With Regards
Kapil
0
kdtyagi
Asked:
kdtyagi
  • 7
  • 5
1 Solution
 
AndyAinscowFreelance programmer / ConsultantCommented:
Main line - x1y1, x2y2, x3y3 ...
To draw
MoveTo(x1, y1);  LineTo(x2, y2); LineTo(x3, y3); ...

Now for your second line. set an offset variable to the offset required
int Offset = 5;

MoveTo(x1, y1+Offset); LineTo(x2, y2+Offset); LineTo(x3, y3+Offset); ...
0
 
kdtyagiAuthor Commented:
For Digital waveform it doesn't work.
With Regards
Kapil
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
How can it NOT work?
Maybe you should rephrase your question
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

 
kdtyagiAuthor Commented:
Sorry may be my question is not correct. I want to draw a line just replication of the original one. In this scenario the replicate of digital waveform (just below) to the original one, horizontal line won't be having any problem but the vertical will have the problem.

According to the your code it gives the shadow look, instead of shadow look i want a line just beside to the main line. The same shape should appear.
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
try
int Offset = 10;   //or 20 instead of 5
0
 
kdtyagiAuthor Commented:
If you will give me your email id i can send you the bitmap so that you will get the clear picture.
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
info@ainscow.ch
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
Oh dear.
The line isn't just below the original.  In places it is also offset horizontally.

Roughly you need to do the following.
Find the joints (horizontal to vertical direction change or vice versa)
Based on the joints create a second array where the points are moved by both a horizontal AND vertical offset.  The direction of the horizontal offset is dependant on the direction of the line change.
Then draw the line defined by these second points.

I don't have any code for this.  It sounds complex but in reality it's just messy to code.
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
I believe I have told him what he needs to do o accomplish the task.
0
 
kdtyagiAuthor Commented:
No one gave me the answer so please close this answer i'll solve myself.
With Regards
Kapil
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
The logic he requires is what my final comment supplies.
0
 
kdtyagiAuthor Commented:
To Administrative,
How to delete the question.
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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