Solved

how can I manage an image with an edit box

Posted on 1998-04-30
5
160 Views
Last Modified: 2010-04-06
Hi
1.-  I have I figure, like a circle with numbers from 0 to 360 degrees ( like a clock ).
2.-  Edit box will display the value choosed in the part 1.
so the question is how Can I do a figure that moving with the mouse I can select a number and after
number is displayed in an edit box.  
Any help for this,
Thanks
Guerra
0
Comment
Question by:guerra
  • 3
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
peter_vc earned 10 total points
ID: 1339812
The trick here is to use the OnMouseMove event.
Using the centre point of the image and simple trig, you can determine the angle of the imaginary line that connects the centre of the image to the current mouse position.  In the OnClick event, you set the contents of the edit box to the calculated angle.
0
 

Author Comment

by:guerra
ID: 1339813
Hi Peter-vc
I droped an image I don't know  what to do next,
if you've got some examples, can I have a look?
Thanks
Guerra
0
 
LVL 1

Expert Comment

by:peter_vc
ID: 1339814
Here is 15 points worth of examples.


unit Unit1;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Image1: TImage;
    Edit1: TEdit;
    procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Image1DblClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Y_Coord : Integer;
  X_Coord : Integer;
  Image_Centre_X : Double;
  Image_Centre_Y : Double;

implementation

{$R *.DFM}

procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
     X_Coord := X;
     Y_Coord := Y;
end;

procedure TForm1.Image1DblClick(Sender: TObject);
var
   TheAngle : Double;
begin
     { Calculate angle here using X & Y_Coord, Image_Centre_X & Y }
     { For now just show Y_Coord }

     TheAngle := Y_Coord;

     { display it }
     Edit1.Text := FloatToStr(TheAngle);

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
     Image_Centre_X := Image1.Width;
     Image_Centre_X := Image_Centre_X / 2;

     Image_Centre_Y := Image1.Height ;
     Image_Centre_Y := Image_Centre_Y / 2;
end;

end.

0
 

Author Comment

by:guerra
ID: 1339815
hi Peter
Thanks for the help, it is working, but could tell me how can i define the centre of the image, because the image takes the values from 0 at the top, the same for the width.
Thanks
guerra
0
 
LVL 1

Expert Comment

by:peter_vc
ID: 1339816
Look at the code (FormCreate event).  The centre is half the width and half the height.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

803 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