![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Как двигать обьекты?
Brack © (2005-07-02 20:35:00)Можно ли перемещать обьект(к примеру Label) в ходе работы программы, изменив при этом определенные свойства?
Brack (2005-07-05 00:03:00) [1]Вот сам решил эту задачку, оказалось все просто:
MouseMove(Shift: TShiftState; X, Y: Integer);
begin
if MDownPl=True then
begin
GetCursorPos(p);
otklX:=p.X-Left;
otklY:=p.y-top;
MDownPl:=False;
end;
if MDown=True then
begin
GetCursorPos(p);
Left:=p.X-otklX;
Top:=p.Y-otklY;
end;
end;
MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y:Integer);
begin
MDown:=True;
MDownPl:=True;
end;
MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y:Integer);
begin
MDown:=False;
end;
isasa (2005-07-02 22:41:00) [2]Да! :))))
OnMouseDown:=TForm1.suPanelMouseDown
isasa (2005-07-02 22:39:00) [3]Да!
Свойство, suPanel должно быть
DragMode:=dmManual
isasa (2005-07-02 22:35:00) [4]Таскать форму за метку?
procedure TForm1.Label1MouseDown(Sender: TObject; Button: TMouseButton;----------
Shift: TShiftState; X, Y: Integer);
const SC_DragMove = $F012; { a magic number }
begin
ReleaseCapture;
Form1.perform(WM_SysCommand, SC_DragMove, 0);
end;
Для панели (suPanel) соответственно
procedure TForm1.suPanelMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
suPanel.Perform(WM_SYSCOMMAND, $F012, 0);
end;
lookin (2005-07-02 21:09:00) [5]А какие свойства?
begin...end (2005-07-02 21:07:00) [6]Можно. См. в справке описание класса TControl: свойств Left и Top, а также метода SetBounds.