Delphi仿POS系統設定按鈕拖曳更改排序

drag2

drag1
許多餐飲或是快餐POS系統都會提供拖曳去更改按鈕排序!
在Delphi可不可以做得到呢?當然是簡單的~

1)MouseDown事件加上
(sender as tbutton).BeginDrag(false);
2)DragOver事件加上
if source is TButton then
Accept:=true;
3)DragDrop事件加上 >> 互換對方的caption
if Sender is TButton then begin
TempCaption := TButton(Source).Caption;
TButton(Source).Caption := TButton(Sender).Caption;
TButton(Sender).Caption := TempCaption;
end;