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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the easiest way to change menu color when hovered by editing the mpr? 3

Status
Not open for further replies.

gryff15

Programmer
Sep 21, 2016
47
PH
I have found a tutorial by Mike Lewis Consultants Ltd at and I was able to test it to a few items on the menu. The thing is I don't want to copy paste COLOR ,,,,,RGB(255,255,255,57,173,73) at every DEFINE BAR because there are too many items. There's a chance that others may regenerate the mpr so I hope I can have something that can be coded again in a simpler way.
I wanted to change the color when it is selected because it matches the company's color.


Code:
DEFINE POPUP accounts MARGIN RELATIVE SHADOW COLOR SCHEME 4
DEFINE BAR 1 OF accounts PROMPT "\<Query Manager" COLOR ,,,,,RGB(255,255,255,57,173,73) ;
	SKIP FOR SetAsDisabled('Query Manager')
DEFINE BAR 2 OF accounts PROMPT "\-" COLOR ,,,,,RGB(255,255,255,57,173,73)
DEFINE BAR 3 OF accounts PROMPT "E\<xit" COLOR ,,,,,RGB(255,255,255,57,173,73) ;
	KEY CTRL+X, "Ctrl+X"

Hoping for your friendly assistance.
Thank you. :)

- webrider -
 
The code you posted will do what you want. But you can simplify it by removing the RGB clauses from the individual DEFINE BARs and place it instead in the DEFINE POPUP (in place of COLOR SCHEME).

Alternatively, if your aim is to make it easy to change the colours later without having to edit the individual clauses, you could use #DEFINE to specify the RGB clause.

But I take your point that, however you specify the colours, the settings will be overridden if someone later regenerates the MPR. There is nothing you can do about that. If you use the menu designer to produce an MPR, and you subsequently modify the generated code, then any time you go back to the menu designer and regenerate the MPR, the modifications will be lost. Basically, that's the way any code generator works.

One solution is use the menu designer to produce as much of the menu as possible, and then delete the MNX and MNT files and do all subsequent changes by hand.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thank you for responding sir Mike. For some reason, when I edit my mpr, it doesn't seem to change. I even tried deleting all the texts to make the mpr file 0kb and it still generated an exe file with working menus. It's like it has its own memory where the mpr codes are still written.
But when I tried to delete the mnt and mnx files as you've said, when I build the project, it says it's missing the menu and wouldn't proceed with the exe generation. I feel discombobulated.

This is the code I tried to do, I'm not sure if it should be &lcBgColor or ?lcBgColor:
Code:
[COLOR=#EF2929]#DEFINE lcBgColor "COLOR ,,,,,RGB(255,255,255,57,173,73) "[/color]

DEFINE POPUP accounts MARGIN RELATIVE SHADOW [COLOR=#EF2929]&lcBgColor[/color]
DEFINE BAR 1 OF accounts PROMPT "\<Query Manager" ;
	SKIP FOR SetAsDisabled('Query Manager')
DEFINE BAR 2 OF accounts PROMPT "\-"
DEFINE BAR 3 OF accounts PROMPT "E\<xit" ;
	KEY CTRL+X, "Ctrl+X"

Thank you.

- webrider -
 
You can't use a constant for macro substitution. Macrosubstitution needs a memory variable.

You could do
Code:
#DEFINE BG_COLOR "COLOR ,,,,,RGB(255,255,255,57,173,73)"
Local lcBgColor
lcBgColor = BG_COLOR

DEFINE POPUP accounts MARGIN RELATIVE SHADOW &lcBgColor
...

And on the other side, you could use the constant more directly this way:

Code:
#DEFINE BG_COLOR ,,,,,RGB(255,255,255,57,173,73)

DEFINE POPUP accounts MARGIN RELATIVE SHADOW COLOR BG_COLOR
...

Chriss
 
To not get compile errors you'll need to remove the menu from the project, not just delete files. Then also add the modified MPR to the code section and look out for DO ...mpr in the main prg.


Chriss
 
Chris has given you the answer. You should either do macro substitution (with &) or use #DEFINE. You shouldn't be using them both at the same time.

But if you are going to move the COLOR clause from DEFINE BAR to DEFINE POPUP, then you don't really need to do anything else. These are all just different ways of achieving the same goal: to avoid having to add the COLOR clause to each individual menu bar.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
If you want to make it possible to modify the menu with the Designer later, put the additional clauses in the SKIP FOR specification for the bar, preceded either by the actual SKIP FOR condition or by .F.

For example, for a bar that has no SKIP FOR condition, specify:

[pre].f. COLOR ,,,,,RGB(255,255,255,57,173,73)
[/pre]

That'll add the clause to the bar when it's generated:

[pre]DEFINE BAR ..... SKIP FOR .F. COLOR ,,,,,RGB(255,255,255,57,173,73)[/pre]

You can combine that with putt the actual color in a constant or variable so you don't have to touch every bar to change it.

Having said all that, I'll point out that menu colors are one of those things you shouldn't actually change. They're related to the user's Windows settings and changing them can mean some people who are colorblind or have other visual difficulties can't read the menu. (Always design assuming disabled people will be using your application.)

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top