Use VB to implement OLE drag and drop function

xiaoxiao2021-03-06  56

Here is the application of the OLE drag and drop in VB with my software "article management system" as an example.

Add an image control in the form, add the following code during its imggdrop_oledragdrop:

Private Sub Imgdrop_oledragdrop (Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, x as single, y as single)

DIM STRTMP

IF data.getformat (15) THEN

DIM STRFILENAME AS STRING

Strfilename = getFileName (data.files (1))

..........

END IF

IF data.getformat (1) THEN

DIM STRCONTENT AS STRING

StrContent = DATA.GETDATA (1)

.................

END IF

End Sub

Explanation:

1. If you want to get the data being dragged, you need to judge the data that is dragged and dropped, different types of data differently.

2, the commonly used data type is mainly text, file list, file list can be used to get all content using for Each.

3, details, data type list, please review the use of MSDN's getData, getFormat usage.

The picture drag and drop results on the web page are the file addresses in the cache, which is the data of the file list type. For details, you must rely on your own research.

PS:

Drag and drop the web file file in Word can get an image (Word should only get the URL of the image, then download the image from the Internet) and HTML format, how is this implementation? If you know, please advise.

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

New Post(0)