Trust files in Explore to VB.NET windows

zhaozj2021-02-16  38

To let VB.NET, the files are checked out, you need to handle WM_DROPFILES messages.

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 = & h233private 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 ifend sub

My code is just an image file that is suitable for Picturebox. Net!

转载请注明原文地址:https://www.9cbs.com/read-27503.html

New Post(0)