4.3.11 Miscellaneous buttons

Miscellaneous buttons

I can't count the number of times I've created OK and Cancel buttons among other standard buttons. In this foundation class category, you'll find a number of buttons, some performing standard tasks, others invoking foundation classes described in other sections.

Cancel Button

Class

_cmdCancel

Base class

CommandButton

Class library

_miscbtns.vcx

Parent class

_cmdOK

Sample

...\Samples\Vfp98\Solution\Ffc\buttons.scx

Dependencies

_base.vcx

The Cancel Button is a subclass of the OK Button (see below). There is nothing special about this button. The only difference between it and the OK Button is its caption.

Help Button

Class

_cmdHelp

Base class

CommandButton

Class library

_miscbtns.vcx

Parent class

_commandbutton

Sample

...\Samples\Vfp98\Solution\Ffc\buttons.scx

Dependencies

_base.vcx

This button, when clicked, displays the online help. It automatically shows the help topic that is referenced by ID in the HelpContextID property of this class. It works with old-fashioned help files as well as HTML Help.

Launch Button

Class

_cmdLaunch

Base class

CommandButton

Class library

_miscbtns.vcx

Parent class

_commandbutton

Sample

...\Samples\Vfp98\Solution\Ffc\buttons.scx

Dependencies

_base.vcx

The Launch Button executes a Visual FoxPro application (APP) or any other Windows executable (EXE) specified in the cFileName property. FoxPro applications are executed directly using macro evaluation, while Windows EXEs are fired up using the RUN command.

OK Button

Class

_cmdOK

Base class

CommandButton

Class library

_miscbtns.vcx

Parent class

_commandbutton

Sample

...\Samples\Vfp98\Solution\Ffc\buttons.scx

Dependencies

_base.vcx

The OK button is rather simple. It simply releases the current form or formset. If you want your OK button to do something special before the form is released, you have to add some code to the Click() event of the OK button. Here's an example:

THISFORM.Save()
DoDefault()

Note that the DoDefault() is called at the end. This makes sure that nothing is released before the custom action takes place.

Run Form Button

Class

_cmdRunForm

Base class

CommandButton

Class library

_miscbtns.vcx

Parent class

_commandbutton

Sample

...\Samples\Vfp98\Solution\Ffc\buttons.scx

Dependencies

_base.vcx

The Run Form button executes the Visual FoxPro form specified in the cFileName property. By default, the button's caption is set to the specified file name. The width of the button is automatically adjusted according to the length of the file name. This often ends up looking awkward. For this reason I recommend turning off this behavior by setting the lSetCaption property to .F.

Run Report Button (Preview Report)

Class

_cmdRunReport

Base class

CommandButton

Class library

_miscbtns.vcx

Parent class

_commandbutton

Sample

...\Samples\Vfp98\Solution\Ffc\buttons.scx

Dependencies

_base.vcx, _reports.vcx, _reports.h

The Run Report Button foundation class executes the report specified in the cFileName property. Similar to the Run Form Button class, this button adjusts its size and caption according to the specified file name unless you set the lSetCaption property to .F.

Printing a report is not as trivial as running a form or an application. For this reason, this class is slightly more complex than the two classes introduced above. The main difference is that printing a report might require an Output dialog that specifies the output media and the output format (see Figure 30). Many of the button's properties are used to configure this dialog.

Figure 30. The Output dialog used by the Run Report button. Some of the displayed groups are optional and can be turned off.

The lUseOutputDialog property specifies whether you want to display a dialog before printing. The dialog class can be specified through the cDialogClass and cDialogClassLib properties. By default, the Report Output object is used as the Print dialog (see below). Many of this object's properties are specific to this Output dialog, such as lOutputDialogPreventScope, lOutputDialogPreventSource and lPromptForReport. Those properties specify whether the user can change the report scope, source and layout file.

Send Mail Buttons

Class

_mailbtn

Base class

Container

Class library

_miscbtns.vcx

Parent class

_container

Sample

...\Samples\Vfp98\Solution\Ffc\buttons.scx

Dependencies

_base.vcx, MS MAPI Session ActiveX Control, MS MAPI Message ActiveX Control

The Send Mail Button creates a new e-mail message based on the current record and sends it using Mail Application Interface (MAPI) services. Typically, this means that Microsoft Outlook or Outlook Express is used to send the mail. The Send Mail button does not allow you to specify a receiver address or anything similar. It brings up the default mail client and requires the user to specify this information (see Figure 31).

The button will display an error message if there was no valid data source, or if the record pointer is at the end of the file.

Figure 31. The default MAPI mail client (in this case Microsoft Outlook 98)
is used to send e-mail.

Unfortunately, it is hard to use the Send Mail button for anything but sending the actual record, because the entire message is created and sent in the Click() event of the button. To change the created message, you'd have to overwrite the entire method, which means that you have to create the entire behavior yourself. You might as well create your own class.



Advanced Object Oriented Programming with Visual FoxPro 6. 0
Advanced Object Oriented Programming with Visual FoxPro 6.0
ISBN: 0965509389
EAN: 2147483647
Year: 1998
Pages: 113
Authors: Markus Egger

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net