Metode IUIFramework::LoadUI (uiribbon.h)
Memuat sumber daya UI kerangka kerja Windows Ribbon, atau markup, file yang dikompilasi.
Sintaks
HRESULT LoadUI(
[in] HINSTANCE instance,
[in] LPCWSTR resourceName
);
Parameter
[in] instance
Jenis: HINSTANCE
Handel ke instans aplikasi Pita.
[in] resourceName
Jenis: LPCWSTR
Nama sumber daya yang berisi markup biner yang dikompilasi.
Nilai kembali
Jenis: HRESULT
Jika metode ini berhasil, metode akan mengembalikan S_OK. Jika tidak, kode kesalahan HRESULT akan dikembalikan.
Keterangan
IUIFramework::LoadUI harus dipanggil setelah inisialisasi. Metode ini dapat dipanggil beberapa kali selama siklus hidup aplikasi, misalnya, untuk memperlihatkan atau menyembunyikan Pita, asalkan IUIFramework::D estroy dipanggil di antaranya.
OnCreateUICommand dan OnViewChanged dipanggil selama eksekusi IUIFramework::LoadUI.
Contoh
Contoh berikut menunjukkan fungsi inisialisasi kerangka kerja dasar.
//
// 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;
}
Persyaratan
Persyaratan | Nilai |
---|---|
Klien minimum yang didukung | Windows 7 [hanya aplikasi desktop] |
Server minimum yang didukung | Windows Server 2008 R2 [hanya aplikasi desktop] |
Target Platform | Windows |
Header | uiribbon.h |
DLL | Mshtml.dll |
Lihat juga
Saran dan Komentar
https://aka.ms/ContentUserFeedback.
Segera hadir: Sepanjang tahun 2024 kami akan menghentikan penggunaan GitHub Issues sebagai mekanisme umpan balik untuk konten dan menggantinya dengan sistem umpan balik baru. Untuk mengetahui informasi selengkapnya, lihat:Kirim dan lihat umpan balik untuk