Entry
BBCBASIC: Windows: File: How to drag/drop a Microsoft Windows Explorer or desktop file on a form?
Oct 20th, 2006 11:10
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 20 October 2020 - 06:59 pm --------------------
BBCBASIC: Windows: File: How to drag/drop a Microsoft Windows Explorer
or desktop file on a form?
===
Steps: Overview:
1. -Open BBCBASIC
2. -Create a new application
3. -Type or copy the following source code
--- cut here: begin --------------------------------------------------
REM The given message number for a dropped files message
messageDropGI% = 563
:
REM Make sure to also intercept
REM Microsoft Windows API dropped file messages
REM (besides the messages which are intercepted by default)
*SYS 1
:
REM When an event (e.g. 'DragAcceptFiles') occurs,
REM check which message is being sent
REM and do something
ON SYS PROCsys( @msg%, @wparam%, @lparam% ) : RETURN
:
REM Inform the Microsoft Windows API 'DragAcceptFiles'
REM which BBCBASIC component (here a form), by passing it
REM its window number (@hwnd%), will accept dropped files
REM Note: the value 1 stands here for 'true'
SYS "DragAcceptFiles", @hwnd%, 1
:
REM This is the main loop which continues indefinitely
REM and waits for events to occur
REPEAT
WAIT 1
UNTIL FALSE
END
:
REM Here this event message is checked (in a case statement)
REM and something is done
DEF PROCsys( messageI%, windowI%, L% )
IF messageI% = messageDropGI% THEN PROCdropfiles( windowI%, L% )
ENDPROC
:
REM 6. Here you handle that particular event message
DEF PROCdropfiles( windowI%, L% )
LOCAL bufferI%
LOCAL bufferSizeI%
LOCAL fileDropI%
LOCAL fileDropMinI%
LOCAL fileDropMaxI%
LOCAL uintI%
LOCAL nilI%
fileDropMinI% = 1
bufferSizeI% = 255
uintI% = &FFFFFFFF
nilI% = 0
DIM bufferI% LOCAL bufferSizeI%
SYS "DragQueryFile", windowI%, uintI%, nilI%, 0 TO fileDropMaxI%
PRINT "No. of files being dropped = "; fileDropMaxI%
IF fileDropMaxI% = 0 THEN ENDPROC
FOR fileDropI% = fileDropMinI% TO fileDropMaxI%
SYS "DragQueryFile", windowI%, fileDropI% - 1, bufferI%, bufferSizeI%
PRINT "File "; fileDropI%;" is """ $$bufferI% """"
NEXT fileDropI%
SYS "DragFinish", windowI%
ENDPROC
--- cut here: end ----------------------------------------------------
4. -If you run this code and drag and drop icons (you can select more
than 1 file, by using e.g. <CTRL><SHIFT> while selecting these
files, thus 'fileDropMaxI%' can be 0, 1, 2, 3, ... depending how
many
files you select) from the desktop or files icons from Internet
Explorer, it will add the filename of that icon in the form
+------------------------+
|form |
| |
| |
| |
| |
| someFilename1 |
| someFilename2 |
| ... |
| |
| |
| |
| |
| |
| |
| |
| |
+------------------------+
===
Tested successfully on
Microsoft Windows XP Professional (service pack 2),
running
BBCBASIC for Windows v5.30a
===
Internet: see also:
---
BBCBASIC for Windows: Accepting drag-and-drop files (by author Richard
Russell)
[Internet: source:
http://bb4w.wikispaces.com/Accepting+drag-and-drop+files
]
---
Microsoft Windows: API: Function: DragAcceptFiles
http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/shellcc/platform/shell/reference/functions/dragacceptfiles.asp
---
Microsoft Windows: API: Function: DragQueryFile
http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/shellcc/platform/shell/reference/functions/dragqueryfile.asp
---
Delphi: File: How to drag/drop a Microsoft Windows Explorer or desktop
file on a memo?
http://www.faqts.com/knowledge_base/view.phtml/aid/36804/fid/175
----------------------------------------------------------------------