【发布时间】:2011-05-19 17:46:27
【问题描述】:
这个话题显然在这里被反复讨论过,但现在从我的角度来看,我已经没有选择了。
操作系统: Windows XP SP3
所以,这是我在我的应用中使用的 RichEdit 的拖放示例:
procedure TForm1.AcceptFiles( var msg : TMessage ); // or TWMDROPFILES
const
cnMaxFileNameLen = 255;
var
i,
nCount : integer;
acFileName : array [0..cnMaxFileNameLen] of char;
begin
// find out how many files we're accepting
nCount := DragQueryFile( msg.WParam, // or msg.Drop
$FFFFFFFF,
acFileName,
cnMaxFileNameLen );
// query Windows one at a time for the file name
for i := 0 to nCount-1 do
begin
DragQueryFile( msg.WParam, { or msg.Drop} i,
acFileName, cnMaxFileNameLen );
// do your thing with the acFileName
MessageBox( Handle, acFileName, '', MB_OK );
end;
// let Windows know that you're done
DragFinish( msg.WParam ); // or msg.Drop
end;
问题是在最近的一些更改之后(不幸的是,我没有使用任何 SVN,所以我无法跟踪哪个提交引入了这个问题)拖放不再起作用。
我在每个可能以某种方式相关(称为)的事件中都运行断点但没有成功:
RichEditMouseOver;
RichEditChange;
FormClick;
我的应用正在处理这些 WM:
procedure WMDropFiles(var Msg: TWMDROPFILES); message WM_DROPFILES;
procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
procedure WMCopyData(var Msg: TWMCopyData); message WM_COPYDATA;
procedure WMGetMinMaxInfo(var AMsg: TWMGetMinMaxInfo); message WM_GETMINMAXINFO;
procedure CMDialogKey(var Msg: TCMDialogKey ); message CM_DIALOGKEY;
在表单上使用 TRichEdit 的空白项目 - 一切正常。
还尝试将 DragAcceptFiles() Form1.Handle 更改为 RichEdit.Handle - 仍然没有运气。
在回显nCount和acFileName参数时,acFileName没有拖拽文件的文件路径...为什么????
目前我只是不知道是什么让 acFileName 参数丢失了拖动文件路径。你能建议问题隐藏在哪里吗?
【问题讨论】:
-
该死,看来这个问题比我预期的要复杂...... :(
标签: windows delphi file drag-and-drop messages