Page 1 of 1

DROP mail attachment into Xbase application

Posted: Wed May 05, 2021 7:20 am
by skiman
Hi,

Anyone who already succeeded to drop a mail attachment (pdf, jpg) into an Xbase application?

I can drop a file from Windows Explorer to the application, but can't find a way to drop from Outlook.

Re: DROP mail attachment into Xbase application

Posted: Wed May 05, 2021 8:14 am
by rdonnay
I tried to do this too with no success.

Re: DROP mail attachment into Xbase application

Posted: Wed May 05, 2021 6:51 pm
by Auge_Ohr
hi,

Xbase++ does use "simple" Constant WS_EX_ACCEPTFILES or Function

Code: Select all

FUNCTION DRAGACCEPTFILES( HWND, lOnOff )
   Dllcall( "Shell32.dll", DLL_OSAPI, "DragAcceptFiles", HWND, lOnOff )
RETURN NIL
to accept File XBPCLPBRD_TEXT / XBPCLPBRD_FILELIST or XBPCLPBRD_BITMAP / XBPCLPBRD_METAFILE from Explorer only.

to "transfer" Email / Attachment into "other" App you need "OLE" Dragdrop which is a much higher Level than Xbase++ can use.

---

you can use COM Interface to build your "own Reader" and add "simulate" DragDrop

o:LbDown() is where you start and WindowFromPoint() API give you Handle of Target.
but you can only "send" a String which "other" App accept and "start Action".

so you have to "save" Email / Attachment via COM Interface and "other" App can use "Action String" to import those Files into it´s App.

---

Code: Select all

   ::oLW1:OnItemBEGINDRAG := { | n, st | ShowDragDrop( ::oLW1, 1 ) }  // o:LbDown and hold it

PROCEDURE ShowDragDrop( oObj, nNo )
   ...
         CASE nEvent == xbeM_LbUp                               // when reach Target to "drop"
            aDropPos := GetCursorPos()
            nHwnd := WindowFromPoint( aDropPos )
            cClsName := ChrR( 0, 1024 )
            cText := ChrR( 0, 1024 )
            @ user32:GetWindowTextA( nHwnd, @cText, LEN( cText ) )
            @ user32:GetClassNameA( nHwnd, @cClsName, LEN( cClsName ) )

            cClsName := STRTRAN( cClsName, CHR( 0 ), "" )
            cText := STRTRAN( cText, CHR( 0 ), "" )

            IF "SysListView32" $ cClsName .AND. "FolderView" $ cText
               // Msgbox(cString,"to Desktop")
               PostappEvent( xbeE_CopyToDeskTop,,, LastDialog( oObj ) :drawingArea )
            ELSE
               oObj:Prep4Drag( nNo )
            ENDIF

            EXIT
...

Code: Select all

         CASE nEvent == xbeE_CopyToDeskTop
            oDlg:Drop2Desk()

METHOD XCM:Drop2Desk()
LOCAL oObj       := ::AktiveList()
LOCAL aData      := oObj:getdata()
LOCAL cUser      := GETENV( "USERPROFILE" )
LOCAL cTargetDir := cUser + "\Desktop\"
   ...
   "just" copy files to Target 
   ::DropCopy( aFiles, cTargetDir )

---

Code: Select all

METHOD DXE_ListView:Prep4Drag( nNo )
   ...
      CASE nHwnd > 0                            // external "EDIT" (TEXT) or "IMAGE" Control
         // Clipboard-Objekt erzeugen
         oClipBoard := XbpClipBoard() :new() :create()
         oClipBoard:open()
         oClipBoard:clear()
         oClipBoard:setBuffer( cString )
         oClipBoard:close()

         @User32:ShowWindow( nHwnd, SW_RESTORE )
         @User32:BringWindowToTop( nHwnd )
         @User32:SetForegroundWindow( nHwnd )
         @User32:SetFocus( nHwnd )

         ::keybd_event( VK_CONTROL, 0, 0, 0 )
         ::keybd_event( ASC( "V" ), 0, 0, 0 )
         ::keybd_event( ASC( "V" ), 0, KEYEVENTF_KEYUP, 0 )
         ::keybd_event( VK_CONTROL, 0, KEYEVENTF_KEYUP, 0 )