User Tools

Site Tools


receiving_20dropped_20files

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
receiving_20dropped_20files [2018/03/31 13:19] – external edit 127.0.0.1receiving_20dropped_20files [2024/01/05 00:21] (current) – external edit 127.0.0.1
Line 1: Line 1:
 =====Receiving dropped files===== =====Receiving dropped files=====
  
-//by Richard Russell, June 2010//\\ \\  The article [[/Opening%20a%20file%20by%20dropping%20or%20clicking|Opening a file by dropping or clicking]] describes how you can handle a file which is **dragged-and-dropped** onto your program's icon. Another way of receiving files is as a result of the user dropping them onto your program's **//window//** rather than onto its **//icon//**. This article describes how to do that.\\ \\  Firstly some initialisation is required:\\ +//by Richard Russell, June 2010//\\ \\  The article [[/Opening%20a%20file%20by%20dropping%20or%20clicking|Opening a file by dropping or clicking]] describes how you can handle a file which is **dragged-and-dropped** onto your program's icon. Another way of receiving files is as a result of the user dropping them onto your program's **//window//** rather than onto its **//icon//**. This article describes how to do that.\\ \\  Firstly some initialisation is required: 
 + 
 +<code bb4w> 
         WM_DROPFILES = &233         WM_DROPFILES = &233
         *SYS 1         *SYS 1
Line 11: Line 13:
         ON SYS PROCsys(@msg%, @wparam%, @lparam%) : RETURN         ON SYS PROCsys(@msg%, @wparam%, @lparam%) : RETURN
         SYS "DragAcceptFiles", @hwnd%, 1         SYS "DragAcceptFiles", @hwnd%, 1
-Once this code has been executed, a file (or files) being dropped onto your program's window will result in an **ON SYS** interrupt with the **@msg%** value being **WM_DROPFILES**.\\ \\  In your 'main loop' you will want to monitor the value of **Dropped%** to determine whether any files have been dropped onto your window. If one or more files has been dropped, you can discover the filenames from the array **DroppedFile$()**. If you need to know **where** the files were dropped (for example your program performs a different action as a result) the coordinates **DroppedAt.x%** and **DroppedAt.y%** are in pixels measured from the top-left corner of your window. Here is a simple example of the kind of code needed:\\ +</code> 
 + 
 +Once this code has been executed, a file (or files) being dropped onto your program's window will result in an **ON SYS** interrupt with the **@msg%** value being **WM_DROPFILES**.\\ \\  In your 'main loop' you will want to monitor the value of **Dropped%** to determine whether any files have been dropped onto your window. If one or more files has been dropped, you can discover the filenames from the array **DroppedFile$()**. If you need to know **where** the files were dropped (for example your program performs a different action as a result) the coordinates **DroppedAt.x%** and **DroppedAt.y%** are in pixels measured from the top-left corner of your window. Here is a simple example of the kind of code needed: 
 + 
 +<code bb4w>
         REPEAT         REPEAT
           WAIT 1           WAIT 1
Line 25: Line 31:
         UNTIL FALSE         UNTIL FALSE
         END         END
-Here the information about the dropped files is simply printed to the screen, but in practice you are likely to want to do something different!\\ \\  Finally, here is the **ON SYS** handler for processing the **WM_DROPFILES** message:\\ +</code> 
 + 
 +Here the information about the dropped files is simply printed to the screen, but in practice you are likely to want to do something different!\\ \\  Finally, here is the **ON SYS** handler for processing the **WM_DROPFILES** message: 
 + 
 +<code bb4w>
         DEF PROCsys(M%,W%,L%)         DEF PROCsys(M%,W%,L%)
         CASE M% OF         CASE M% OF
Line 43: Line 53:
         ENDCASE         ENDCASE
         ENDPROC         ENDPROC
 +</code>
 +
 Needless to say, if there are other **ON SYS** interrupts that need to be handled by your program (e.g. menu selections, button clicks etc.) then you must add the necessary code to this handler (probably in a **WHEN WM_COMMAND:** clause). Needless to say, if there are other **ON SYS** interrupts that need to be handled by your program (e.g. menu selections, button clicks etc.) then you must add the necessary code to this handler (probably in a **WHEN WM_COMMAND:** clause).
receiving_20dropped_20files.1522502377.txt.gz · Last modified: 2024/01/05 00:16 (external edit)