On Dropfiles

On Dropfiles

Postby MarcoBoschi » Fri Mar 05, 2010 2: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
User avatar
MarcoBoschi
 
Posts: 1015
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: On Dropfiles

Postby Antonio Linares » Sat Mar 06, 2010 8:58 am

Marco,

Your example modified to do it :-)
Code: Select all  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: On Dropfiles

Postby MarcoBoschi » Sat Mar 06, 2010 4: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
User avatar
MarcoBoschi
 
Posts: 1015
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: On Dropfiles

Postby MarcoBoschi » 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
User avatar
MarcoBoschi
 
Posts: 1015
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: On Dropfiles

Postby nageswaragunupudi » 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: Select all  Expand view

#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
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: On Dropfiles

Postby Otto » 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: Select all  Expand view
/*
##############################################################################
# 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: Select all  Expand view

{{"KATEGORIE"   , "C",  50,   0}  }

 


Best regards,
Otto


Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: On Dropfiles

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: On Dropfiles

Postby MarcoBoschi » Mon Mar 08, 2010 7:49 am

nageswaragunupudi,
Many thanks! Is very for me your code!
Have a nice day
Marco
User avatar
MarcoBoschi
 
Posts: 1015
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: On Dropfiles

Postby MarcoBoschi » Mon Mar 08, 2010 8:40 am

Thank you Otto!
User avatar
MarcoBoschi
 
Posts: 1015
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: On Dropfiles

Postby Antonio Linares » Mon Mar 08, 2010 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 97 guests