Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Custom Menu color
Message
De
05/03/2006 23:34:34
 
 
À
23/02/2006 06:32:38
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01098399
Message ID:
01101624
Vues:
21
This message has been marked as a message which has helped to the initial question of the thread.
>Hi,
>Can I set custom menu color for top level form menu?
>Can't understand how to use color pair ;(
>I need to setup menu backcolor, menu forecolor, selected item back color, selected Item forecolor
>Is it possible?
>
>Thanks
>Denis


Hi Denis

I won't lecture you here about not changing the menu colours.

To answer your question, Yes it is possible to change the background, foregroung as well as the font and font attributes of each menu item if you so wish.

Using a little known trick this is possible. You can also make this easy to change using the VFP menu designer as well as changeable at RUNTIME!!!

Read on...

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 :

4. Enter this: COLOR , RGB(255,255,255,192,255,0)

(don't forget the comma after the keyword color)

5 Enter this:

FONT "Century Gothic", 20 Style "B"

6 Now if you want a bitmap add this :

PICTURE "c:\vfp9\fox.bmp"

Now the complete string in your Message field is:

"" COLOR , RGB(255,255,255,192,255,0) FONT "Century Gothic", 20 Style "B" Picture "c:\vfp9\fox.bmp"

Note1: Colours are entered as a colour pair Foreground / Background)

Note: Your menu 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 + colours!

RUNTIME Changes:

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 = [ COLOR , RGB(255,255,255,192,255,0) FONT "Century Gothic", 20 Style "B" PICTURE "c:\vfp9\fox.bmp" ]



(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



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 = [COLOR , RGB(255,255,255,0,0,255) FONT "Century Gothic", 6 Style "B" Picture "c:\vfp9\fox.bmp"]

(Change the background colour and the font size)

Now rum this again:
Do MyMenu.Mpr



Open the menu and see that the font size has reduced from 20 to 6 and the backgroung colour has changed - at runtime!

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

You just need to remember to DO the MPR each time you change the attributes.

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

You can store colour schemes/themes and use them from a table using the above method.

Good luck

Cheers
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform