0

如何使用GuiDropFilesGUI 控件?

我的表单中有几个edit字段,我希望能够将文件分别拖放到它们上并使用它们。

这就是我想出的:

首先,我的控件设置如下:

WS_EX_ACCEPTFILES=0x10

Gui, add, edit,  vedit1, %file_1%
WinSet,ExStyle, +WS_EX_ACCEPTFILES, edit1

我的拖放程序是这样的:

GuiDropFiles:  ; Support drag & drop.
    Loop, parse, A_GuiControlEvent, `n
    {
        thisfile := a_loopfield  ; Get the first file only (in case there's more than one).
        thiscontrol := a_guicontrol
        break
    }

    alert(thisfile . "`r" . thiscontrol)

    if(thiscontrol = edit1)
        guicontrol,,%edit1%, %thisfile%
    if(thiscontrol = edit2)
        guicontrol,,%edit2%, %thisfile%
    if(thiscontrol = edit3)
        guicontrol,,%edit3%, %thisfile%

return

我正在使用 autohotkey 文档中的基本示例。我也从这里尝试了这个例子,但它一直说,“没有放在编辑框上”。任何线索都会很棒。

4

1 回答 1

0

想通了(经过几个小时的损失)。

首先,我不需要这个: WinSet,ExStyle, +WS_EX_ACCEPTFILES, edit1

而且我不需要在编辑控件上设置任何样式。

我所需要的就是这个,因为我的编辑控件的变量名以“UI_file”开头:

GuiDropFiles:  ; Support drag & drop.

    Loop, parse, A_GuiEvent, `n
    {
        thisfile := A_LoopField  ; Get the first file only (in case there's more than one).
        thiscontrol := a_guicontrol
        break
    }
    ;alert(thisfile . "`r" . thiscontrol)

    If InStr(A_GuiControl, "UI_file")
        guicontrol,,%A_GuiControl%, %thisfile%

return
于 2013-06-10T22:47:43.113 回答