[futurebasic] Re: [FB] Drag and Drop - Problem with Drag Track Proc

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 2010 : Group Archive : Group : All Groups

From: Rich Love <carnationsoftware@...>
Date: Thu, 16 Dec 2010 11:43:58 -0600
I am sure the info is there somewhere but I am not having any luck finding it.

Rich

On Dec 16, 2010, at 10:14 AM, fblistserve@... wrote:

> Rich, I'm travelling and don't have access to FB but there is a slightly different syntax for PROC - see FBtoC Help. There is no reason to believe anything with DND toolboxes has changed. The "Unknown Function" message is from the translator saying it doesn't know about that function ( i.e. it isn't defined or prototyped ). The proc help ( mentioned above ) should say the label must precede the use of proc. I haven't examined this code since I'm doing this via webmail, but it sounds like a possibility to investigate.
> 
> Brian S.
> ---- Rich Love <carnationsoftware@...> wrote: 
>> I am guessing that is not the problem.
>> I am using procs in another app with the current version of FBtoC with no problems (those are not drag manager related though)
>> 
>> 
>> It seems like there is a problem with the drag manager toolbox?
>> 
>> Rich
>> 
>> 
>> On Dec 16, 2010, at 7:17 AM, Edwards, Waverly wrote:
>> 
>>> I don't think "proc" is valid any longer.  You could change the old
>>> 
>>> "Drag Track Proc"
>>> enterproc SomeCallbackName ...
>>> exitproc 
>>> 
>>> to 
>>> 
>>> local fn SomeCallbackName...
>>> end fn
>>> 
>>> You'll also need to change references such as this
>>> 
>>> gTrackProc = Fn NewDragTrackingHandlerUPP( [gTrackProc + _FBprocToProcPtrOffset] )
>>> 
>>> to reflect the updated syntax like this
>>> 
>>> gTrackProc = @fn SomeCallbackName
>>> 
>>> 
>>> I'm sure it's in the manual, though I don't have access to it now.
>>> 
>>> 
>>> W.
>>> -----Original Message-----
>>> From: futurebasic@... [mailto:futurebasic@...] On Behalf Of Rich Love
>>> Sent: Thursday, December 16, 2010 7:44 AM
>>> To: futurebasic@...
>>> Subject: [FB] Drag and Drop - Problem with Drag Track Proc
>>> 
>>> This code was posted on 11/17/07 by Lake Group
>>> I am trying to get it to work in the current version of FBtoC
>>> 
>>> For some reason, it will not recognize that the Drag Proc is there.
>>> I get the following error:
>>> 
>>> Error: ** Unknown function in line 197 of Drag and Drop.main: Drag Track Proc
>>> 197:  gTrackProc = Proc "Drag Track Proc"
>>>                                                               ^
>>> 
>>> Here is the code that Lake Group posted
>>> (I have made a couple of minor changes to get it to run in the current version of FB, but have not made any changes to the drag proc)
>>> 
>>> Rich
>>> 
>>> 
>>> #IF DEF _usingLiteRuntime
>>> PRINT "Sorry!"
>>> PRINT "This program will not work in the console runtime."
>>> PRINT "Select Standard BASIC or Appearance Compliant from the Command menu."
>>> #ELSE
>>> 
>>> Include "Tlbx DragMgr.Incl"
>>> Include "Tlbx Files.Incl"
>>> 
>>> Begin Globals
>>> Dim Dynamic    gFiles(_maxInt) As FSSpec ' dynamic array of FSSpecs
>>> Dim As Proc    gTrackProc, gRecvProc' Drag & Drop procedures
>>> Dim As Boolean gCanAccept
>>> End Globals
>>> 
>>> 
>>> 
>>> /*
>>>   This function will grab the content of a given folder
>>>   and fill up a dynamic array of FSSpecs. It returns
>>>   the number of files retrieved.
>>> 
>>> */
>>> Clear Local
>>> 
>>> Local Fn GetFilesInFolder ( fldSpec As .FSSpec )
>>> '~'1
>>> Dim index As Int
>>> Dim fName As Str63
>>> Dim pb.80' HParamBlockRec is not defined
>>> 
>>> Kill Dynamic gFiles' reinitialize the dynamic array
>>> index = 1
>>> Do
>>> pb.ioFDirIndex%  = index
>>> pb.ioNamePtr&    = @fName
>>> pb.ioVRefNum%    = fldSpec.vRefNum
>>> pb.ioDirID&      = fldSpec.parID
>>> If Fn PBHGetFInfoSync( pb ) Then Exit Do' exit if error
>>> gFiles.name( index )    = fName
>>> gFiles.vRefNum( index ) = fldSpec.vRefNum
>>> gFiles.parID( index )   = fldSpec.parID
>>> index++' next file
>>> Until _nil
>>> Compress Dynamic gFiles
>>> 
>>> End Fn// = [@gFiles + _AutoXREFCurr] - 1' number of files retrieved
>>> 
>>> /*
>>>   This function displays some info about the files
>>>   stored in the dynamic array of FSSpecs
>>> */
>>> Local Fn ShowFiles( folderSpec As .FSSpec )
>>> '~'1
>>> Dim As Int    numberOfFiles, i
>>> Dim As FSSpec thisSpec
>>> Dim As FInfo  info
>>> 
>>> numberOfFiles = Fn GetFilesInFolder( folderSpec )' set up the dynamic array of FSSpecs and get the number of files
>>> Long If numberOfFiles
>>> For i = 1 To numberOfFiles
>>> thisSpec = gFiles( i )' copy spec from dynamic array to local FSSpec
>>> Long If Fn FSpGetFInfo( thisSpec, info ) = _noErr
>>> Print thisSpec.name, Mki$( info.fdType ), Mki$( info.fdCreator )
>>> End If
>>> Next
>>> End If
>>> 
>>> End Fn
>>> 
>>> 
>>> /*
>>>   This function tells if a given FSSpec refers to a folder
>>> */
>>> Clear Local Mode
>>> Local Fn FSSpecIsAFolder( fSpec As .FSSpec )
>>> '~'1
>>> Dim As Int        err
>>> Dim As Boolean  @ isFolder, wasAlis
>>> 
>>> err = Fn ResolveAliasFile( #fSpec, _true, isFolder, wasAlis )
>>> End Fn = isFolder
>>> 
>>> /*
>>>   This function is called when an item is dropped in
>>>   the main's window content area.
>>> */
>>> 
>>> Clear Local
>>> Local Fn DNDrecvProc( wPtr As Ptr, refCon As Unsigned Long, theDrag As Unsigned Long )
>>> '~'1
>>> Dim As Int              result, err
>>> Dim As Unsigned Long  @ theItem, size
>>> Dim As Boolean        @ isFolder, wasAlis
>>> Dim As HFSFlavor        flavor
>>> Dim As FSSpec           dropFld
>>> Dim pb.128
>>> result = _UserCanceledErr
>>> If gCanAccept = _false Then exit Fn
>>> 
>>> 
>>> size = Sizeof( HFSFlavor )
>>> Long If Fn GetDragItemReferenceNumber( theDrag, 1, theItem ) = _noErr
>>> Long If Fn GetFlavorData( theDrag, theItem, _"hfs ", flavor, size, 0 ) = _noErr
>>> Long If flavor.fdFlags And 32768
>>> err = Fn ResolveAliasFile( flavor.fileSpec, _true, isFolder, wasAlis )
>>> End If
>>> // Robert P. modification here:
>>> pb.ioNamePtr = @flavor.fileSpec.name
>>> pb.ioVRefNum = flavor.fileSpec.vRefNum
>>> pb.ioDirID   = flavor.fileSpec.parID
>>> pb.ioFDirIndex = 0 // get dirID of this directory
>>> err = fn PBGetCatInfoSync( @pb )
>>> dropFld.vRefNum = pb.ioVRefNum
>>> dropFld.parID   = pb.ioDirID
>>> dropFld.name    = ""
>>> fn ShowFiles( dropFld )
>>> End If
>>> End If
>>> result = _noErr
>>> 
>>> End Fn = result
>>> 
>>> /*
>>>   This function is called during a drag operation
>>> */
>>> Clear Local
>>> Local Fn DNDtrackProc( dragMsg As Int, wPtr As Ptr, refConPtr As Ptr, theDrag As Unsigned Long )
>>> '~'1
>>> Dim As handle           tmpRgn
>>> Dim As Unsigned Long  @ attributes, flavorFlags, theItem, size
>>> Dim As Unsigned short @ count
>>> Dim As HFSFlavor        flavor
>>> 
>>> If Fn GetDragAttributes( theDrag, attributes ) != _noErr Then exit Fn
>>> 
>>> Select dragMsg
>>> 
>>> Case _kDragTrackingEnterWindow,_kDragTrackingLeaveWindow
>>> gCanAccept = _false
>>> Long If Fn CountDragItems( theDrag, count ) = _noErr
>>> Long If count
>>> Long If Fn GetDragItemReferenceNumber( theDrag, 1, theItem ) = _noErr
>>> Long If Fn GetFlavorFlags( theDrag, theItem, _"hfs ", flavorFlags ) = _noErr
>>> size = Sizeof( HFSFlavor )
>>> Long If Fn GetFlavorData( theDrag, theItem, _"hfs ", flavor, size, 0 ) = _noErr
>>> gCanAccept = Fn FSSpecIsAFolder( flavor.fileSpec )
>>> End If
>>> End If
>>> End If
>>> End If
>>> End If
>>> 
>>> 
>>> Long If gCanAccept
>>> #If CarbonLib
>>> wPtr = Fn GetWindowPort( wPtr )
>>> #Endif
>>> tmpRgn = Fn NewRgn
>>> Long If tmpRgn
>>> RectRgn( tmpRgn, wPtr.portRect& )
>>> count = Fn ShowDragHilite( theDrag, tmpRgn, (dragMsg = _kDragTrackingEnterWindow))
>>> DisposeRgn( tmpRgn )
>>> End If
>>> 
>>> Long If dragMsg = _kDragTrackingEnterWindow
>>> Cursor _plusCursor
>>> Xelse
>>> Cursor _arrowCursor
>>> End If
>>> End If
>>> 
>>> End Select
>>> 
>>> End Fn = _noErr
>>> 
>>> 
>>> 
>>> 
>>> /*
>>>   This function installs the tracking and receive procedures
>>>   in the main window.
>>> */
>>> #If Ndef _gestaltDragMgrPresent
>>> _gestaltDragMgrPresent = 0
>>> #Endif
>>> 
>>> Clear Local
>>> Local Fn InstallDD( wnd As Long )
>>> '~'1
>>> Dim @ temp As Long, wPtr As Ptr
>>> 
>>> Long If Fn Gestalt(_"drag", temp ) = _noErr
>>> Long If temp And _gestaltDragMgrPresent%
>>> If wnd Then Get Window wnd,wPtr
>>> 
>>> gTrackProc = Proc "Drag Track Proc"
>>> gRecvProc  = Proc "Drag Rec Proc"
>>> #If CarbonLib
>>> gTrackProc = Fn NewDragTrackingHandlerUPP( [gTrackProc + _FBprocToProcPtrOffset] )
>>> gRecvProc  = Fn NewDragReceiveHandlerUPP( [gRecvProc + _FBprocToProcPtrOffset] )
>>> #ENDIF
>>> Long If Fn InstallTrackingHandler( gTrackProc, wPtr, #_nil ) = _noErr
>>> Long If Fn InstallReceiveHandler( gRecvProc  , wPtr, #_nil ) != _noErr
>>> temp = Fn RemoveTrackingHandler( gTrackProc, wPtr )
>>> End If
>>> End If
>>> End If
>>> End If
>>> End Fn
>>> 
>>> /*
>>>   This function remove the tracking and receive procedures
>>>   installed in the main window.
>>> */
>>> Clear Local
>>> Local Fn RemoveDD( wnd As Long )
>>> '~'1
>>> Dim @ temp As Long, wPtr As Ptr
>>> 
>>> Long If Fn Gestalt( _"drag", temp ) = _noErr
>>> Long If temp And _gestaltDragMgrPresent%
>>> If wnd Then Get Window wnd,wPtr
>>> temp = Fn RemoveTrackingHandler( gTrackProc, wPtr )
>>> temp = Fn RemoveReceiveHandler( gRecvProc , wPtr )
>>> End If
>>> End If
>>> End Fn
>>> 
>>> 
>>> '~Main
>>> 
>>> gFBUseNavServices = _zTrue' needed for _FSSpecFolder
>>> 
>>> Dim fldSpec As FSSpec
>>> 
>>> Window 1
>>> Fn InstallDD( 1 )' install Drag & Drop in window #1
>>> Long If Len( Files$( _FSSpecFolder, , ,fldSpec ) )
>>> Fn ShowFiles( fldSpec )
>>> End If
>>> 
>>> Do
>>> HandleEvents
>>> Until gFBQuit
>>> 
>>> Kill Dynamic gFiles
>>> Fn RemoveDD( 1 )
>>> End
>>> 
>>> '~Procs
>>> /*
>>>   Callback procedures for Drag & Drop
>>> */
>>> Goto "Skip DD procs"
>>> 
>>> #If Def _useFBdbugger
>>> Troff
>>> #Endif
>>> "Drag Rec Proc"
>>> Enterproc Fn Drag_Rec_Proc(dragWindPtr As Ptr,dragRefCon As Ptr,aDrag As Unsigned Long) = word
>>> Exitproc = Fn DNDrecvProc(dragWindPtr,dragRefCon,aDrag)
>>> 
>>> "Drag Track Proc"
>>> Enterproc Fn Drag_Track_Proc(dragMsg As Int,dragWindPtr As Ptr,dragRefCon As Ptr,aDrag As Unsigned Long) = word
>>> Exitproc = Fn DNDtrackProc(dragMsg,dragWindPtr,dragRefCon,aDrag)
>>> 
>>> 
>>> "Skip DD procs"
>>> #If Def _useFBdbugger
>>> Tron
>>> #Endif
>>> 
>>> #ENDIF
>>> 
>>> --
>>> To unsubscribe, send ANY message to: futurebasic-unsubscribe@...
>>> 
>>> --
>>> To unsubscribe, send ANY message to: futurebasic-unsubscribe@...
>>> 
>> 
>> 
>> Rich Love - Carnation Software
>> Get 'Say it & Mail it' for iPhone
>> http://www.SayitMailit.com
>> 
>> MacWise Terminal emulation for Macintosh
>> http://www.CarnationSoftware.com
>> Twitter - http://twitter.com/CarnationSW
>> Email - RichLove@...
>> 512 858-9234
>> 
> 
> --
> To unsubscribe, send ANY message to: futurebasic-unsubscribe@...
> 


Rich Love - Carnation Software
Get 'Say it & Mail it' for iPhone
http://www.SayitMailit.com

MacWise Terminal emulation for Macintosh
http://www.CarnationSoftware.com
Twitter - http://twitter.com/CarnationSW
Email - RichLove@...
512 858-9234
















Attachments: