Solved

how can I manage an image with an edit box

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now