📄 modalcolumns.pas
字号:
unit ModalColumns;
interface
uses
Windows,
Messages,
SysUtils,
Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
StdCtrls;
type
TColumnsModal = class(TForm)
Label1: TLabel;
Label2: TLabel;
ListBox1: TListBox;
ListBox2: TListBox;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure ListBox2DragOver(Sender, Source: TObject; x, Y: Integer;
State: TDragState; var Accept: Boolean);
procedure ListBox2DragDrop(Sender, Source: TObject; x, Y: Integer);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
ColumnsModal: TColumnsModal;
implementation
{$R *.dfm}
procedure TColumnsModal.ListBox2DragOver(Sender, Source: TObject; x,
Y: Integer; State: TDragState; var Accept: Boolean);
begin
Accept := Sender = Source;
Accept := Accept and (ListBox2.SelCount = 1);
end;
procedure TColumnsModal.ListBox2DragDrop(Sender, Source: TObject; x, Y: Integer);
var
ListLoop: Integer;
Text: string;
Pos: TPoint;
begin
Pos.x := x;
Pos.Y := Y;
if not (Sender = Source) then Exit;
for ListLoop := 0 to ListBox2.Items.Count - 1 do
begin
if ListBox2.Selected[ListLoop] then
begin
Text := ListBox2.Items.Strings[ListLoop];
ListBox2.Items.Delete(ListLoop);
ListBox2.Items.Insert(ListBox2.ItemAtPos(Pos, True), Text);
Exit;
end;
end;
end;
procedure TColumnsModal.Button1Click(Sender: TObject);
var
ListLoop: Integer;
Text: string;
begin
ListLoop := 0;
while ListLoop < ListBox1.Items.Count do
begin
if ListBox1.Selected[ListLoop] then
begin
Text := ListBox1.Items.Strings[ListLoop];
ListBox1.Items.Delete(ListLoop);
ListBox2.Items.Add(Text);
end
else
begin
Inc(ListLoop);
end;
end;
end;
procedure TColumnsModal.Button2Click(Sender: TObject);
var
ListLoop: Integer;
Text: string;
begin
ListLoop := 0;
while ListLoop < ListBox2.Items.Count do
begin
if ListBox2.Selected[ListLoop] then
begin
Text := ListBox2.Items.Strings[ListLoop];
ListBox2.Items.Delete(ListLoop);
ListBox1.Items.Add(Text);
end
else
begin
Inc(ListLoop);
end;
end;
end;
procedure TColumnsModal.FormShow(Sender: TObject);
begin
SetWindowLong(Button1.Handle, GWL_STYLE, WS_CHILD or WS_VISIBLE or BS_FLAT);
SetWindowLong(Button2.Handle, GWL_STYLE, WS_CHILD or WS_VISIBLE or BS_FLAT);
SetWindowLong(Button3.Handle, GWL_STYLE, WS_CHILD or WS_VISIBLE or BS_FLAT);
SetWindowLong(Button4.Handle, GWL_STYLE, WS_CHILD or WS_VISIBLE or BS_FLAT);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -