Link to home
Start Free TrialLog in
Avatar of tirbanqs
tirbanqsFlag for Philippines

asked on

Delphi paintbox

Hi  guys

I'm making a line graph application using delphi. I draw a line and ellipse in the paintbox. My question is how can i identify if the mouse over is in the ellipse. I want to show a hint and the text is not fix. Meaning every ellipse has a different hint text. I place the record in a list. So it would be best if an id would also included in the ellipse. Is this possible?

Hope you guys get it.
Avatar of kretzschmar
kretzschmar
Flag of Germany image

maybe

instead of drawing place TShapes

just as an idea

meikl ;-)

Avatar of tirbanqs

ASKER

nice idea.
is it ok if i have plenty of tshapes. i have plenty of ellipse on the chart.
Normally You could do it like this

var
  h: hrgn;
begin
 h := CreateEllipticRgn(10,10,50,50);
 if PtInRegion(h,mouse.CursorPos.x,mouse.CursorPos.Y) then
   begin
   ...
   end;
 DeleteObject(h);
But how can i add an id or any identification on it?
The hint text are on the list.

btw, how can i add your in the paintbox...
You should have a list ellipsis coordinates and their identifiers.

This code can be in OnMouseMove event.
Can you give me an example.
I'm new to this programming stuff.
I really don't know how to implement your code... sorry
I'll revise my question so it will be easier to understand.

how can i identify that the mouse cursor is over the ellipse? and how can i put an id or identification for each ellipse? because each ellipse hint has different values/text.

help!!! :)
ASKER CERTIFIED SOLUTION
Avatar of mokule
mokule
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you mokule and meikl.
Btw mokule, is it advisable to dispose the pointer when destroying the list? or when freeing the list, is the memory allocated freed?
You're right. You should dispose pointers before list free.
The correct way is:

procedure TForm1.FormDestroy(Sender: TObject);
var
  i: integer;
begin
  for i := 0 to List.Count-1 do
    Dispose(List.Items[i]);
  List.Free;
end;
Thank you mokule.
I implemented your code in my program. It works perfectly.
Thanks again.