IUIRibbon::GetHeight method (uiribbon.h)

Retrieves the height of the ribbon.

Syntax

HRESULT GetHeight(
  [out] UINT32 *cy
);

Parameters

[out] cy

Type: UINT32*

The height of the ribbon, in pixels.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

The value returned for cy is based on a number of dependencies that include, but are not limited to, the width of the host window and the layout template declared in the Ribbon markup.

Examples

The following example demonstrates how to use the IUIRibbon::GetHeight method to retrieve the height of the ribbon to calculate a display location for a Context Popup control.

void GetDisplayLocation(POINT &pt, HWND hWnd)
{
  if (pt.x == -1 && pt.y == -1)
  {
    HRESULT hr = E_FAIL;

    // Display the menu in the upper-left corner of the client area, below the ribbon.
    IUIRibbon* pRibbon;
    hr = g_pFramework->GetView(0, IID_PPV_ARGS(&pRibbon));
    if (SUCCEEDED(hr))
    {
      UINT32 uRibbonHeight = 0;
      hr = pRibbon->GetHeight(&uRibbonHeight);
      if (SUCCEEDED(hr))
      {
        pt.x = 0;
        pt.y = uRibbonHeight;
        // Convert client coordinates of a specified point to screen coordinates.
        ClientToScreen(hWnd, &pt);
      }
      pRibbon->Release();
    }
    if (FAILED(hr))
    {
      // Default to just the upper-right corner of the entire screen.
      pt.x = 0;
      pt.y = 0;
    }
  }
}

Requirements

Requirement Value
Minimum supported client Windows 7 [desktop apps only]
Minimum supported server Windows Server 2008 R2 [desktop apps only]
Target Platform Windows
Header uiribbon.h
DLL Mshtml.dll

See also

IUIRibbon

Windows Ribbon Framework Samples