Wiki Home

Tool Box


Namespace: VFP
The Tool Box is a fully user customizable feature of the VFP 8.0 IDE. With this control you will turn off your Class Designer and Form Designer tool bars.

From the tool box you can drag and drop classes to the class designer, form designer and any edit window. The tool box is data driven so you can add your class libraries to it, the classes of your framework, etc.

It's not limited to VFP classes either...

Definitely one of the best new IDE feature in this Version!
Here is one way of putting code/comments into a PRG, or Method using the Tool Box.
Add a Script to one of the sections, (right click the Tool Box, Customize Tool Box)

Place the following code into the "Complete drag script:" editbox.

* Get the caption of the window the mouse is over
cWindow = MWINDOW()

* Save the mouse position within the window
nRow = MROW(cWindow)
nCol = MCOL(cWindow)

* Build the text to input into the window
*!* DO FORM "C:\work\vfp8\test\procedureheader" TO cInput
cInput = INPUTBOX("Type comment:",PROPER(cWindow))


* Activate the window
ACTIVATE WINDOW (cWindow)

* Position the cursor
MOUSE CLICK WINDOW (cWindow) AT nRow,nCol

* Save the contents of the Windows clipboard
cClip = _ClipText

* Put the text onto the Windows clipboard
_ClipText = cInput

* Paste the text
KEYBOARD "{CTRL+V}"

* Wait until the key has been registered
DO WHILE CHRSAW()
   * Force Windows event
   DOEVENTS
ENDDO

* Reset the Windows clipboard
* If text was on the clipboard, it is restored here
* If an object, or other type it is blanked
_ClipText = cClip


This gets text from the InputBox, and sends the results where the left drag stopped. Also, you could launch a form. - Tracy Pearson
I worked with this some more. After scanning the default scripts in IntelliSense I found a way to keep the clipboard in tact. Also, the main bulk of what needs to happen is in a re-usable class. - Tracy Pearson
LOCAL loToolBox
loToolBox = CREATEOBJECT('DragScript')  && or use NewObject()
loToolBox.Start()


DEFINE CLASS DragScript as ToolBoxPostDragScript

   PROCEDURE Main()
      * Build the text to input into the window
      * you can even call a form here
      *!* DO FORM "C:\work\builders\procedureheader" TO cInput
      * Get the caption of the window the mouse is over
      cWindow = MWINDOW()
      This.cInput = INPUTBOX("Type comment:",PROPER(cWindow))
   ENDPROC

ENDDEFINE


*- Put this class where you want it
*- in a prg or even in the _ToolBox ClassLib
DEFINE CLASS ToolBoxPostDragScript AS Custom

   cInput = ""

   PROCEDURE Start()
      LOCAL lcFxToolLib, lcWindow, lnRow, lnCol, lnWinHdl
      * Prep
      lcfxtoollib = SYS(2004)+"FOXTOOLS.FLL"
      * If the file can not be found, let's not do this
      IF !FILE(lcfxtoollib)
         RETURN .F.
      ENDIF
      SET LIBRARY TO (m.lcfxtoollib) ADDITIVE

      * Get the caption of the window the mouse is over
      lcWindow = MWINDOW()

      * Save the mouse position within the window
      lnRow = MROW(lcWindow)
      lnCol = MCOL(lcWindow)

      * Activate the window
      ACTIVATE WINDOW (lcWindow)

      * Position the cursor
      MOUSE CLICK WINDOW (lcWindow) AT lnRow,lnCol
      * Make sure the window postion moves before writing the text
      DOEVENTS FORCE

      * Get the text to insert
      This.Main()

      * Paste the text
      lnWinHdl = _WONTOP()
      _wselect(lnWinHdl)
      _EdInsert(lnWinHdl,This.cInput,len(This.cInput))

   ENDPROC
   PROCEDURE Main()

   ENDPROC

ENDDEFINE


a-jeffle said on 20050302 - Tracy, I can't get this to work at all in VFP9. Maybe it's been depricated in 9. I see text templates for Dragging, but I don't see any "Complete drag script" editboxes. What it's doing is simply dragging the text (your code) into the form or prg. Help?

Make sure you choose Script as the item type when you add the new item.-- Tamar Granor
Get a reference to the Toolbox object with _otoolbox and then change the toolbox table. You can then have a shared toolbox on your network or even several toolboxes for different uses. I have a table of different toolboxes that is used to create a combo list in a form that our engineers can select from. The code below is in the interactive change

loTool = _otoolbox
IF this.Value = 'Default'
  loTool.otoolboxengine.settoolboxtable (HOME(7)+'toolbox.dbf')
else
  loTool.otoolboxengine.settoolboxtable (lcPath+ALLTRIM(csrTools.ctable))
endif
loTool.Caption = 'Toolbox - '+this.Value

Category VFP 8 New Features
( Topic last updated: 2005.04.06 02:05:43 PM )