Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Exploring System Port

From: rebol665:ifrance at: 14-Oct-2002 8:38

Hi Gregg, It works for me on Windows 2000 and on Windows 98. Pat ----- Original Message ----- From: "Gregg Irwin" <[greggirwin--mindspring--com]> To: <[rebol-list--rebol--com]> Sent: Monday, October 14, 2002 1:07 AM Subject: [REBOL] Re: Exploring System Port
> Hi All, > > OK, it looks like incoming Windows messages are formed like this: > > msg: [winmsg 563 8585228 0] > > so: > > msg/1 = 'winmsg > msg/2 = ID > msg/3 = wParam > msg/4 = lParam > > Below is a very quick hack that allows you to drag and drop files onto the > console window. Requires View/Pro or /Command for library access and a > version that supports the system port (e.g. 1.2.5, 1.2.8, Command 2.1.1). > > Let me know if it works for you. > > --Gregg > > P.S. Watch for wrap! > > REBOL [ > Title: "sys-port-drag-accept" > File: %sys-port-drag-accept.r > Author: "Gregg Irwin" > EMail: [greggirwin--acm--org] > Purpose: {Demo using system port to catch WM_DROPFILE messages.} > ] > > ; Stripped version of win-shell object for demo purposes. > win-shell: make object! [ > win-lib: load/library %shell32.dll > > null-buff: func [ > {Returns a null-filled string buffer of the specified length.} > len [integer!] > ][ > head insert/dup make string! len #"^@" len > ] > > drag-accept-files: make routine! [ > hWnd [integer!] > fAccept [integer!] > return: [integer!] > ] win-lib "DragAcceptFiles" > > drag-finish: make routine! [ > hDrop [integer!] > return: [integer!] > ] win-lib "DragFinish" > > drag-query-file: make routine! [ > hWnd [integer!] > iFile [integer!] > lpszFile[string!] > cb [integer!] > return: [integer!] > ] win-lib "DragQueryFile" > > drag-query-filename-size: make routine! [ > hWnd [integer!] > iFile [integer!] > lpszFile[integer!] > cb [integer!] > return: [integer!] > ] win-lib "DragQueryFile" > > num-files-dropped?: func [hdrop [integer!]] [ > drag-query-file hdrop -1 "" 0 > ] > > ; When they give us a filename index, we'll subtract one for them, > ; because Windows has the list as zero based, but I'd much rather let > ; everything be one based on the REBOL side. > dropped-filename-size?: func [hdrop [integer!] index [integer!]] [ > drag-query-filename-size hdrop index - 1 0 0 > ] > > dropped-filename?: func [hdrop [integer!] index [integer!] /local
result
> len] [ > result: null-buff add 1 dropped-filename-size? hdrop index > len: drag-query-file hdrop index - 1 result length? result > copy/part result len > ] > > ] > > my-hwnd?: does [second get-modes system/ports/system [window]] > > WM_DROPFILES: 563 ; &H233 > > enable-system-trap: does [ > ; Trap OS interrupts > if not system/ports/system [ > if none? attempt [system/ports/system: open [scheme: 'system]][ > print "NOTE: Missing System Port" exit > ] > ] > if find get-modes system/ports/system 'system-modes 'winmsg [ > set-modes system/ports/system [winmsg: WM_DROPFILES] > ] > append system/ports/wait-list system/ports/system > ] > > check-system-trap: func [port /local msg] [ > if not port? port [return none] > if any [port/scheme <> 'system port <> system/ports/system][return > port] > if not system/ports/system [return none] > while [msg: pick system/ports/system 1] [ > ;print ["msg:" mold msg] > if msg/1 = 'winmsg [ > if msg/2 = WM_DROPFILES [ > print ["You dropped " win-shell/num-files-dropped? msg/3 > "files."] > repeat i win-shell/num-files-dropped? msg/3 [ > file: to-rebol-file win-shell/dropped-filename? msg/3
i
> print [tab join i "." tab either dir? file [dirize > file][file]] > ] > print "Finishing drag operation" > win-shell/drag-finish msg/3 > print "Unregistering window from DragAcceptFiles queue" > win-shell/drag-accept-files my-hwnd? to integer! false > ; (save files here) > halt ;quit > ] > ] > ] > none > ] > > print "Drag some files and drop them on this window...^/" > > win-shell/drag-accept-files my-hwnd? to integer! true > > enable-system-trap > > forever [ > wake-port: wait 10 ;timeout period > if wake-port [check-system-trap wake-port] > ] > > -- > To unsubscribe from this list, please send an email to > [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes. > > ______________________________________________________________________ > Etudiant: Wanadoo t'offre le Pack eXtense Haut Débit soit 150,92 euros > d'économies ! Clique ici : http://www.ifrance.com/_reloc/mail.etudiant
______________________________________________________________________ Etudiant: Wanadoo t'offre le Pack eXtense Haut Débit soit 150,92 euros d'économies ! Clique ici : http://www.ifrance.com/_reloc/mail.etudiant