6 |
The LA Fox Developer Newsletter
|
November 1997
|
FoxPro Q&A
(Con't from page
5)
Q What should I do toplaya soundora beep in VFP?
A You can play a simple beep by printing the Bell character
CHR(7).
?CHR(7)
If you have a sound card (to play .wav files), then do the follow
ing:
SET BELL TO wavfilename, 1
?CHR(7)
The appropriate .wav file is played.
You can also use the API function MessageBeep. The MessageBeep function plays a waveform sound. However, you need a sound card for this.
DECLARE
integer MessageBeep in Win32API integer
=MessageBeep(I 6)
=MessageBeep(32)
=MessageBeep(48)
=MessageBeep(64)
=MessageBeep(256)
All these result in different system sounds.
Q Can I attach a new menu to a user-defined screen?
A You can attach a menu to a screen. You can define a menu in a window using the IN WiNDOW clause. The following code demonstrates how to go about this.
Example: Suppose the Window name of the screen is ‘myscreen’. The following steps show how to add a menu to this screen containing two pads, namely File and Edit.
In the Screen Setup Code, add the following Menu code:
SET SYSMENU AUTOMATIC
DEFINE MENU menul IN WINDOW
myscreen
DEFINE PAD File OF menul PROMPT “~<FiIe” COLOR SCHEME 3
DEFINE PAD Edit OF menul PROMPT "\<Edit" COLOR SCHEME 3
ON PAD File OF menul ACTIVATE POPUP mfile
ON PAD Edit OF menul ACTIVATE POPUP medit
MARGIN RELATIVE SHADOW COLOR SCHEME 4
DEFINE BAR I OF mfile PROMPT "\<New..."
DEFINE BAR 2 OF mfile PROMPT “i<Print...”
DEFINE BAR 3 OF mfile PROMPT “\cExlt”
ON SELECTION BAR 3 OF mfile DO one &&
Exit
other selection code comes here...
n the Activate (When) section, activate the menu.
|
ACTIVATE MENU menul NOWAIT
In the Cleanup and Procedures section, add the functions that
you are using.
PROCEDURE one && This is used for ExIting.
CLEAR READ
DEACTIVATE POPUP mfile && This Is
important
RETURN
The menu created in the above example is not a true system menu. It therefore does not exactly look or behave like a system menu. For example, if you select a menu pad, you must execute “DEACTIVATE POPUP padname” to close up the pad. Clicking the mouse off the menu pad does not deactivate the menu.
Q I have many landscape reports using a 6-pt font. It’s hard for the eye to scan from left to
right
and keep track of what line you’re on. I’d like to puta light grey shading on every other row, similar to the old green bar paper, to assist the user, instead of having them use a ruler. Is this possible?
A Here is a step by step example
-
In the Report Oesigner, Place a Rectangle object in the Detail band. Select it and Send it to the Back of all other objects (Object menu).
-
Make the color of the object
-
Grey (Object fill color). Stretch the Rectangle from left to right of the detail band, so that all the other fields fit exactly on top of it.
Now when you preview the report, you will find that all the lines are shaded grey.
-
To shade only the Alternate rows do the following
1- In the Report Designer, Double Click on the Rectangle object
which you just added in the detail band.
2- In the resulting RECTANGLE/LINE dialog box, click on the
check box which says ‘Print When’.
3- In the resulting Print When dialog, click on the check box
which says ‘Print only when expression is true’.
4-In the resulting Expression Builder, enter the expression as:
MYFUNC()
5- Now create a program file MYFUNC.PRG with the following lines:
a
This is a toggle program. Returns true
first
time, false th next time
public x
|
Page 6
|
6 |