Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
MENU'S >>  HOW DO I CHANGE THE ATTRIBUTES LIKE COLOUR, FONT ETC. FOR MY MENU'S

  Bernard Bout
  Where is Bernard Bout?
 Brisbane
 Australia
 Bernard Bout



This is how to obtain Dynamic Colors for your menubars, Dynamic fonts and Dynamic bmps that can be changed at runtime.

When desigining your menu in the menu designer of VFP, for the menu item you want to change, click on the small button just below Options.

This opens the VFP "Prompt Options" dialog box where you specify shortcut, Skip for, Message etc. The field we want is Message

1. In the Message field first enter an empty string like so "". You could add some text between the "" if you wanted, but for this exercise just enter ""


2. Now enter a SPACE

3. Now enter your font string Exactly as I have :

FONT "Century Gothic", 20 Style "B"

4. Now if you want a bitmap add this :

PICTURE "c:\vfp9\fox.bmp"

Now the complete string in your Message field is:

"" FONT "Century Gothic", 20 Style "B" Picture "c:\vfp9\fox.bmp"

Note: Your Preview will not show the new attributes.
From the menu select Menu | Generate to generate the MPR file.

Run this : DO MyMenu.mpr

Now go to the menu and look at the item that you added the above line to. Voila. Picture & Font Attributes.

Now open the menu in VFP, go to the Message field (as above), Highlight and CUT out all the code you entered EXCEPT for the "" . Now your Message field should have just ""

Type a space and then enter this:
&MyMenuVar1

Message field now looks like this :

"" &MyMenuVar1

Save this and generate the MPR file again. Do NOT run it as yet.

In your command window type this:


MyMenuVar1 = [FONT "Century Gothic", 20 Style "B" COLOR , RGB(255,255,255,192,255,0) PICTURE "c:\vfp9\fox.bmp" ]

NOTE: VFP Help File is wrong
"COLOR ColorPairList

Specifies the colors for an individual menu item, overriding the default colors or the colors specified with DEFINE POPUP. You can specify the colors of all menu items, mark characters, and messages. By default, the colors of menu items are determined by color scheme 2 of the current color set."


The above will do NOTHING. You need to enter the colorpair as I have done above, with a comma between the COLOR and the Pair:

COLOR , RGB(255,255,255,192,255,0)


(Basically you paste the code you cut out of the message field between the [] btackets. Use any small bitmap but you need the full path)

Press enter and Public Variable MyMenuVar1 now equals to your string.

Now
Do MyMenu.Mpr

Final result is as below. Ugly I know but it gives you the idea that you can change anything, even the fonts.



Open the menu to the item you wanted changed and see that it now has a bitmap as well as font attributes. You can change the value assigned to MyMenuVar at runtime and reissue Do MyMenu.Mpr and the menu will take on the new attributes.

Type :
MyMenuVar1 = [FONT "Century Gothic", 6 Style "B" COLOR , RGB(255,255,255,192,255,0) PICTURE "c:\vfp9\fox.bmp" ]
(change the font size to 6 , Backgcolor to green, forecolor to white)


Now Do MyMenu.Mpr

Open the menu and see that the font size has reduced from 20 to 6 at runtime with a colour change!

So now you know how to do this at design time as well as runtime.

You just need to remember to Generate the MPR and also at runtime DO the MPR each time you change the attributes.

Experiment at changing other properties as defined in the VFP help Define Bar command.

FEEDBACK

Salwan Ravi @ 8/23/2007 8:08:38 AM
it's great

Biju Thomas @ 12/2/2007 6:10:24 PM
Amazing

Vinay Pagaria @ 12/6/2007 10:19:42 AM
great!

shahid masoud @ 7/21/2008 11:55:18 AM
How to change top level menu bar ?

Bernard Bout @ 7/23/2008 3:07:48 AM
shahid masoud - You change Top Level Menu bar in Windows. That is a system wide setting.

OM RAJAN @ 7/30/2008 3:29:08 PM
its great.... tnx bout

mk sharma @ 7/30/2009 3:38:45 PM
please show a example for top level menu bar

warm regards,
mk.

mk sharma @ 7/30/2009 3:46:39 PM
it effects all the menus but only want to change only my software menu

warm regards,
mk.

Rama Kirhsna NagaRaju @ 9/26/2010 5:28:27 PM
Hello Sir,
Your Code Is Not Working. Could You Please Send Any Sample File For Me. It's More Help Full For Us.
Plz... Send To Me
My Mail ramakrishnatenali@rediffmail.com

Mircea Mrenes @ 4/3/2014 6:41:15 PM
Brilliant! It works perfectly! Thanks a lot!



Your Name: 
Your Feedback: 

Spam Protection:
Enter the code shown: