How to Create a Standard Editing Control Toolbar
  
PSS ID Number: Q139598
Article last modified on 11-15-1995
 
3.00
 
WINDOWS
 

---------------------------------------------------------------------
The information in this article applies to:
 
 - Microsoft Visual FoxPro for Windows, version 3.0
---------------------------------------------------------------------
 
SUMMARY
=======
 
Many Windows applications have a toolbar with a series of buttons to
perform common editing functions such as cut, copy, and paste. In  Visual
FoxPro, you can create a custom toolbar with these editing functions.
 
You can then incorporate this toolbar into new or existing Visual FoxPro
applications.
 
MORE INFORMATION
================
 
Using functions in the Foxtools library, a custom toolbar class can be
created to perform standard editing functions. The following code creates a
toolbar object with buttons that perform cut, copy, paste, undo, and redo
editing functions. The toolbar uses .bmp files that are located in the
Vfp\Samples\Graphics\Bmps\Fox directory. These .bmp files must be available
in order for the pictures to appear on the toolbar buttons.
 
NOTE: For backward compatibility, Visual FoxPro still supports FOXTOOLS.FLL
(included in earlier FoxPro versions), the Visual FoxPro API library that
allows calls to 16-bit .DLL functions. However, in Visual FoxPro, the
DECLARE command is the preferred method for calling .DLL functions.
 
   PUBLIC oEditBar
 
   oEditBar=CreateObject('editbar')
   oEditBar.Visible=.t.
 
   DEFINE CLASS editbar AS toolbar
 
       Caption = "Edit Controls"
       Height = 30
       Left = 0
       Top = 0
       Width = 132
       Name = "editbar"
 
       ADD OBJECT cmdcut AS commandbutton WITH ;
           Top = 4, ;
           Left = 6, ;
           Height = 23, ;
           Width = 24, ;
           Picture = "cut.bmp", ;
           Caption = "", ;
           Default = .F., ;
           ToolTipText = "Cut", ;
           Name = "cmdCut"
 
       ADD OBJECT cmdcopy AS commandbutton WITH ;
           Top = 4, ;
           Left = 29, ;
           Height = 23, ;
           Width = 24, ;
           Picture = "copy.bmp", ;
           Caption = "", ;
           Default = .F., ;
           ToolTipText = "Copy", ;
           Name = "cmdCopy"
 
       ADD OBJECT cmdpaste AS commandbutton WITH ;
           Top = 4, ;
           Left = 52, ;
           Height = 23, ;
           Width = 24, ;
           Picture = "paste.bmp", ;
           Caption = "", ;
           Default = .F., ;
           ToolTipText = "Paste", ;
           Name = "cmdPaste"
 
       ADD OBJECT separator1 AS separator WITH ;
           Top = 4, ;
           Left = 81, ;
           Height = 0, ;
           Width = 0, ;
           Name = "Separator1"
 
       ADD OBJECT cmdundo AS commandbutton WITH ;
           Top = 4, ;
           Left = 81, ;
           Height = 23, ;
           Width = 24, ;
           Picture = "undo.bmp", ;
           Caption = "", ;
           Default = .F., ;
           ToolTipText = "Undo", ;
           Name = "cmdUndo"
 
       ADD OBJECT cmdredo AS commandbutton WITH ;
           Top = 4, ;
           Left = 104, ;
           Height = 23, ;
           Width = 24, ;
           Picture = "redo.bmp", ;
           Caption = "", ;
           Default = .F., ;
           ToolTipText = "Redo", ;
           Name = "cmdRedo"
 
       PROCEDURE Init
           SET LIBRARY TO SYS(2004)+"FOXTOOLS.FLL"
       ENDPROC
 
       PROCEDURE cmdcut.Click
           =_EdCut(_WOnTop())
       ENDPROC
 
       PROCEDURE cmdcopy.Click
           =_EdCopy(_WOnTop())
       ENDPROC
 
       PROCEDURE cmdpaste.Click
           =_EdPaste(_WOnTop())
       ENDPROC
 
       PROCEDURE cmdundo.Click
           =_EdUndo(_WOnTop())
       ENDPROC
 
       PROCEDURE cmdredo.Click
           =_EdRedo(_WOnTop())
       ENDPROC
 
   ENDDEFINE
 
To remove the toolbar, release the object with the command:
 
   RELEASE oEditBar
 
Additional reference words: 3.00 VFoxWin tool bar toolbox tool box
KBCategory: kbprg kbui kbhowto kbcode
KBSubcategory: FxprgToolbar
=============================================================================
Copyright Microsoft Corporation 1995.
