Metodo IUIFramework::LoadUI (uiribbon.h)
Carica la risorsa dell'interfaccia utente del framework della barra multifunzione di Windows o il file di markup compilato.
Sintassi
HRESULT LoadUI(
[in] HINSTANCE instance,
[in] LPCWSTR resourceName
);
Parametri
[in] instance
Tipo: HINSTANCE
Handle per l'istanza dell'applicazione della barra multifunzione.
[in] resourceName
Tipo: LPCWSTR
Nome della risorsa che contiene il markup binario compilato.
Valore restituito
Tipo: HRESULT
Se questo metodo ha esito positivo, restituisce S_OK. In caso contrario, restituisce un codice di errore HRESULT .
Commenti
IUIFramework::LoadUI deve essere chiamato al momento dell'inizializzazione. Questo metodo può essere chiamato più volte durante il ciclo di vita di un'applicazione, ad esempio per mostrare o nascondere una barra multifunzione, purché IUIFramework::D estroy venga chiamato tra.
OnCreateUICommand e OnViewChanged vengono chiamati durante l'esecuzione di IUIFramework::LoadUI.
Esempio
Nell'esempio seguente viene illustrata una funzione di inizializzazione del framework di 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;
}
Requisiti
Requisito | Valore |
---|---|
Client minimo supportato | Windows 7 [solo app desktop] |
Server minimo supportato | Windows Server 2008 R2 [solo app desktop] |
Piattaforma di destinazione | Windows |
Intestazione | uiribbon.h |
DLL | Mshtml.dll |