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!

system menu

Status
Not open for further replies.

ramanjain

Programmer
May 6, 2015
12
IN
how can we change system menu's font and size which is created help of menu builder.
I opened mpr file and edit the define menu line (add fontname and size) but it's not work. Some one have idea about this


thanx in advance


reagards
 
VFP Help said:
The FONT clause is ignored for menu titles added to the Visual FoxPro system menu _MSYSMENU
The system menu is a system menu. Fonts of system components (eg also form titlebars) are determined by Windows.

This is Windows, the look is the users decision via themes.

If you want your own look you better don't use _SCREEN at all and it would be consequential to throw all system theme looks overboard and do your own titlebar, border etc. It's possible, though I would not recommend it. An alternative is not use a system menu at all but create an office like ribbon, though that also has been outdated with at least a newer form in Office 2013 and also has not become standard of many applications.

Take a look at what VFPX offers, eg OOP Menu Project and ThemedControls.

Bye, Olaf.
 
Given you have an MPR file, and that you mentioned the "menu builder", that indicates that this is a menu you have created yourself, not a "system menu". If that's so, then you should be able to use the FONT clause, as normal.

To do so, you will need to edit the MPR file. Just add the clause at the relevant place. For example:

Code:
DEFINE BAR _mfi_open OF _mfile PROMPT "\<Open..." ;
  [b]FONT 'Verdana', 14 ;[/b]
  KEY CTRL+O, "Ctrl+O" ; 
  PICTRES _mfi_open ;
  MESSAGE "Opens an existing file"

Note that you can't do this in the menu designer. You have to hand-edit the generated code. Keep in mind too that if you hand-edit the code, then go back to the menu designer and re-generate the menu, your edits will be lost.

Having said all that, I agree with Olaf that you shouldn't change the font for your main menu. It is better to leave it to Windows, as it is based on the user's preferences as estabished in Control Panel.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
One of the things I've been preaching since the advent of the FoxPro "power tools": NEVER EDIT GENERATED CODE! It permanently breaks the link from the designer to the code. There is a third-part product called GenMenuX available at that will let you insert clauses (like FONT) through the designer itself.

That said, I'll agree with Olaf here. DON'T CHANGE MENU APPEARANCES. They come from Windows itself. You can change them in Control Panel, but you'll be changing them in Word, Excel, etc. -- it's one global setting.

This is not something I'd ever do, and any application that does it on my computer will immediately be uninstalled.
 
In fact, I have occasionally changed the font (and colours) of menus - but only in limited circumstances. I would never change the main top-of-screen menus, but I have sometimes created custom buttons that open a drop-down menu when clicked. In those cases, I use colours and fonts that match those of the button itself.

But I stress that these are limited cases, and not something I would generally advocate.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
>Given you have an MPR file, and that you mentioned the "menu builder", that indicates that this is a menu you have created yourself, not a "system menu".

That's a wrong assumption. If you use the menu designer, keep at default and eg start with the "Quick Menu", you get menu and items, which when later running the genmenu generated mpr will establish/replace the system menu in the _screen. And as Dan seconds this area is theme controlled.

I just would need to point to the quote of the help once more, it clearly states, when the FONT clause has no effect. If any CREATE MENU would not create/replace the system menu, that note would not be needed, would it?

Bye, Olaf.
 
If you use the menu designer, keep at default and eg start with the "Quick Menu", you get menu and items, which when later running the genmenu generated mpr will establish/replace the system menu in the _screen.

Correct. But that doesn't negate what I said. If you use the "quick menu" option and generate an MPR, you will be able add a FONT clause; and that clause will work.

I don't know whether it is correct to call that a "system menu", but that doesn't change my point.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Well, I just did that, an in fact you end up with code not including a DEFINE MENU command, instead the code redefines the sysmenu.

If I check the general option to create a "Top-Level Form" menu, the code generated now is different and conatins some instructions on how to call it. It contains a DEFINE MENU command, which will not show the Font name and size if you add a FONT clause. So I'd like to see what you mean would work, Mike.

This is wat I tried in more detail:
Create Menu (obviously don't choose Shortcut, when asked)
In the Menu menu choose Quick Menu
In the View menu choose General Options and in the dialog check "Top-Level Form".
In the Menu menu choose Generate...

I'm on Dans side, you don't modify generated code, as next time you'd like to cange the menu you'd need to redo your modification, as it's overwritten.
Nevertheless for demonstartion purposes now locate the DEFINE MENU line and add a fnt clause, eg with Courier New and 20 pts size, something which you'd see.

Now run this:
Code:
oForm = CreateObject("toplevelform")
DO menu1.mpr WITH oForm
oForm.Show()
Define Class toplevelform as form
   ShowWindow = 2
Enddefine

The form will have the quick menu with windows theme font, not what you specify. And that's because of what the help says about the clause.
Anyway, now would be a good time ramanjain to specify what he did so far and what modifications don't work. If he did what I just said, that explains whar you see. It's not meant to work with such system menus.

The vfpx oop menu project allows you to define your menu in OOP style, but on top of that difference to the designer it also allows modifications you can't do with the native menu designer. In the same manner genmenux extends what VFP offers. It all depends on what you did so far, so please share that and you can get a better response and recommendation.

Bye, Olaf.
 

in the menu designer click on the options for the menu item. Then in the "message" text box type

[] FONT Tahoma

or whatever. This causes the menu generator to add the FONT clause after the message clause in the .mpr. Has to be repeated for each menu item alas.

you could/should also have a global variable (gcSYSFONT ?) set at application startup and then all the menu items would have [] FONT gcSYSFONT in their message options.

hth

n
 
NOT RECOMMENDED (do not try this at home)

You can change the system menu font via Control Panel -> Personalization -> Window Color -> Menu (in Win7) but it affects all applications.

For different versions of Windows


Here is a programmatic way

Code:
Declare integer SystemParametersInfo in win32api integer uiAction, integer uiParam, string@ pvParam, integer fWinIni      
#define SPI_GETNONCLIENTMETRICS 41
#define SPI_SETNONCLIENTMETRICS 42    
#define SPIF_SENDCHANGE  2
#define NCM_SIZE 10*4+5*60

#define FW_ULTRALIGHT 200
#define FW_REGULAR 400
#define FW_BOLD 700
#define FW_HEAVY 900

* Get current settings    
ncm_current = Padr(BinToC(NCM_SIZE,"4RS"),NCM_SIZE,Chr(0))
SystemParametersInfo(SPI_GETNONCLIENTMETRICS,NCM_SIZE, @ncm_current, 0)

ncm_changed = m.ncm_current
* get the logfont structure
lcFontStr = SUBSTR(m.ncm_current,161,60)
lcFontStrChanged = lcFontStr
* get the current values
nheight = CTOBIN(LEFT(m.lcFontStr,4),"4RS")
nweight = CTOBIN(SUBSTR(m.lcFontStr,17,4),"4RS")
nitalic = CTOBIN(SUBSTR(m.lcFontStr,21,1),"1RS")
nunderline = CTOBIN(SUBSTR(m.lcFontStr,22,1),"1RS")
nstrike =  CTOBIN(SUBSTR(m.lcFontStr,23,1),"1RS")
cfontname = SUBSTR(lcFontStr,29)

* Fontname = Arial
lcFont = "Arial"
lcFontStrChanged = STUFF(m.lcFontStrChanged,29,32,m.lcFont + REPLICATE(CHR(0), 32 - LEN(m.lcFont)))
ncm_changed = STUFF(m.ncm_changed,161,60,m.lcFontStrChanged)
SystemParametersInfo(SPI_SETNONCLIENTMETRICS,NCM_SIZE, ncm_changed,SPIF_SENDCHANGE) 
MESSAGEBOX("Arial")
* Fontsize = 14
lnFontSize = 14
lcFontStrChanged = STUFF(m.lcFontStrChanged,1,4,BINTOC(getheight(m.lnFontSize),"4RS"))
ncm_changed = STUFF(m.ncm_changed,161,60,m.lcFontStrChanged)
SystemParametersInfo(SPI_SETNONCLIENTMETRICS,NCM_SIZE, ncm_changed,SPIF_SENDCHANGE) 
MESSAGEBOX("Fontsize = 14")
* Bold
lcFontStrChanged = STUFF(m.lcFontStrChanged,17,4,BINTOC(FW_BOLD ,"4RS"))
ncm_changed = STUFF(m.ncm_changed,161,60,m.lcFontStrChanged)
SystemParametersInfo(SPI_SETNONCLIENTMETRICS,NCM_SIZE, ncm_changed,SPIF_SENDCHANGE) 
MESSAGEBOX("Bold")
* Italic
lcFontStrChanged = STUFF(m.lcFontStrChanged,21,1,BINTOC(1 ,"1RS"))
ncm_changed = STUFF(m.ncm_changed,161,60,m.lcFontStrChanged)
SystemParametersInfo(SPI_SETNONCLIENTMETRICS,NCM_SIZE, ncm_changed,SPIF_SENDCHANGE) 
MESSAGEBOX("Italic")
* Underline
lcFontStrChanged = STUFF(m.lcFontStrChanged,22,1,BINTOC(1 ,"1RS"))
ncm_changed = STUFF(m.ncm_changed,161,60,m.lcFontStrChanged)
SystemParametersInfo(SPI_SETNONCLIENTMETRICS,NCM_SIZE, ncm_changed,SPIF_SENDCHANGE) 
MESSAGEBOX("Underline")
* Strikethrough
lcFontStrChanged = STUFF(m.lcFontStrChanged,23,1,BINTOC(1 ,"1RS"))
ncm_changed = STUFF(m.ncm_changed,161,60,m.lcFontStrChanged)
SystemParametersInfo(SPI_SETNONCLIENTMETRICS,NCM_SIZE, ncm_changed,SPIF_SENDCHANGE) 
MESSAGEBOX("Strikethrough")

* change back
ncm_changed = STUFF(m.ncm_changed,161,60,m.lcFontStr)
SystemParametersInfo(SPI_SETNONCLIENTMETRICS,NCM_SIZE, ncm_changed,SPIF_SENDCHANGE)

FUNCTION getheight
	LPARAMETERS tnPointSize
	DECLARE INTEGER GetDC IN USER32 INTEGER hwnd
	DECLARE INTEGER ReleaseDC IN USER32 INTEGER hwnd, INTEGER hdc  
	DECLARE INTEGER GetDeviceCaps IN GDI32 INTEGER hdc, INTEGER nIndex
	DECLARE integer MulDiv IN Kernel32 INTEGER, INTEGER, INTEGER
	LOCAL lnhDC, lnfHeight, LOGPIXELSY
	LOGPIXELSY = 90
	lnhDC = GetDC(0)
	lnfHeight = -MulDiv(tnPointSize, GetDeviceCaps(lnhDC, LOGPIXELSY), 72)
	lnhDC = ReleaseDC(0, lnhDC)
	CLEAR DLLS "GetCD", "ReleaseDC", "GetDeviceCaps", "MulDiv"
RETURN lnfHeight



Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top