FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour drag and drop from outlook pure FIVEWIN solution
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
drag and drop from outlook pure FIVEWIN solution
Posted: Tue Dec 30, 2008 11:12 AM
Now I have drag and drop from outlook working. Here is my source code.

Regards,
Otto

exe file for testing: you need a c:\temp dir. Your email is saved there as a msg file.


http://www.winhotel.at/fw/xfang.zip

source:

testdrop.prg

#INCLUDE "FIVEWIN.CH"

REQUEST DBFCDX
REQUEST DBFFPT

function Main(cKdnr)
   local oDlg, oRich
   local hRichDLL  := LoadLibrary( "riched20.dll" )

   DEFINE DIALOG oDlg NAME "DROP"  FROM 1, 1 TO 100, 100 PIXEL

   oRich = xTRich():Redefine( 100, { || "" }, oDlg )
   oRich:cKdNr := cKdNr

   oRich:bMButtonDown  := {|nRow, nCol, nFlags| oRich:end(),oDlg:hide(),dropread(cKdnr),oDlg:show(), oDlg:end()}

   ACTIVATE DIALOG oDlg

   FreeLibrary( hRichDLL )

return nil
//----------------------------------------------------------------------------//


function dropread()
   local oDlg
   LOCAL oOutlook       := TOleAuto():New( "Outlook.Application" )
   local myOlExp        := oOutlook:ActiveExplorer
   local oMail
   local oGet
   local cKategorie      := space(50)
   local cStichwort      := space(50)
   local oK              := .f.
   local dDatum          := date()
   local dNachfassen     := date()+14
   local cScanner        := GetPvProfString( "SCANNER","MODELL","N",".\INI\WINHOTEL.INI" )
   local ziel            := ""
   local oDatei
   local I               := 0
   local cNotiz          := "cNotiz"
   local oInhalt
   local cDatei  := ""
   *--------------------------------------------------------------------------

   oMail := myOlExp:Selection:Item(1)
   oMail:SaveAs  ( "c:\temp\" +  "testdemo.msg"   )
   cNotiz     := left(ALLTRIM(oMail:body),1000)
   cStichwort := oMail:subject  + space(50)


   DEFINE DIALOG oDlg RESOURCE "SCANNER"

   REDEFINE SAY   oDatei               ID 111   OF  oDlg
   REDEFINE GET   ckategorie           ID 101   of oDlg
   REDEFINE GET   cStichwort           ID 102   of oDlg
   REDEFINE GET   dDatum               ID 105   of oDlg
   REDEFINE GET   dNachfassen          ID 106   of oDlg
   REDEFINE GET   oGet VAR  cNotiz     ID 8002  of oDlg MEMO

   REDEFINE BUTTON ID 103 OF oDlg  ACTION (oDlg:END())
   REDEFINE BUTTON ID 104 OF oDlg  ACTION (OK:=.T.,oDlg:END())

   ACTIVATE DIALOG oDlg ON INIT oDatei:SetText(cDatei) ;
      ON PAINT SETWINDOWPOS( oDlg:hWnd, -1, 0, 0, 0, 0, 3 ) ;
      CENTERED

   IF ok = .t.
      msginfo("Save data")
   ENDIF

return nil
//----------------------------------------------------------------------------//

INIT PROCEDURE PrgInit

   SET CENTURY ON
   SET EPOCH TO YEAR(DATE())-98

   SET DELETED ON
   SET EXCLUSIVE OFF

   REQUEST HB_Lang_DE
   REQUEST HB_CODEPAGE_DEWIN

   HB_LangSelect("DE")
   HB_SetCodePage("DEWIN")

   SET DATE TO GERMAN

   SetHandleCount(205)
   rddsetdefault( "DBFCDX" )
   SetGetColorFocus()

   EXTERN DESCEND

   SetBalloon( .T. )

RETURN
//----------------------------------------------------------------------------//



xTRich.prg

// Win32 RichEdit Control support

#include "FiveWin.ch"
#include "Constant.ch"
#include "WColors.ch"
#include "RichEdit.ch"

#ifdef __XPP__
   #define Super ::TControl
   #define New   _New
#endif

#define CTRL_CLASS        "RichEdit20A"

#define MK_MBUTTON         16


#define WM_MBUTTONDOWN    519
#define WM_MBUTTONDBLCLK  521


#define WM_MOUSEWHEEL     522
#define WM_NCHITTEST      132  // 0x84

//----------------------------------------------------------------------------//

CLASS xTRich FROM TRichEdit

   DATA   cCargo, cKdNr

   METHOD HandleEvent( nMsg, nWParam, nLParam )

   METHOD MButtonDown( nRow, nCol, nFlags )

ENDCLASS

//----------------------------------------------------------------------------//

METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS xTRich
   local  nRow, nCol, nFlags
   do case

   case nMsg == WM_NCHITTEST


      if ::cCargo = GetWindowText( ::hWnd ) .or.  len(ALLTRIM(GetWindowText( ::hWnd )))=0

      else
         ::MButtonDown( nRow, nCol, nFlags )
         ::cCargo := GetWindowText( ::hWnd )

      endif
   case nMsg == FM_HIGHLIGHT
      return ::HighLightLine()

   case nMsg == FM_HIGHLIGHTALL
      return ::HighlightAllText()

   case nMsg == WM_KEYDOWN
      if ::lReadOnly
         if ( nWParam == Asc( "E" ) .or. nWParam == Asc( "L" ) .or. ;
               nWParam == Asc( "J" ) .or. nWParam == Asc( "R" ) ) .and. ;
               GetKeyState( VK_CONTROL )

            return 0
         endif
      endif

      return ::KeyDown( nWParam, nLParam )

   otherwise
      if( nMsg == WM_MOUSEWHEEL .or. nMsg == WM_MBUTTONDOWN .or. ;
         nMsg == WM_MBUTTONDBLCLK )

      if GetKeyState( VK_CONTROL )
         return 0
      endif
   else
      Super:HandleEvent( nMsg, nWParam, nLParam )
   endif
endcase

return nil

//----------------------------------------------------------------------------//

METHOD MButtonDown( nRow, nCol, nKeyFlags ) CLASS xTRich

   Super:MButtonDown( nRow, nCol, nKeyFlags )

   ::PostMsg( FM_CHANGE )

return nil

//----------------------------------------------------------------------------//


testdrop.rc

// RESOURCE SCRIPT generated by "Pelles C for Windows, version 4.50".

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>

LANGUAGE LANG_GERMAN,SUBLANG_GERMAN_AUSTRIAN

SCANNER DIALOGEX DISCARDABLE 18, 19, 254, 257
STYLE WS_POPUP|DS_MODALFRAME|WS_CAPTION|WS_SYSMENU
CAPTION "Import"
FONT 10, "MS Reference Sans Serif", 400, 0, 0
BEGIN
  CONTROL "Stichwort", -1, "Static", WS_GROUP, 6, 56, 84, 8
  CONTROL "Kategorie", -1, "Static", WS_GROUP, 6, 88, 73, 8
  CONTROL "Datum", -1, "Static", WS_GROUP, 120, 9, 26, 8
  CONTROL "nachfassen", -1, "Static", WS_GROUP, 99, 22, 39, 8
  CONTROL "", 101, "Edit", WS_BORDER|WS_TABSTOP, 6, 106, 118, 12
  CONTROL "", 102, "Edit", WS_BORDER|WS_TABSTOP, 6, 70, 119, 12
  CONTROL "", 105, "Edit", WS_BORDER|WS_TABSTOP, 152, 8, 45, 12
  CONTROL "", 106, "Edit", WS_BORDER|WS_TABSTOP, 153, 22, 45, 12
  CONTROL "Abbruch", 103, "Button", WS_TABSTOP, 124, 224, 45, 14
  CONTROL "Speichern", 104, "Button", WS_TABSTOP, 72, 224, 40, 14
  CONTROL "Datei", 111, "Static", WS_GROUP, 6, 40, 240, 8
  CONTROL "", 8002, "Edit", ES_MULTILINE|ES_WANTRETURN|WS_VSCROLL|WS_BORDER|WS_TABSTOP, 4, 124, 222, 82
END

DROP DIALOGEX DISCARDABLE 6, 18, 210, 142
STYLE WS_POPUP|DS_MODALFRAME|DS_CONTEXTHELP|DS_3DLOOK|WS_CAPTION|WS_SYSMENU|WS_VISIBLE
CAPTION "Dialog"
FONT 8, "MS Sans Serif", 0, 0, 1
BEGIN
  CONTROL "OK", IDOK, "Button", WS_TABSTOP, 160, 5, 45, 15
  CONTROL "Cancel", IDCANCEL, "Button", WS_TABSTOP, 160, 23, 45, 15
  CONTROL "", 100, "RichEdit20A", ES_MULTILINE|ES_WANTRETURN|WS_VSCROLL|WS_BORDER|WS_TABSTOP, 8, 12, 102, 111
END
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: drag and drop from outlook pure FIVEWIN solution
Posted: Tue Feb 03, 2009 06:00 PM

Otto,
if I have many mail and each amil have one or many files attach how i can save all ?
My wish is to save all on a cd rom and make an fwh appl to show mails
it is possible ?

Best Regards, Saludos



Falconi Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: drag and drop from outlook pure FIVEWIN solution
Posted: Tue Feb 01, 2011 05:08 PM
Otto,
I 'm trying a test with outlook 2003
you test make error

see it pls

Code (fw): Select all Collapse
Application
===========
   Path and name: C:\Documents and Settings\Acer\Desktop\xfang\xfang.EXE (32 bits)
   Size: 2,012,672 bytes
   Time from start: 0 hours 1 mins 8 secs 
   Error occurred at: 01.02.2011, 18:09:42
   Error description: Error TOleAuto/-1  Unknown error: TOLEAUTO:NEW
   Args:
     [   1] = C   Outlook.Application

Stack Calls
===========
   Called from:  => THROW(0)
   Called from: source\rtl\win32ole.prg => TOLEAUTO:NEW(335)
   Called from: c:\winhotel\xfang\source\testole.prg => DROPREAD(27)
   Called from: c:\winhotel\xfang\source\testole.prg => (b)MAIN(15)
   Called from: .\source\classes\WINDOW.PRG => TRICHEDIT:MBUTTONDOWN(0)
   Called from: c:\winhotel\xfang\xtrich.prg => XTRICH:MBUTTONDOWN(89)
   Called from: c:\winhotel\xfang\xtrich.prg => XTRICH:HANDLEEVENT(41)
   Called from: .\source\classes\WINDOW.PRG => _FWH(0)
   Called from:  => DIALOGBOX(0)



any Idea and solution ?
Best Regards, Saludos



Falconi Silvio
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: drag and drop from outlook pure FIVEWIN solution
Posted: Tue Feb 01, 2011 06:25 PM

Hello Silvio,

2003 is a very old program and it seems there is a problem with ActiveX.

Best regards,
Otto

Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: drag and drop from outlook pure FIVEWIN solution
Posted: Tue Feb 01, 2011 11:21 PM

and wichversion I can use ?

I have 2002/2003
on 2002 run ok
I not have 2010 and 2007

Best Regards, Saludos



Falconi Silvio
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: drag and drop from outlook pure FIVEWIN solution
Posted: Thu Nov 18, 2021 12:23 PM

Mister Otto, this program has not been updated? And what resource editor did you use to create the dialog? Thanks.

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: drag and drop from outlook pure FIVEWIN solution
Posted: Thu Nov 18, 2021 01:07 PM

Hello Joao,
This is a very old program (2008 or earlier) but we use it every day with all customers.
I'm searching for the source code and will post a new example.

I am also working on a program to manage the emails.
At the moment, everything is "floating".
For the email desktop we need the following components:

Document management

viewtopic.php?f=3t=33215p=234030hilit=emaildesktopsid=e2b0dce5f3903132a02fba860b1c3e30#p234030

time schedule system

viewtopic.php?f=45t=40227p=240418sid=1ea92eda63070d635accaf15daba8216#p240418

and the full-text search.

viewtopic.php?f=45t=41010p=245572hilit=fulltextsearchsid=7f88cb40a93b3ea42d3466c73357f4ff#p245572

The individual parts now work so far, and we have to merge them into a program.

Best regards,
Otto

&&&&&&&&&&&

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: drag and drop from outlook pure FIVEWIN solution
Posted: Thu Nov 18, 2021 02:40 PM

Thanks Mister Otto, as soon as possible I'll test this with Outlook. Get ready because I'll call you, is that okay with you? Although about outlook, I don't understand anything.

Gracias señor Otto, lo antes posible probaré esto con Outlook. Prepárate porque te llamaré, ¿te parece bien? Aunque sobre Outlook, no entiendo nada.

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: drag and drop from outlook pure FIVEWIN solution
Posted: Thu Nov 18, 2021 10:54 PM
hi Silvio,
Silvio wrote:if I have many mail and each amil have one or many files attach how i can save all ?
My wish is to save all on a cd rom and make an fwh appl to show mails
it is possible ?

you have this Code now
Code (fw): Select all Collapse
   oOutlook       := TOleAuto():New( "Outlook.Application" )
   myOlExp        := oOutlook:ActiveExplorer
   oMail := myOlExp:Selection:Item(1)


now enhance with
Code (fw): Select all Collapse
   oAttachment := oMail:Attachments
   nCount      := oAttachment:Count
   FOR i := 1 TO nCount
       oItem := oAttachment:Item(i)
       cName := oItem:DisplayName
       oItem:SaveAsFile(cName)


Note ! you need to "wait" until files is "real saved" before do next else i can be "corrupt"

so i "test" File Size
Code (fw): Select all Collapse
        SLEEP(10)
        DO WHILE .T.
           aDir := Directory(cTemp)
           // wait until file size was uodate
           IF aDir[1][F_SIZE] > 100
               nBytes := aDir[1][F_SIZE]
               EXIT
           ENDIF
           SLEEP(10)
        ENDDO
greeting,

Jimmy
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: drag and drop from outlook pure FIVEWIN solution
Posted: Mon Nov 22, 2021 09:06 AM

Sorry,
I not have this source code
I made it many years ago I not Know where It can be

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion