Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change menu font (name,size) and colors with Menu designer

Menus

How to change menu font (name,size) and colors with Menu designer

by  Kruno  Posted    (Edited  )
.

Yes. It is [color red]not[/color red] recommended to change the way menu looks.
But if you (or your users) still insist, here is the way:

A. CHANGING MENU FONT (NAME, SIZE, STYLE)
================================================
Step-by-Step Procedure
To change the font of a menu item, follow these steps:

1. Open the menu designer, and select Quick Menu under Menu.
2. In the Prompt column, click a menu item (for example, Open) under File.
3. Press the Options button to display the Prompt Options dialog box.
4. Select the Skip For box to display the Expression Builder.
5. In the Skip For box, type the following:
.f. FONT "Courier New", 14 style "BI"
6. Choose OK twice to return to the Menu Designer.
7. Choose Generate under Menu, and run the menu.
Now the Open choice in the File menu is much larger and displays bold italic.

http://support.microsoft.com/default.aspx?scid=kb;en-us;130657
================================================

My suggestion (for VFP9 and lower):
You will allow the user to change these settings or/and
save these values to DBF or TXT/INI.

1. Before invoking your menu in your program read them into variables.
lcfont_name e.g.Courier New
lnfont_size e.g.14 (integer!)
lcfont_style e.g.BI

2. And build a string with these values.
Code:
lcxxx = [FONT "] + lcfont_name + [", ] + ;
ALLTRIM(STR(lnfont_size)) + ;
[ STYLE "] + lcfont_style+[" ]
3. Then declare 2 global variables.
Code:
public gcMenuF,gcMenuT
gcMenuF = ".f. " + lcxxx
gcMenuT = ".t. " + lcxxx

4. In Menu Designer click on button Options on the right of your
option and put in SKIP FOR:

Code:
&gcMenuF

For your disabled options put instead

Code:
&gcMenuT

**************************************************************

B. CHANGING MENU COLORS

Lets say you prepared your lcxxx as above.
To manipulate with colors, you need 3 pairs of integers representing
colors. You got it by RGB-dialog.

2-A.
Read them into variables:

lnenabled_fore -> enabled options, fore and back color
lnenabled_back

lnselected_fore -> the selected option, fore and back color
lnselected_back

lndisabled_fore -> disabled options, fore and back color
lndisabled_back

2-B.
After you get lcxxx as above (2),
Code:
lcxxx = [FONT "] + lcfont_name + [", ] + ;
ALLTRIM(STR(lnfont_size)) + ;
[ STYLE "] + lcfont_style+[" ]

you need 3 color pairs only relevant in VFP,
opposed to FPD.

Code:
lcx1 = Color2RGBpair(lndisabled_fore,lndisabled_back)
lcx2 = Color2RGBpair(lnenabled_fore,lnenabled_back)
lcx3 = Color2RGBpair(lnselected_fore,lnselected_back)

lcxxx = lcxxx + ;
[ COLOR ] + ;
lcx1 + "," + ;
lcx2 + ",,,," + ;
lcx3 + " "

[color red]
After that richer lcxxx, you declare 2 global variables and put one in SKIP FOR in your Menu Designer (steps 3,4)
[/color red]


You only need access to function Color2RGBpair.
Notice very odd format of RGB ! Like RGBRGB.

Code:
FUNCTION Color2RGBpair
* Returns color pair as "RGB(cRed,cGreen,cBlue,cRed,cGreen,cBlue)" from the numeric value of the color. 
* Based on function Color2RGB_1 by ???
LPARAMETERS tnColorFore ,tnColorBack
RETURN STRTRAN("RGB("+ ;
	STR(tnColorFore%256,3)+","+;
	STR(FLOOR(tnColorFore%256^2 / 256),3)+ "," + ;
	STR(FLOOR(tnColorFore / 256^2),3)+","+;
	STR(tnColorBack%256,3)+","+;
	STR(FLOOR(tnColorBack%256^2 / 256),3)+ "," + ;
	STR(FLOOR(tnColorBack / 256^2),3) + ;
	")" , " ", "")
ENDFUNC

Limitations: It seems to work only for menu bars (DEFINE BAR), not for PADS and not for separators in menu.

Example:
lnenabled_fore = 0
lnenabled_back = 16777215
lndisabled_fore = 14737632
lndisabled_back = 16777215
lnselected_fore = 16777215
lnselected_back = 14772545
lnfont_size = 12
lcfont_name = "Verdana"
lcfont_style = "B"
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top