Solved

how can I manage an image with an edit box

Posted on 1998-04-30
5
177 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

696 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