Microsoft KB Archive/139598

How to Create a Standard Editing Control Toolbar

PSS ID Number: Q139598 Article last modified on 11-15-1995

3.00

WINDOWS

= 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 Vfpdirectory. 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 = &quot;Edit Controls&quot; Height = 30 Left = 0 Top = 0 Width = 132 Name = &quot;editbar&quot;

ADD OBJECT cmdcut AS commandbutton WITH ; Top = 4, ; Left = 6, ; Height = 23, ; Width = 24, ; Picture = &quot;cut.bmp&quot;, ; Caption = &quot;&quot;, ; Default = .F., ; ToolTipText = &quot;Cut&quot;, ; Name = &quot;cmdCut&quot;

ADD OBJECT cmdcopy AS commandbutton WITH ; Top = 4, ; Left = 29, ; Height = 23, ; Width = 24, ; Picture = &quot;copy.bmp&quot;, ; Caption = &quot;&quot;, ; Default = .F., ; ToolTipText = &quot;Copy&quot;, ; Name = &quot;cmdCopy&quot;

ADD OBJECT cmdpaste AS commandbutton WITH ; Top = 4, ; Left = 52, ; Height = 23, ; Width = 24, ; Picture = &quot;paste.bmp&quot;, ; Caption = &quot;&quot;, ; Default = .F., ; ToolTipText = &quot;Paste&quot;, ; Name = &quot;cmdPaste&quot;

ADD OBJECT separator1 AS separator WITH ; Top = 4, ; Left = 81, ; Height = 0, ; Width = 0, ; Name = &quot;Separator1&quot;

ADD OBJECT cmdundo AS commandbutton WITH ; Top = 4, ; Left = 81, ; Height = 23, ; Width = 24, ; Picture = &quot;undo.bmp&quot;, ; Caption = &quot;&quot;, ; Default = .F., ; ToolTipText = &quot;Undo&quot;, ; Name = &quot;cmdUndo&quot;

ADD OBJECT cmdredo AS commandbutton WITH ; Top = 4, ; Left = 104, ; Height = 23, ; Width = 24, ; Picture = &quot;redo.bmp&quot;, ; Caption = &quot;&quot;, ; Default = .F., ; ToolTipText = &quot;Redo&quot;, ; Name = &quot;cmdRedo&quot;

PROCEDURE Init SET LIBRARY TO SYS(2004)+&quot;FOXTOOLS.FLL&quot; 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.