首页 > 编程 > .NET > 正文

托拽Explore中的文件到VB.net的窗口 40Star(原作)

2024-07-10 13:08:02
字体:
来源:转载
供稿:网友
托拽explore中的文件到vb.net的窗口    40star(原作)  
  
关键字     wm_dropfiles vb.net
  


要让vb.net相应外部托拽来的文件,需处理wm_dropfiles消息。

private declare sub dragacceptfiles lib "shell32.dll" (byval hwnd as int32, byval faccept as int32)
private declare sub dragfinish lib "shell32.dll" (byval hdrop as int32)
private declare function dragqueryfile lib "shell32.dll" alias "dragqueryfilea" (byval hdrop as int32, byval uint as int32, byval lpstr as

string, byval ch as int32) as int32

private const wm_dropfiles = &h233
private const max_length = 255

protected overrides sub wndproc(byref m as system.windows.forms.message)
    if m.msg = wm_dropfiles then
        dragfiles(m.wparam.toint32)
        exit sub
    end if
    mybase.wndproc(m)
end sub

private sub dragfiles(byval hdrop as int32)
    dim ireturn as int32
    dim sfile as string
    sfile = space(max_length)
    ireturn = dragqueryfile(hdrop, 0, sfile, max_length)
    if ireturn then
        textbox3.text = sfile
        picturebox1.image = image.fromfile(trim(textbox3.text))
        dragfinish(hdrop)
    end if
end sub

我的代码只是适用于.net的picturebox能用的图像文件噢!





发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表