很久之前找了一个dragout-v0.2的库文件,现在不知道原网址了,不知道咋用,给的案例也报错
Code AardioLine:176复制
1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.97.98.99.100.101.102.103.104.105.106.107.108.109.110.111.112.113.114.115.116.117.118.119.120.121.122.123.124.125.126.127.128.129.130.131.132.133.134.135.136.137.138.139.140.141.142.143.144.145.146.147.148.149.150.151.152.153.154.155.156.157.158.159.160.161.162.163.164.165.166.167.168.169.170.171.172.173.174.175.176.import
win
;import
win
.cur;import
fsys;namespace
win
.util;class
dragout{-
ctor
(){ -
this
.running = false
; -
-
var
newWndproc = function
(hwnd, message, wParam, lParam){ -
select
(message) { -
case
0x20 { -
-
return
0
; - }
-
case
0x200 { - setCur(getDropTarget(
this
.allowParent) ? this
.cur_yes : this
.cur_no); -
return
0
; - }
-
case
0x202 { -
var
drop = dropFiles(getDropTarget(this
.allowParent), this
.files); - releaseCapture();
-
this
.stop(); -
if
(drop && this
.callback){ -
this
.callback(hwnd); - }
-
return
0
; - }
-
else
{ -
return
this
.originWndproc(hwnd, message, wParam, lParam); - }
- }
- }
- };
- start =
function
(winform, files, callback, allowParent = true
, cur_yes, cur_no){ -
this
.stop(); -
if
(!winform[["hwnd"
]]) error
("参数@1:应为窗口!"
, 2
); -
if
(type
(files) != type
.table
) error
("参数@1:应为字符串数组!"
, 2
); -
-
this
.winform = winform; -
this
.originWndproc = null
; -
-
-
var
originWndproc = winform.wndproc; -
if
(!originWndproc){ -
this
.haveOriginWndproc = false
; - winform.wndproc =
function
(){}; - originWndproc = winform.wndproc;
-
if
(!originWndproc) error
("扩展库错误:窗口回调函数错误!"
, 2
); - }
else
{ -
this
.haveOriginWndproc = true
; - }
-
this
.originWndproc = originWndproc; -
-
this
.files = files; -
for
(i=1
; -
this
.files[i] = ..string
.toUnicode(files[i]); - }
-
this
.callback = callback; -
this
.allowParent = allowParent; -
-
this
.cur_yes = cur_yes : self
.cur_yes; -
this
.cur_no = cur_no : self
.cur_no; -
- winform.wndproc =
null
; - winform.wndproc = newWndproc;
-
- setCapture(winform.hwnd);
- setCur(getDropTarget(
this
.allowParent) ? this
.cur_yes : this
.cur_no); -
-
this
.running = true
; - }
- stop =
function
(){ -
if
(!this
.running) return
; -
if
(this
.originWndproc){ -
this
.winform.wndproc = null
; -
if
(this
.haveOriginWndproc){ -
this
.winform.wndproc = this
.originWndproc; -
this
.originWndproc = null
; - }
- }
-
this
.running = false
; - }
- }
var
curdata = '\x00\x00\x02\x00\x01\x00\x20\x20\x00\x00\x00\x00\x00\x000\x01\x00\x00\x16\x00\x00\x00(\x00\x00\x00\x20\x00- \x00\x00@\x00\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
- \x00\x00\x00\x00\x00\x00\x00\xFF\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1F\xF0\x00\x00\x1F\xF0
- \x00\x00\x1E\xF0\x00\x00\x1E\xF0\x00\x00\x180\x00\x0A\x9E\xF0\x00\x15^\xF0\x00\x08\x1F\xF0\x00\x10\x1F\xF0\x00\x08\x00\x00
- \x00\x10\x01\x00\x00\x08\x02\x00\x00\x11\x95\x00\x00\x09\xAA\x00\x00\x03\x00\x00\x00C\x00\x00\x00f\x00\x00\x00~\x00\x00\x00
- ~\x00\x00\x00\x7F\xC0\x00\x00\x7F\x80\x00\x00\x7F\x00\x00\x00~\x00\x00\x00|\x00\x00\x00x\x00\x00\x00p\x00\x00\x00\x60\x00
- \x00\x00@\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xC0\x07\xFF\xFF\xC0\x07\xFF\xFF\xC0\x07\xFF\xFF
- \xC0\x07\xFF\xFF\xC0\x07\xFF\xFF\xC0\x07\xFF\xE0\x00\x07\xFF\xE0\x00\x07\xFF\xE7\xC0\x07\xFF\xE7\xC0\x07\xFF\xE7\xC0\x07
- \xFF\xE7\xFC\xFF\xFF\xE6<\xFF\xFF\xE4\x00\xFF\xFF\x60\x00\xFF\xFF8\x7F\xFF\xFF\x18\x7F\xFF\xFF\x00\xFF\xFF\xFF\x00\xFF\xFF
- \xFF\x00\x0F\xFF\xFF\x00\x1F\xFF\xFF\x00?\xFF\xFF\x00\x7F\xFF\xFF\x00\xFF\xFF\xFF\x01\xFF\xFF\xFF\x03\xFF\xFF\xFF\x07\xFF
- \xFF\xFF\x0F\xFF\xFF\xFF\x1F\xFF\xFF\xFF?\xFF\xFF\xFF';
namespace
dragout{-
var
win
= ..win
; -
var
string
= ..string
; -
- setCur =
win
.cur.setCur; - setCapture =
win
.setCapture; - releaseCapture =
win
.releaseCapture; -
- cur_no =
win
.cur.load(0x7F88) -
var
tname = string
.fromto((..io
.tmpname("aardio_dragout_cur_"
)), 0
, 65001
); -
string
.save(tname, curdata); -
- cur_yes =
win
.cur.loadfile(tname); - ..fsys.delete(tname);
- tname =
null
; -
-
var
GetCursorPos = User32.api("GetCursorPos"
,"INT( struct &lpPoint)"
) ; - getCursorPos =
function
(){ -
var
p = ::POINT(); - GetCursorPos(p);
-
return
p.x, p.y; - }
-
-
var
WindowFromPoint = ::User32.WindowFromPoint; -
var
getStyleEx = ..win
.getStyleEx; -
var
getParentOwner = ..win
.getParentOwner; - getDropTarget =
function
(allowParent = true
){ -
var
hwnd = WindowFromPoint(getCursorPos()); -
if
(allowParent) while
(hwnd){ -
if
(getStyleEx(hwnd, 0x10)) -
break
; - hwnd = getParentOwner(hwnd);
- }
else
{ -
if
(!getStyleEx(hwnd, 0x10)){ -
return
; - }
- }
-
return
hwnd; - }
-
-
class
DROPFILES{ -
ctor
(x, y){ -
this
.x = x; -
this
.y = y; - }
- INT pFiles =
20
; - int x;
- int y;
- INT fNC =
1
; - INT fWide =
1
; - }
-
var
rtostring = ..raw
.tostring
; - dropFiles =
function
(hwnd, files){ -
if
(!hwnd) return
false
; -
var
str = rtostring(DROPFILES(getCursorPos())); -
for
(i=1
; -
var
p = ::GlobalAlloc(0x40, - ::CopyMemory(p, str,
-
-
- ::PostMessage(hwnd, 0x233,
tonumber
(p), 0
); -
return
true
; - }
- }
给的实列,有报错
Code AardioLine:47复制
1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.import
win
.ui;var
winform = win
.form(text="aardio form"
;right=448
;bottom=311
;acceptfiles=1
)- winform.add(
- button={cls=
"button"
;text="button"
;left=143
;top=96
;right=269
;bottom=184
;z=1
} - )
import
console;- console.open();
import
win
.util.dragout;- drag =
win
.util.dragout(); - filetab = {
"D:\test.aardio"
; "D:\test2.aardio"
}; - winform.button.wndproc =
function
(hwnd,message,wParam,lParam){ -
select
( message ) { -
case
0x201{ - drag.start(winform.button, filetab,
function
(hwnd){ - console.log(hwnd);
- },
true
); - }
-
case
0x233{ - console.dump(
win
.getDropFile(wParam)); - }
- }
-
- }
- winform.wndproc =
function
(hwnd,message,wParam,lParam){ -
select
( message ) { -
case
0x201{ - drag.start(winform, filetab,
function
(hwnd){ - console.log(hwnd);
- },
false
); - }
-
case
0x233{ - console.dump(
win
.getDropFile(wParam)); - }
- }
-
- }
- winform.show();
win
.loopMessage();- console.pause(
true
);