X
xgwzw
Unregistered / Unconfirmed
GUEST, unregistred user!
拖入时如何制定目标组件呢?
procedure TForm1.AppOnMessage(var Msg: TMsg; var Handled: Boolean);
VAR WMD : TWMDropFiles;
BEGIN
IF Msg.message = WM_DROPFILES then
BEGIN
WMD.Msg := Msg.message;
WMD.Drop := Msg.wParam;
WMD.Unused := Msg.lParam;
WMD.Result := 0;
WMDropFiles(WMD);
Handled := TRUE;
END;
end;
procedure TForm1.WMDropFiles(var Msg: TWMDropFiles);
VAR
N : Word;
buffer : ARRAY[0..180] OF Char;
Pt:TPoint;
begin
WITH Msg DO
BEGIN
FOR N := 0 TO DragQueryFile(Drop, $FFFFFFFF, buffer,1)-1 DO
BEGIN
DragQueryFile(Drop, N, Buffer, 80);
if SameText(ExtractFileExt(StrPas(Buffer)),'.txt') then
begin
GetCursorPos (Pt);
//if (pt.x>chklst1.Left) and (pt.x<chklst1.Width+chklst1.Left) and (pt.y>chklst1.Top) and (pt.y<chklst1.Height+chklst1.top)then
// if ControlAtPos(pt,False).Name='chklst1' then
试图得到鼠标位置来判断,我没有通过,可能是我的功力不够把,我想应该可以的!
begin
//ShowMessage('1');
chklst1.Items.Add(StrPas(Buffer));
end;
// if fchklstflag=2 then
if ControlAtPos(pt,False).Name='chklst4' then
begin
chklst5.Items.Add(StrPas(Buffer));
end;
end;
END;
DragFinish(Drop);
END;
END;
procedure TForm1.AppOnMessage(var Msg: TMsg; var Handled: Boolean);
VAR WMD : TWMDropFiles;
BEGIN
IF Msg.message = WM_DROPFILES then
BEGIN
WMD.Msg := Msg.message;
WMD.Drop := Msg.wParam;
WMD.Unused := Msg.lParam;
WMD.Result := 0;
WMDropFiles(WMD);
Handled := TRUE;
END;
end;
procedure TForm1.WMDropFiles(var Msg: TWMDropFiles);
VAR
N : Word;
buffer : ARRAY[0..180] OF Char;
Pt:TPoint;
begin
WITH Msg DO
BEGIN
FOR N := 0 TO DragQueryFile(Drop, $FFFFFFFF, buffer,1)-1 DO
BEGIN
DragQueryFile(Drop, N, Buffer, 80);
if SameText(ExtractFileExt(StrPas(Buffer)),'.txt') then
begin
GetCursorPos (Pt);
//if (pt.x>chklst1.Left) and (pt.x<chklst1.Width+chklst1.Left) and (pt.y>chklst1.Top) and (pt.y<chklst1.Height+chklst1.top)then
// if ControlAtPos(pt,False).Name='chklst1' then
试图得到鼠标位置来判断,我没有通过,可能是我的功力不够把,我想应该可以的!
begin
//ShowMessage('1');
chklst1.Items.Add(StrPas(Buffer));
end;
// if fchklstflag=2 then
if ControlAtPos(pt,False).Name='chklst4' then
begin
chklst5.Items.Add(StrPas(Buffer));
end;
end;
END;
DragFinish(Drop);
END;
END;