SH_UIMETRIC_CHANGE

4/8/2010

The SH_UIMETRIC_CHANGE notification is sent to applications when the user changes the text size from the Screen control panel application.

Syntax

SH_UIMETRIC_CHANGE
  res = (WPARAM) wParam;
  shuim = (SHUIMETRIC) lParam;

Parameters

  • res
    This parameter is reserved for future use; the value of this parameter must be set to 0.
  • shuim
    The SHUIMETRIC value SHUIM_FONTSIZE_POINT.

Return Value

None.

Remarks

You can retrieve the new font size by calling SHGetUIMetrics. You must use RegisterWindowMessage function when more than one application must process the same message.

Code Example

The following example demonstrates how to call RegisterWindowMessage using the SH_UIMETRIC_CHANGE notification. It also demonstrates using SHGetUIMetrics to retrieve the correct font height in points, pixels, and percentage of the system font size.

#include <aygshell.h>

LRESULT CALLBACK SHUIMetricWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
  // This message will only fire on Pocket PC
  static UINT uMetricChangeMsg = RegisterWindowMessage(SH_UIMETRIC_CHANGE);

  if (message == uMetricChangeMsg)
  {
    HRESULT hr;
    LOGFONT lf;
    HDC hDC = GetDC(hwnd);
    int iFontSizePoint;
    int iFontSizePixel;
    int iFontSizePercentage;

    // Get the height of the current system font size in points.
    // This can be used with the LOGFONT structure to retrieve
    // the correct font height.
    hr = SHGetUIMetrics(SHUIM_FONTSIZE_POINT, &iFontSizePoint, sizeof(iFontSizePoint), NULL);
    lf.lfHeight = -MulDiv(iFontSizePoint, GetDeviceCaps(hDC, LOGPIXELSY), 72);

    // Get the height of the current system font size in pixels.
    // This can be used with the LOGFONT structure to retrieve
    // the correct font height.
    hr = SHGetUIMetrics(SHUIM_FONTSIZE_PIXEL, &iFontSizePixel, sizeof(iFontSizePixel), NULL);
    lf.lfHeight = -iFontSizePixel;

    // Get the height of the current system font size in percentage of
    // the default system font size. This is useful when using RichEdit
    // controls, since RichEdit supports the EM_SETZOOM message.
    hr = SHGetUIMetrics(SHUIM_FONTSIZE_PERCENTAGE, &iFontSizePercentage, sizeof(iFontSizePercentage), NULL);

    ReleaseDC(hwnd, hDC);
  }

  return DefWindowProc(hwnd, message, wParam, lParam);
}

Requirements

Header aygshell.h
Windows Embedded CE Windows CE .NET 4.2 and later
Windows Mobile Pocket PC for Windows Mobile 2003 Second Edition and later

See Also

Reference

Shell API Notifications
SHGetUIMetrics
SHUIMETRIC