Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Lädt die Windows-Menübandframework-Ui-Ressource oder kompilierte Markupdatei.
Syntax
HRESULT LoadUI(
[in] HINSTANCE instance,
[in] LPCWSTR resourceName
);
Parameter
[in] instance
Typ: HINSTANCE
Ein Handle für die Menübandanwendung instance.
[in] resourceName
Typ: LPCWSTR
Der Name der Ressource, die das kompilierte binäre Markup enthält.
Rückgabewert
Typ: HRESULT
Wenn diese Methode erfolgreich ist, wird S_OK zurückgegeben. Andernfalls wird ein Fehlercode HRESULT zurückgegeben.
Hinweise
IUIFramework::LoadUI sollte bei der Initialisierung aufgerufen werden. Diese Methode kann während des Lebenszyklus einer Anwendung mehrmals aufgerufen werden, z. B. zum Ein- oder Ausblenden eines Menübands, vorausgesetzt, dass IUIFramework::D estroy dazwischen aufgerufen wird.
OnCreateUICommand und OnViewChanged werden während der Ausführung von IUIFramework::LoadUI aufgerufen.
Beispiele
Im folgenden Beispiel wird eine grundlegende Frameworkinitialisierungsfunktion veranschaulicht.
//
// 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;
}
Anforderungen
Anforderung | Wert |
---|---|
Unterstützte Mindestversion (Client) | Windows 7 [nur Desktop-Apps] |
Unterstützte Mindestversion (Server) | Windows Server 2008 R2 [nur Desktop-Apps] |
Zielplattform | Windows |
Kopfzeile | uiribbon.h |
DLL | Mshtml.dll |