FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour On Dropfiles
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
On Dropfiles
Posted: Fri Mar 05, 2010 02:58 PM

The question is: is it possible during drop of one or more files
select an element from listbox?

Thanks in advance

Marco

include "FiveWin.ch"

FUNCTION Main()
LOCAL oWnd
LOCAL oBrw
LOCAL aItem := {"one", "two", "three", "four" }

DEFINE WINDOW oWnd FROM 100 , 100 TO 205 , 205 PIXEL

@ 1 , 1 LISTBOX oBrw ITEMS aItem OF oWnd SIZE 200 , 200 PIXEL

ACTIVATE WINDOW oWnd ON DROPFILES SENDMAIL( nRow, nCol, aFiles, aItem )

return nil

FUNCTION SENDMAIL( nRow, nCol, aFiles, aItem )
LOCAL nPos := 1
// nPos := ????????

? nRow, nCol, LEN( aFiles )
? "Element is " , aItem[nPos]

RETURN NIL

Marco Boschi
info@marcoboschi.it
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: On Dropfiles
Posted: Sat Mar 06, 2010 08:58 AM
Marco,

Your example modified to do it :-)
Code (fw): Select all Collapse
#include "FiveWin.ch"

#define LB_GETTOPINDEX     0x018E
#define LB_GETITEMHEIGHT   0x01A1

FUNCTION Main()

   LOCAL oWnd, aItem := { "one", "two", "three", "four" }, cItem, oLbx

   DEFINE WINDOW oWnd FROM 100 , 100 TO 205 , 205 PIXEL

   @ 1 , 1 LISTBOX oLbx VAR cItem ITEMS aItem OF oWnd SIZE 200 , 200 PIXEL

   ACTIVATE WINDOW oWnd ;
      ON DROPFILES SENDMAIL( nRow, nCol, aFiles, oLbx )

return nil

FUNCTION SENDMAIL( nRow, nCol, aFiles, oLbx )

   local nFirst  := oLbx:SendMsg( LB_GETTOPINDEX ) + 1
   local nHeight := oLbx:SendMsg( LB_GETITEMHEIGHT ) 
   local nAt     := Int( nRow / nHeight ) + nFirst 
   
   if nAt > 0 .and. nAt <= Len( oLbx:aItems )
      MsgInfo( "Element is: " + oLbx:aItems[ nAt ] )
   else
      MsgAlert( "No element there!" )
   endif      

RETURN NIL
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: On Dropfiles
Posted: Sat Mar 06, 2010 04:33 PM

Antonio,
thanks a lot dor your willingness.
There is another little problem.
In the listbox is not refreshed the cursor position.
Now I take a look my outlook express, for instance: If I want to move a message from In folder to another folder I cam drag with the mouse the message and scroll all items in the tree view on the left. During this operation I can see which is the selected item at the passage of the mouse.
I am probably asking too much.
Thanks a lot

Marco Boschi
info@marcoboschi.it
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: On Dropfiles
Posted: Sun Mar 07, 2010 10:17 AM
Antonio

FUNCTION SENDMAIL( nRow, oLbx, aItem )

local nFirst := oLbx:SendMsg( LB_GETTOPINDEX ) + 1
local nHeight := oLbx:SendMsg( LB_GETITEMHEIGHT )
local nAt := Int( nRow / nHeight ) + nFirst
LOCAL nPippo := aItem[1]

if nAt > 0 .and. nAt <= Len( oLbx:aItems )
oLbx:select( nAt )
else
MsgAlert( "No element there!" )
endif

RETURN NIL

Is it possible to adapt this code for twbrowse class even?

Thanks again
Marco
Marco Boschi
info@marcoboschi.it
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: On Dropfiles
Posted: Sun Mar 07, 2010 10:54 AM
I don't know how to do with WBrowse, but I can do it with XBrowse, After dropping files, the browse cursor is repositioned and number and value is retrieved. I can not make the browse scroll though.
Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "xbrowse.ch"

function Main()

   local oWnd, oBrw, oFont, n, d
   local aItem := { 'January', 'February', 'March', 'April', 'May', 'June', 'July', ;
                    'August', 'September', 'October', 'Novermber', 'December' }

   DEFINE WINDOW oWnd

   @ 0,0 XBROWSE oBrw OF oWnd ARRAY aItem AUTOCOLS CELL LINES

   oBrw:nStretchCol := 1
   oBrw:CreateFromCode()
   oWnd:oClient := oBrw

   ACTIVATE WINDOW oWnd ;
      ON DROPFILES ShowItem( nRow, nCol, aFiles, oBrw )

return nil

static function ShowItem( nRow, nCol, aFiles, oBrw )

   oBrw:SetPos( nRow - oBrw:nTop, nCol - oBrw:nLeft, .t. )
   xbrowse( { { oBrw:KeyNo(), oBrw:aCols[ 1 ]:Value } , aFiles } )

return nil
Regards



G. N. Rao.

Hyderabad, India
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: On Dropfiles
Posted: Sun Mar 07, 2010 11:05 AM
Download
http://www.atzwanger-software.com/fw/xbrdrag.zip
Marco,
I will remember having done some tests on that issue.
I have installed an older xBrowse class. Here you have to click inside the record selector to start drag.

This is my code:
Code (fw): Select all Collapse
/*
##############################################################################
# TXBrowse Demo                                                              #
# Copyright FiveTech 2002                                                    #
##############################################################################
*/

#include "FiveWin.ch"
#include "InKey.ch"
#include "xbrowse.ch"

STATIC oSay


//----------------------------------------------------------------------------//
function Main()
   local oWnd
  
  TXBrowse():lKinetic := .F.
  
   REQUEST DBFCDX
   rddsetdefault( "DBFCDX" )

   DEFINE WINDOW oWnd TITLE "New TXBrowse class (only for FWH)" ;
      MENU BuildMenu( oWnd ) MDI ;
      MENUINFO 3

   ACTIVATE WINDOW oWnd     ON INIT BasicCell( oWnd )

return nil

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

function BuildMenu( oWnd )

   local oMenu
   local cFile

   cFile := cFilePath( GetModuleFileName( GetInstance() ) ) + "readme.txt"

   MENU oMenu
      MENUITEM "Browse RDD data"
      MENU
         MENUITEM "Test xbrowse" ;
            ACTION BasicCell( oWnd )
      ENDMENU

   ENDMENU

return oMenu

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

STATIC FUNCTION BasicCell( oWnd )
    local oChild, oBrw, oBrw2 , ocol2, oCol
    local oCursor

    LOCAL aInhalt := directory("*.prg","D")

    DEFINE CURSOR oCursor RESOURCE "hand"

    DEFINE WINDOW oChild TITLE "Incremental seek & Inset style browse" MDICHILD OF oWnd
    oBrw := TXBrowse():New( oChild )
    oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROW
    oBrw:nColDividerStyle := LINESTYLE_INSET
    oBrw:nRowDividerStyle := LINESTYLE_INSET
    oBrw:bSeek            := {|c| DbSeek( Upper( c ) ) }

    oBrw:nTop     := 0
    oBrw:nLeft    := 0
    oBrw:nBottom  := 500
    oBrw:nRight   := 300

    oBrw:nRowHeight := 18

    oBrw:SetArray( ainHalt,  .T. )
    oBrw:aCols[1]:cHeader := 'Source'
    oBrw:aCols[1]:nWidth := 157

    oBrw:aCols[2]:cHeader := 'Size'
    oBrw:aCols[3]:cHeader := 'Date'

    oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROW
    oBrw:nRowDividerStyle := 4

    oBrw:lRecordSelector := .t.
    oBrw:lHScroll := .f.

    oBrw:CreateFromCode()

    SET EXCLUSIVE OFF
    USE kategorie NEW


    oBrw2 := TXBrowse():New(oChild )
    oBrw2:nMarqueeStyle := MARQSTYLE_HIGHLROW
    oBrw2:nColDividerStyle := LINESTYLE_INSET
    oBrw2:nRowDividerStyle := LINESTYLE_INSET
    oBrw2:bSeek            := {|c| DbSeek( Upper( c ) ) }
    oBrw2:lAllowRowSizing  :=.f.

    oBrw2:nTop     := 0
    oBrw2:nLeft    := 350
    oBrw2:nBottom  := 500
    oBrw2:nRight   := 900

    oBrw2:nRowHeight := 18
    oCol2            := oBrw2:AddCol()
    oCol2:cHeader    := "Kategorie"
    oCol2:bStrData   := { || kategorie->kategorie}
    oCol2:nWidth     := 146

    oBrw2:CreateFromCode()
    oBrw:oDragCursor  := oCursor

    oBrw2:bDropOver = { | uDropInfo, nRow, nCol, nKeyFlags | msginfo(kategorie->kategorie +"  "+ str( oBrw2:MouseRowPos( nRow ))    +"  "+        str(oBrw2:MouseColPos( nCol ))                  +"  "+oBrw:aArrayData[oBrw:nArrayAt,1]) }






    oBrw:bMMoved = { | nRow, nCol, nKeyFlags, lDrag | if( lDrag != nil .and. lDrag, CheckListbox( nRow, nCol, oBrw2, oBrw, nKeyFlags,oChild ),) }

    @ 1,500 SAY oSay  PROMPT " x "  PIXEL  SIZE 150, 20
      
    ACTIVATE WINDOW oChild ON INIT oBrw:SetFocus()     MAXIMIZED

RETURN NIL

function CheckListbox( nRow, nCol, oBrw, oLbx, nKeyFlags,oChild )

    local aPoint := { nRow, nCol }, nAt, cValue
    local caPointWNDGAST

    aPoint = ClientToScreen( oLbx:hWnd, aPoint )

    oSay:SetText(aPoint[ 2 ] )

    if aPoint[ 1 ] > 32768
        aPoint[ 1 ] -= 65535
    endif
    if aPoint[ 2 ] > 32768
        aPoint[ 2 ] -= 65535
    endif
    if WindowFromPoint( aPoint[ 2 ], aPoint[ 1 ] ) == oBrw:hWnd
        ScreenToClient( oBrw:hWnd, aPoint )
       * IF     aPoint[ 2 ]  < 120    // exclude scrollbar

            IF    aPoint[ 1 ]  > 500-19
                oBrw:PageDown(1 )
            elseif  aPoint[ 1 ]  < 19
                oBrw:PageUp(1 )
            else
                  if oBrw:MouseRowPos( aPoint[ 1 ]) > 0
                    oBrw:LButtonDown(aPoint[ 1 ], nCol, nKeyFlags )
                endif
            ENDIF
       * ENDIF
    endif


return nil



You need a kategorie.dbf.

Code (fw): Select all Collapse
{{"KATEGORIE"   , "C",  50,   0}  }


Best regards,
Otto


Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: On Dropfiles
Posted: Sun Mar 07, 2010 12:24 PM

Mr Otto
This logic does not help when dropping files from outside the FW application over the FW Window. oBrw:bMMoved does not get any message.

May be Mr. Antonio can suggest a way, if we can track the mouse movement till the files are finally dropped.

Regards



G. N. Rao.

Hyderabad, India
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: On Dropfiles
Posted: Mon Mar 08, 2010 07:49 AM

nageswaragunupudi,
Many thanks! Is very for me your code!
Have a nice day
Marco

Marco Boschi
info@marcoboschi.it
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: On Dropfiles
Posted: Mon Mar 08, 2010 08:40 AM

Thank you Otto!

Marco Boschi
info@marcoboschi.it
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: On Dropfiles
Posted: Mon Mar 08, 2010 08:57 AM

Dear Rao,

Maybe a solution is to capture the mouse so we get the mouse move events

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion