How to make, that after entering the data of coordinates (x, y) in the first window in the second window, a vector is drawn according to these coordinates? That is, the question is how to connect the events of the first form with the second?
- Coordinate (0, 0) in the center of the form cannot be. I would do this: create a control point in the center of the form (X0: = Form1.ClientWidth, Y0: = Form1.ClientHeight), and calculate the current value of X and Y based on these points. For example: X: = X0 + dx, where dx is the value of x that the user entered; and Y: = Y0-dy, if dy is negative, then Y will become more, that is, lower, and less with positive dx. If not clearly explained - E-Mail in profile. - DelphiM0ZG
|
1 answer
To do it the way it is done in the case of one form, but by addressing the necessary form in the code. For the event of both components Edit OnChange of the first form, set the second drawing (if you draw a graph on the form - Form2.Repaint), and in the event of the second OnPaint form, take the coordinates from the first one like this:
X:=StrToInt(Form1.EditX.Text); Y:=StrToInt(Form1.EditY.Text);
and then draw on the form. It is necessary to connect both forms to each other using File -> Use Unit ... , and from the list select Form1 Unit2, and vice versa.
- thanks, figured out) and another question: how to make the coordinate (0,0) be in the center of the form? - tkoff
- It is better to draw not on the form, but on the
Image
(like so called). Then the image will not be "erased" by other windows. - andrybak - On Image, of course, it is better to draw. Although, when drawing on a form (or in PaintBox) in the OnPaint event, all the drawing is done, it will be redrawn when the image is erased by other windows. - DelphiM0ZG
|