How to make Windows Ribbon Framework honor user's font size?
Asked Answered
K

1

19

The Office 2007/2010 team's ribbon honor's the user's (Menu) font size.

The Windows Ribbon Framework ribbon (used by MS Paint, and my application) ignores the users's (i.e. my) font preferences.

Screenshot showing:

  • Excel 2010
  • MS Paint (WRF)
  • My application (WRF)

enter image description here

How can i get the Windows Ribbon Framework ribbon to honor the user's font size?

Bonus Chatter

There is no single "Windows Font". The user is allowed to configure six different fonts:

  • Icon Title font
  • Status font
  • Message font
  • Menu font
  • Caption font
  • Small Caption font

The Office team's ribbon uses the Menu font, which makes sense since the ribbon is a menu. You can retreive the Menu font using:

//Win32
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, ref nonClientMetrics, 0); 
nonClientMetrics.lfMenuFont;

//.NET
SystemFonts.MenuFont;

//Delphi
TScreen.MenuFont

Ribbon color:

By default the ribbon doesn't honor the user's color scheme (notice in my screenshots the blue ribbon, with my brown glass color). There is an api to change the color of the ribbon, as you can see in the 3rd ribbon (the one hosted in my application).

//change ribbon background color
IPropertyStore(framework).SetValue(UI_PKEY_GlobalBackgroundColor, glassColor);

//change ribbon font color
IPropertyStore(framework).SetValue(UI_PKEY_GlobalTextColor, Color.Black);    

Bonus Reading

  • Windows Ribbon Framework: How to change font face and size? (That question was about how to set an arbitrary font face and size - which could be used to honor the user's Windows font preferences. This question is about instructing the ribbon itself to honor the user's font preference, while still being unable to specify an arbitrary font face/size)
Kant answered 27/2, 2012 at 15:22 Comment(3)
Can you post there code where you attempt to change it. This question honestly requires you to provide code.Bashemath
@Ramhound There is no code to allow you to change it. There is code to let you change colors used by the ribbon, including the font color (msdn.microsoft.com/en-us/library/windows/desktop/…). But there is no way to change the font size or face.Kant
It seems they fixed it in a recent Windows update (around Dec 2020 - Jan 2021). My ribbon-based application simply started showing the font larger. Windows explorer shows it larger too.Heartthrob
R
0

This is an older question, but there is a FontSize property available for the WPF windows ribbon: http://www.microsoft.com/en-us/download/details.aspx?id=11877

You can bind that attribute to a function that returns SystemFonts.MenuFontSize and get the larger text you desire.

Raggedy answered 24/1, 2013 at 5:15 Comment(1)
The question was about the windows Ribbon Framework (Windows API) which is something different than the WPF based Ribbon implementation of .NET.Daly

© 2022 - 2024 — McMap. All rights reserved.