Wiki Home

Tool Bar


Namespace: Wiki
Tool Bar

Source: TNVFP 6202 Training Courseware by Jim Duffy of Take Note; Microsoft VFP6 Programmer's Guide

A Tool Bar is a set of buttons on a sizeable bar which can be docked anywhere on the main FoxPro window, or float in a window of it's own. Though a Tool Bar is not a form, it can be included in a Form Set. If you attempt to add a toolbar to an existing Form, FoxPro will prompt you to create a Form Set automatically. CAUTION: All existing properties and methods will move to the Form Set and will need to be renamed from THISFORM to THISFORMSET.

The most commonly included control in a Tool Bar is a button, but a Tool Bar can contain any type of control. The Separator control helps keep Tool Bar s neat and easy to use. Tool Bar s size themselves according to the number of controls they contain. A Tool Bar is especially useful for presenting the user with a choice of actions or preferences which are custom to the task at hand, without him having to hunt inside a menu for them. Proper planning and design of menus and toolbars will ensure that the key functionality of your applications is exposed, and that users will not become frustrated as they try to use your applications.

Of note are the Docked and Dockposition properties, the Dock() method, and the Beforedock and Afterdock events. A Tool Bar is always on top at runtime, though it is not always on top at design time.

Rather than creating a Form Set, one might prefer to create a Tool Bar class and instantiate it at runtime. The syntax of the Dock() method is

Tool Bar.Dock [nLocation [, x, y]]

and it takes the following arguments:

TOOL_NOTDOCKED && -1
TOOL_TOP && 0
TOOL_LEFT && 1
TOOL_RIGHT && 2
TOOL_BOTTOM && 3
A toolbar can get focus only if it contains a control that allows text input (text box, edit box, spinner, or combo box). -- Hackers Guide
The impact is on an edit that's been made in a control on a form. If the user clicks on a save button in a toolbar before leaving the control, the lostfocus, and valid never fire. They would need to be specifically fired in code by the toolbar save button.
There has been some discussion over whether users prefer a toolbar, menu, or hot keys for things like cut, copy, and paste. User's taste varies widely. Some like the keyboard for almost everything, and some prefer the mouse. Windows standards suggest that there be more than one way to do almost everything.
My favorite "cheezy" trick for my main application toolbar is to design the buttons and controls the way I want them in a Container and then slap the Container into the Toolbar class. This gives me total control over the layout of the Toolbar while sacrificing some flexibility. --- John Koziol
What are the benefits? --- Josť Luis Santana
Has someone improved on VFP's Print Preview Tool Bar?
I would like, as a minimum to add a button to it that does a SET PRINTER PROMPT so you can select printer, number of pages and number of copies.
How do I find out the name of this toolbar in order to modify it? Is it modifiable? Has anyone already done this?
Barbara Bartlow

Did you review the Print Range category ? Rick Schummer
The first members of the _SCREEN.Forms[] collection are always undocked toolbars. !! NOT VALID for standard VFP toolbars !!
A common way to hide and restore the standard VFP Toolbars in an application is as follows.

* Code to hide the standard toolbars

Public Array asystemtoolbars[11, 2]
asystemtoolbars[1, 1] = "Print Preview"
asystemtoolbars[2, 1] = "Report Designer"
asystemtoolbars[3, 1] = "Form Controls"
asystemtoolbars[4, 1] = "Standard"
asystemtoolbars[5, 1] = "Form Designer"
asystemtoolbars[6, 1] = "Layout"
asystemtoolbars[7, 1] = "Database Designer"
asystemtoolbars[8, 1] = "View Designer"
asystemtoolbars[9, 1] = "Report Controls"
asystemtoolbars[10, 1] = "Color Palette"
asystemtoolbars[11, 1] = "Query Designer"
asystemtoolbars[11, 1] = "View"
for l_n = 1 to 11
  if wvisible(asystemtoolbars[l_n, 1])
    asystemtoolbars[l_n, 2] = .T.
    hide window (asystemtoolbars[l_n, 1])
  endif
endfor


*Code to restore the toolbars

l_cOldErr = ON("ERROR")
ON ERROR *
local l_n
for l_n = 1 to 11
  if not wvisible(asystemtoolbars[l_n, 1]) and ;
    asystemtoolbars[l_n, 2]
    show window (asystemtoolbars[l_n, 1])
  endif
endfor
ON ERROR &l_cOldErr

Data Environment Classes
Contributor: Cindy Winegarden, William Fields
Category VFP Controls Category Exam 70-155 Hot Topic Category Code Samples
( Topic last updated: 2010.12.19 04:01:28 PM )