Buenas aquí tienes un ejemplo de como hacerlo, sin necesidad de usar ListBoxEx solo tienes que definir un objeto o ventana que tenga handle....
Código:
GLOBAL
if not WinAPI then WinAPI = {}; end
WinAPI.DragAcceptFiles = function (hWnd, bAccept)
assert((type(hWnd) == 'number'), 'Ïåðâûé ïàðàìåòð äîëæåí èìåòü òèï: number')
if bAccept == nil then bAccept = true; end
assert((type(bAccept) == 'boolean'), 'Âòîðîé ïàðàìåòð äîëæåí èìåòü òèï: boolean')
if bAccept == true then bAccept = 1; else bAccept = 0; end
DLL.CallFunction("shell32.dll", "DragAcceptFiles", hWnd..","..bAccept, 1, 1);
end
WinAPI.DragQueryFileEx = function (hDrop, nFlag)
assert((type(hDrop) == 'number'), 'Ïåðâûé ïàðàìåòð äîëæåí èìåòü òèï: number')
nFlag = nFlag or 0;
assert((type(nFlag) == 'number'), 'Âòîðîé ïàðàìåòð äîëæåí èìåòü òèï: number')
local Ret, nCount, bDir, sFile, pData
local tData = {};
Ret = DLL.CallFunction("shell32.dll", "DragQueryFileA", hDrop..",-1,0,0", 0, 1);
if Ret == "0" then return false; end
nCount = tonumber(Ret);
for i = 0, nCount - 1 do
pData = Memory.Allocate(1024);
Ret = DLL.CallFunction("shell32.dll", "DragQueryFileA", hDrop..","..i..","..pData..",1024", 0, 1);
if Ret == "0" then return false; end
sFile = Memory.GetString(pData, -1, "Ascii");
Memory.Free(pData);
if nFlag > 0 then
bDir = File.GetAttributes(sFile).Directory;
if nFlag == 1 and not bDir then
local tPaths = String.SplitPath(sFile);
tData[#tData + 1] = tPaths.Filename..tPaths.Extension;
elseif nFlag == 2 and bDir then
tData[#tData + 1] = _GetFolderName(sFile) .. " <-- this is a folder";
end
else
if File.GetAttributes(sFile).Directory then
tData[#tData + 1] = _GetFolderName(sFile) .. " <-- this is a folder";
else
local tPaths = String.SplitPath(sFile);
tData[#tData + 1] = tPaths.Filename..tPaths.Extension;
end
end
end
return (#tData == 0) and nil or tData;
end
WinAPI.DragFinish = function (hDrop)
DLL.CallFunction("shell32.dll", "DragFinish", hDrop, 1, 1);
end
Callback = function(hWnd, uMsg, wParam, lParam)
if uMsg == 563 then
local tFileList = WinAPI.DragQueryFileEx(wParam, tonumber(Page.GetRadioValue("1", RADIOGROUP_VALUE)));
if tFileList then
ListBox.DeleteItem("ListBox1", -1);
for i = 1, #tFileList do
ListBox.AddItem("ListBox1", tFileList[i], tFileList[i]);
end
end
WinAPI.DragFinish(wParam);
return 0;
end
end
function QueryAllowProjectClose()
Memory.FreeWindowSubClass(10);
return true;
end
_ShowRadioButton = function(b)
for i = 1, 3 do
RadioButton.SetEnabled("RadioButton"..i, b);
end
end
_GetFolderName = function (s)
s = String.TrimRight(s, "\\");
local nPos = String.ReverseFind(s, "\\", false);
if nPos ~= -1 then
return String.Mid(s, nPos + 1, -1);
end
return s;
end
ON SHOW:
-- îáðàáîò÷èê ñèñòåìíîãî ñîîáùåíèÿ WM_DROPFILES
Memory.CreateWindowSubClass(ListBox.GetProperties("ListBox1").WindowHandle, 10, "Callback");
Crea la llamada del callback del objecto de ese modo puedes tener acceso a dichos contenidos...
ON CLICK del CHECKBOX1
WinAPI.DragAcceptFiles(ListBox.GetProperties("ListBox1").WindowHandle, CheckBox.GetChecked(this));
_ShowRadioButton(CheckBox.GetChecked(this));
LLama a la funcion y define el Handle de dicho objecto...
Despues esta el codigo de los radiobox que realmente no tienen pero en realidad si por que al estar activo uno u otro se define un valor que luego sera llamado que esta en global que es este:
local tFileList = WinAPI.DragQueryFileEx(wParam, tonumber(Page.GetRadioValue("1", RADIOGROUP_VALUE)));
Si te fijas pide que le diga el valor de el radiobox activo si es 0,1 o 2... que son:
0 : Acepta archivos y carpetas
1 : Acepta solo archivos
2 : Acepta solo carpetas
Como ves algunos textos se ven mal por que seguramente estarán escritos en ruso... de modo que tienes que modificarlo también donde haga mención a RadioBox y donde define el Handle del ListBox, yo he cambiado 4 parámetros para ver si funcionaba usando el Handle de la ventana y funciona 100%.
Si tienes alguna duda haznos saber,
y si la información te fue de utilidad no olvides donar algo para el mantenimiento del foro!
Descarga:
- HIDE: ON
- Hidebb Message Hidden Description
Nota: Este ejemplo necesita el Plugin Memory para que funcione puesto que usa algunas funciones de dicho plugin.