![]() |
|
|
#1
|
|||
|
|||
|
как сделать так чтобы при нажатии мышью в определенную область TImage (например X от 0 до 100 а Y от 10 до 20) появлялась новая форма
|
|
#2
|
||||
|
||||
|
Использовать PtInRect.
|
|
#3
|
|||
|
|||
|
так? а в point что писать?
Код:
procedure TForm1.ImageGistClick(Sender: TObject);
begin
myRect := Rect(10,100, 35, 0);
if PtInRect(myRect, Point(?,?))
then form2.Show;
end;
end. |
|
#4
|
||||
|
||||
|
Чтобы не ловить координаты курсора, удобнее использовать MouseDown, там они уже передаются в параметрах.
Это нонсенс: Код:
myRect := Rect(10,100, 35, 0); |
|
#5
|
|||
|
|||
|
Код:
procedure TForm1.ImageGistMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; x, y: Integer); begin if (x >= 10 or x <= 35) and (y >= 0 or y <=100) ) then form2.Show; end; |
|
#6
|
|||
|
|||
|
скобки
if ((x >= 10) or (x <= 35)) and ((y >= 0) or (y <=100)) |
|
#7
|
|||
|
|||
|
можно так =)
if (x in [10..35]) and (y in [0..100]) |
|
#8
|
||||
|
||||
|
Для использования Rect-а:
Код:
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X,
Y: Integer);
begin
if PtInRect(Rect(0, 10, 100, 20), Point(X, Y)) then
MessageDlg('qwerty', mtInformation, [mbOk], 0);
end; |