如题
解决方案 »
- Image如何Canvas出Panel的凸起或凹陷效果!
- 请问大家DELPHI里怎样申明这个函数?
- clientSocket和serverSocket是基于什么协议工作的?
- 请问各位,我怎么不能向SQLSERVER数据库插入超过15个字符的字符串,代码如下
- ADO中如何做一个提示输入IP,连接远程服务器SQL
- 如能解决,再加200分奉上......打开一个Delphi文件,出现如下错误提示.....急啊.
- 50分问题:在Delphi中如何实现文件的复制。
- 请问怎么设置COM+中的缓冲池?
- ==救命啊:连接Oracle的程序需要打包哪些文件?===
- 高手请进,怎样用delphi连接access数据库!
- 一个.mdb的数据库中只有一个表,用程序求这个表名
- 在作物料需求计划时,我这样分解物料的方法不对,怎么改?
有用户觉得ctrl,shift多选麻烦,想只用鼠标来多选,点一个选中一个。
界面上放个TApplicationEvents 控件var
pt:TPoint;procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
var
index:integer;
begin
if Msg.message=WM_LBUTTONDOWN then
begin
if Msg.hwnd=ListBox1.Handle then
begin
index:=ListBox1.ItemAtPos(pt,true);
if index>=0 then
ListBox1.Selected[index]:=not ListBox1.Selected[index];
Handled:=true;
end;
end;
end;procedure TForm1.ListBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
pt.X:=X;
pt.Y:=Y;
end;procedure TForm1.BitBtn1Click(Sender: TObject);
var
i:integer;
begin
for i:=0 to ListBox1.Items.Count-1 do
if ListBox1.Selected[i] then
Memo1.Lines.Add(ListBox1.Items[i])
end;
procedure TForm1.ListBox1Enter(Sender: TObject);
begin
keybd_event(17,0,0,0);
end;procedure TForm1.ListBox1Exit(Sender: TObject);
begin
keybd_event(17,0,2,0);
end;
liangqingzhi使用模拟Ctrl键虽然好用,但有时容易锁住Ctrl键.
gzmhero 的方法不错,但无法连续选择,我稍修改了一下:type
TMousePos = record
XPos, YPos: Smallint;
end;
var
Index:Integer = -1;
LastIndex: Integer;
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
var
I, I0, I1: Integer;
begin
if Msg.message=WM_LBUTTONDOWN then
begin
if Msg.hwnd=ListBox1.Handle then
begin
with TMousePos(Msg.lParam) do
Index:=ListBox1.ItemAtPos(Point(XPos, YPos),true);
LastIndex := Index;
ListBox1.ItemIndex := LastIndex;
if Index >= 0 then
ListBox1.Selected[Index]:=not ListBox1.Selected[Index];
Handled := True;
end;
end;
if Msg.message=WM_LBUTTONUP then
begin
if Msg.hwnd=ListBox1.Handle then
begin
Index := -1;
end;
end;
if Msg.message=WM_MOUSEMOVE then
begin
if Msg.hwnd=ListBox1.Handle then
begin
if Msg.wParam and MK_LBUTTON <> 0 then begin;
with TMousePos(Msg.lParam) do
I1 := ListBox1.ItemAtPos(Point(XPos, YPos), True);
if I1 = LastIndex then Exit;
if I1 < 0 then Exit;
LastIndex := I1;
if I1 > Index then I0 := Index + 1 else begin
I0 := I1;
I1 := Index - 1;
end;
for I := I0 to I1 do
ListBox1.Selected[I] := ListBox1.Selected[Index];
ListBox1.ItemIndex := LastIndex;
end;
end;
end;
end;