Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Body Chart

Status
Not open for further replies.

muntz70

Programmer
Dec 5, 2003
25
US
I'm curious as to how some of you folks would handle the following challenge:

I need to create a Body Chart for a medical application. I want the user to be able to click on an image of a body where an injury occurred and have an "X" appear where the user clicked.

I need to record this in a database so that it can be reviewed and used to print the Body Chart and the location of the injury at any time.

My idea was to use a an image on a form and use the X,Y coordinates of the "onMouseUp" event to place the "X" on the image. Also recording the coordinates to the database.

Any "better" ways to accomplish this task?

Thanks
 
Sounds fine to me, so long as your base image will never change in shape or size.

Just as a word of warning though, make sure the coordinate you capture in the OnMouseUp is relative to the image, and not the form or the screen.
 
During development, it might be wise to throw a TStatusBar onto your form and output the mouse coordinates in the TImage's OnMouseDown to serve as a debugging tool.
Code:
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  StatusBar1.SimpleText := 'Clicked: ' + IntToStr(X) + ', ' + IntToStr(Y);
end;

I would use OnMouseDown rather than OnMouseUp. This is because if OnMouseUp was used the user could click down on one point, drag the mouse to another part of the image and then release and the coordinates of the point of release would be captured rather than where the user first clicked. Using OnMouseDown would avoid this problem.

As Griffyn warned, make sure you use the of the TImage and not of the form.

Clive
Runner_1Revised.gif

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top