IUIFramework ::LoadUI, méthode (uiribbon.h)
Charge la ressource d’interface utilisateur de l’infrastructure du ruban Windows ou le fichier de balisage compilé.
Syntaxe
HRESULT LoadUI(
[in] HINSTANCE instance,
[in] LPCWSTR resourceName
);
Paramètres
[in] instance
Type : HINSTANCE
Handle de l’application ruban instance.
[in] resourceName
Type : LPCWSTR
Nom de la ressource qui contient le balisage binaire compilé.
Valeur retournée
Type : HRESULT
Si cette méthode réussit, elle retourne S_OK. Sinon, elle retourne un code d’erreur HRESULT.
Remarques
IUIFramework ::LoadUI doit être appelé lors de l’initialisation. Cette méthode peut être appelée plusieurs fois pendant le cycle de vie d’une application, par exemple, pour afficher ou masquer un ruban, à condition que IUIFramework ::D estroy soit appelé entre les deux.
OnCreateUICommand et OnViewChanged sont appelés pendant l’exécution de IUIFramework ::LoadUI.
Exemples
L’exemple suivant illustre une fonction d’initialisation d’infrastructure de base.
//
// 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;
}
Configuration requise
Condition requise | Valeur |
---|---|
Client minimal pris en charge | Windows 7 [applications de bureau uniquement] |
Serveur minimal pris en charge | Windows Server 2008 R2 [applications de bureau uniquement] |
Plateforme cible | Windows |
En-tête | uiribbon.h |
DLL | Mshtml.dll |
Voir aussi
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour