IUIFramework::LoadUI method (uiribbon.h)
Loads the Windows Ribbon framework UI resource, or compiled markup, file.
Syntax
HRESULT LoadUI(
[in] HINSTANCE instance,
[in] LPCWSTR resourceName
);
Parameters
[in] instance
Type: HINSTANCE
A handle to the Ribbon application instance.
[in] resourceName
Type: LPCWSTR
The name of the resource that contains the compiled, binary markup.
Return value
Type: HRESULT
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Remarks
IUIFramework::LoadUI should be called upon initialization. This method can be called multiple times during the lifecycle of an application, for example, to show or hide a Ribbon, provided that IUIFramework::Destroy is called in between.
OnCreateUICommand and OnViewChanged are called during the execution of IUIFramework::LoadUI.
Examples
The following example demonstrates a basic framework initialization function.
//
// FUNCTION: InitializeFramework(HWND)
//
// PURPOSE: Initialize the Ribbon framework and bind a Ribbon to the application.
//
// PARAMETERS:
// hWnd - Handle to the Ribbon host application window.
//
// COMMENTS:
//
// In order to get a Ribbon to display, the Ribbon framework must be initialized.
// This involves three important steps:
// 1) Instantiate the Ribbon framework object (CLSID_UIRibbonFramework).
// 2) Pass the host HWND and IUIApplication object to the framework.
// 3) Load the binary markup compiled by the UI Command Compiler (UICC.exe).
//
//
bool InitializeFramework(HWND hWnd)
{
// Instantiate the Ribbon framework object.
HRESULT hr = CoCreateInstance(
CLSID_UIRibbonFramework,
NULL,
CLSCTX_INPROC_SERVER,
IID_PPV_ARGS(&g_pFramework));
if (!SUCCEEDED(hr))
{
return false;
}
// Create the application object (IUIApplication) and call the
// framework Initialize method, passing the application object and the
// host HWND that the Ribbon will attach itself to.
CComObject<CApplication> *pApplication = NULL;
CComObject<CApplication>::CreateInstance(&pApplication);
hr = pApplication->QueryInterface(&g_pApplication);
if (!SUCCEEDED(hr))
{
return false;
}
hr = g_pFramework->Initialize(hWnd, g_pApplication);
if (!SUCCEEDED(hr))
{
return false;
}
// Load the binary markup.
// Initiate callbacks to the IUIApplication object that was
// provided to the framework earlier and bind command handler(s)
// to individual commands.
hr = g_pFramework->LoadUI(GetModuleHandle(NULL), L"APPLICATION_RIBBON");
if (!SUCCEEDED(hr))
{
return false;
}
return true;
}
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 |