Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Line Program

Posted on 1998-09-07
5
Medium Priority
?
225 Views
Last Modified: 2010-04-30
I need to write a program that draw some blocks and them tie them together with lines. If the user moves the blocks, the lines go with them to the original point. Please, I don't want to draw lines using Windows API or graphic animation. Thank You!!!
0
Comment
Question by:dgtal
5 Comments
 
LVL 1

Expert Comment

by:kacklehorn
ID: 1433419
Good luck not using APIs!!
0
 

Expert Comment

by:DaveD072798
ID: 1433420
Try setting up Label controls with a BorderStyle=1 for your boxes. This will have an added advantage of allowing colored or transparent boxes.

In the Label_Click event, toggle it's DragMode to allow/disallow dragging it in the Form. Now you've got your movable blocks. All you need is to draw the lines.

Since there is no Paint event to trap for a Label, how about the Form_DragDrop event instead? Check if the control being dropped is a Label and redraw your line however you need to.
0
 

Author Comment

by:dgtal
ID: 1433421
The "Drag and Drop"  of boxes is not the problem here. The problem is to keep the lines following the blocks wherever they go  without having to redraw lines....thank you
0
 
LVL 2

Expert Comment

by:shchuka
ID: 1433422
There is no way to have the line following the box without redrawing the line.  Just think of it this way:  The box is located in some location and a line is drawn to that box.  Now you move the box - the line WILL NOT move along with it, since it's NOT part of the box.  Therefore you need to "delete" the old line and draw a new one.

You have to redraw the lines.
0
 
LVL 1

Accepted Solution

by:
felonius earned 100 total points
ID: 1433423
Use line controls. If you have for instance 2 boxes with a line connected to the left of the first and to the right of the second.

*****      *****
* 1 *------* 2 *
*****      *****

That means that

line.x1 = box1.left + box1.width
line.y1 = box1.top + box1.height / 2
line.x2 = box2.left
line.y2 = box2.top + box2.height / 2

Whenever the box is moved (which you seem to have fixed) and the box is released you should go through the above formulas again. If you need to generate new lines and boxes run time use control arrays.

Hope this helps. Otherwise you must descibe your problem in more detail.

felonius
0

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.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

877 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