Compartilhar via


SHGetUIMetrics

Windows Mobile SupportedWindows Embedded CE Not Supported

9/9/2008

O SHGetUIMetrics função recupera o tamanho da fonte sistema.

Syntax

HRESULT SHGetUIMetrics (
  SHUIMETRIC shuim,
  PVOID pvBuffer,
  DWORD cbBufferSize,
  DWORD * pcbRequired
);

Parameters

  • shuim
    [no] Indica como você desejar o tamanho da fonte sistema expresso. shuim Deve ser um do SHUIMETRIC Os valores.
  • pvBuffer
    [out] Referência ao valor tamanho da fonte sistema recuperado. Pode ser NULL. (Consulte " Comentários " para obter detalhes).
  • cbBufferSize
    [no] O tamanho estimado de pvBuffer.
  • pcbRequired
    [out] Referência para o real tamanho exigido para pvBuffer. Pode ser NULL. (Consulte " Comentários " para obter detalhes).

Return Value

SHGetUIMetrics Retorna um HRESULT valor de um S_OK Ou um apropriado código de erro.

Remarks

Para garantir que seu aplicativo exibe corretamente, você deve chamar SHGetUIMetrics Para determinar atual sistema tamanho da fonte quando seu aplicativo for iniciado. Além disso, depois que a janela recebe a SH_UIMETRIC_CHANGE notificação que é transmitir sempre que o usuário for alterado tamanho da fonte o sistema, você pode chamar SHGetUIMetrics Para determinar a nova métrica fonte e, em seguida, determinar se o novo tamanho da fonte requer um novo layout de sua janela.

Se você chamar SHGetUIMetrics Para recuperar o sistema tamanho da fonte, shuim Deve ser um dos três SHUIMETRIC Valores: SHUIM_FONTSIZE_POINT, ou SHUIM_FONTSIZE_PIXEL, ou SHUIM_FONTSIZE_PERCENTAGE. Neste maiúsculas e minúsculas, pvBuffer é um ponteiro para DWORD, e cbBufferSize é o tamanho de uma DWORD.

Observação

No Smartphone for Windows Mobile 2003 e versões anteriores, os usuários não é possível alteração tamanho da fonte o sistema.

Exemplo de código

O seguinte exemplo de código demonstra como usar SHGetUIMetrics.

Observação

Para fazer o seguinte exemplo de código mais fácil de ler, verificação de segurança e manipulação de erro não estão incluídos.Esta exemplo de código não deve ser usado em uma configuração versão a menos que ele foi modificado para incluí-las.

#include <Aygshell.h>
LRESULT CALLBACK SHUIMetricWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    // This message will only fire on Windows Mobile 6 Professional and Windows Mobile 6 Classic
    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 get 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 get 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
Library Aygshell.dll
Windows Embedded CE Windows CE .NET 4.2 and later
Windows Mobile Pocket PC for Windows Mobile 2003 Second Edition and later, Smartphone for Windows Mobile 2003 Second Edition and later

See Also

Reference

Funções do shell
SH_UIMETRIC_CHANGE
SHUIMETRIC