tirbanqs
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.
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.
ASKER
nice idea.
is it ok if i have plenty of tshapes. i have plenty of ellipse on the chart.
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.CursorP os.x,mouse .CursorPos .Y) then
begin
...
end;
DeleteObject(h);
var
h: hrgn;
begin
h := CreateEllipticRgn(10,10,50
if PtInRegion(h,mouse.CursorP
begin
...
end;
DeleteObject(h);
ASKER
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...
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.
This code can be in OnMouseMove event.
ASKER
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'm new to this programming stuff.
I really don't know how to implement your code... sorry
ASKER
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!!! :)
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you mokule and meikl.
ASKER
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;
The correct way is:
procedure TForm1.FormDestroy(Sender:
var
i: integer;
begin
for i := 0 to List.Count-1 do
Dispose(List.Items[i]);
List.Free;
end;
ASKER
Thank you mokule.
I implemented your code in my program. It works perfectly.
Thanks again.
I implemented your code in my program. It works perfectly.
Thanks again.
instead of drawing place TShapes
just as an idea
meikl ;-)