Solved

how can I manage an image with an edit box

Posted on 1998-04-30
5
169 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

713 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