  $ filename "t.exe"
 'uses RTL64
  uses minwin

  % WM_DROPFILES  0x0233

  dim cmdline as asciiz ptr
  dim hinst as sys
  
  extern lib "shell32.dll"
    ! DragQueryFile "DragQueryFileA"
    ! DragFinish
    ! DragAcceptFiles
  end extern
  
  ' DragQueryFile Alias "DragQueryFileA" ( _
  '   sys wHandle, NumFiles, NameBuffer,BufferLen ) As sys
  ' DragFinish Alias "DragFinish" (sys wHandle)
  ' DragAcceptFiles Alias "DragAcceptFiles" (sys hWnd, fAccept )


  Function GetDropFiles(sys hDropParam) As String
  ===============================================
  ' returns string list of dropped files
  '
  int i             ' iterator
  int e             ' number of files dropped
  int le            ' length of each file
  string sfile      ' temp name buffer for each file
  string sDropFiles ' list of files to return
  '
  e=DragQueryFile(hDropParam, -1, 0, 0)
  for i = 0 To e-1
    '
    ' get filename length
    ' create buffer for filename
    ' get filename
    ' append filename to list              
    ' but ignore shortcuts
    '
    le=DragQueryFile(hDropParam, i, 0, 1)
    sfile=space le
    DragQueryFile(hDropParam, i, sFile, le+1)
    If Ucase(mid(sFile, -4)) = ".LNK"
    else
      sDropFiles+= sFile + chr(13,10)
    end if
  next i   
  return sDropFiles
  End Function



  function WndProc ( sys hWnd, wMsg, wParam, lparam ) as sys callback
  ===================================================================

    static sys          hdc
    static string       txt
    static PaintStruct  Paintst
    static rect         crect
 
    ===========
    select wMsg
    ===========
      
    'case WM_COMMAND
                 
    case WM_CREATE
    ==============
            
    DragAcceptFiles(hwnd, TRUE)
  
    static sys hwdr
    int style=
      WS_CHILD | WS_BORDER | WS_VISIBLE | ES_READONLY |
      ES_MULTILINE   | ES_WANTRETURN
    string stys="edit"
    hwdr=CreateWindowEx(0,stys, null, style, 0,0,0,0, hwnd, 100, hinst, null)
    string s = "Drop Files here:"
    int le=len s
    SendMessage hwdr,WM_SETTEXT,le,s

    Case WM_DROPFILES
    =================
    '
    sys pDrop = wparam
    string sFiles = GetDropFiles(pDrop)
    int le=len sFiles
    SendMessage hwdr,WM_SETTEXT,le,sFiles
    'print sFiles
    DragFinish(wparam)
    '
    case WM_DESTROY
    ================
          
    PostQuitMessage 0
              

    case WM_KEYDOWN
    ===============

      select wParam
      =============

      case 27 : SendMessage hwnd, WM_CLOSE, 0, 0      'ESCAPE

      end select

    case WM_SIZE
    ============

    RECT r
    GetClientRect hwnd,r
    MoveWindow hwdr , r.left+10 , r.top+10 , r.right-20 , r.bottom-20 , TRUE

      

    case else
    =========
          
      function=DefWindowProc hWnd,wMsg,wParam,lParam
        
    end select

  end function ' WndProc

  Function WinMain(sys inst, prevInst, asciiz*cmdline, sys show) as sys
  =====================================================================

  WndClass wc
  MSG      wm

  sys hwnd, wwd, wht, wtx, wty, tax

  with wc
    .style = CS_HREDRAW or CS_VREDRAW
    .lpfnWndProc = @WndProc 
    .cbClsExtra =0
    .cbWndExtra =0    
    .hInstance =inst
    .hIcon=LoadIcon 0, IDI_APPLICATION
    .hCursor=LoadCursor 0,IDC_ARROW
    .hbrBackground = GetStockObject WHITE_BRUSH 
    .lpszMenuName =null
    .lpszClassName = strptr "Demo"
  end with
  '
  RegisterClass wc
 
  wwd = 640
  wht = 240
  tax = GetSystemMetrics SM_CXSCREEN
  wtx = (tax - wwd) >>1
  tax = GetSystemMetrics SM_CYSCREEN
  wty = (tax - wht) >>1
 
  hwnd = CreateWindowEx 0,wc.lpszClassName,"Drag and Drop",WS_OVERLAPPEDWINDOW,Wtx,Wty,Wwd,Wht,0,0,inst,0
  ShowWindow hwnd,SW_SHOW
  UpdateWindow hwnd
  
  DragAcceptFiles(hwnd, TRUE)
  '
  sys bRet
  '
  do while bRet := GetMessage(wm, 0, 0, 0)
    if bRet = -1 then
      'show an error message
    else
      TranslateMessage wm
      DispatchMessage wm
    end if
  wend
  End Function 


  'ENTRY CODE
  '==========
  
  @cmdline=GetCommandLine
  hinst=GetModuleHandle 0
  '
  'WINDOWS START
  '=============
  '
  WinMain(hinst,0,cmdline,SW_NORMAL)
  end
