IUIApplication::OnViewChanged method (uiribbon.h)
Dipanggil saat status Tampilan berubah.
Sintaks
HRESULT OnViewChanged(
[in] UINT32 viewId,
[in] UI_VIEWTYPE typeID,
[in] IUnknown *view,
[in] UI_VIEWVERB verb,
[in] INT32 uReasonCode
);
Parameter
[in] viewId
Jenis: UINT32
ID untuk Tampilan. Hanya nilai 0 yang valid.
[in] typeID
Jenis: UI_VIEWTYPE
UI_VIEWTYPE yang dihosting oleh aplikasi.
[in] view
Jenis: IUnknown*
Penunjuk ke antarmuka Tampilan.
[in] verb
Jenis: UI_VIEWVERB
UI_VIEWVERB (atau tindakan) yang dilakukan oleh Tampilan.
[in] uReasonCode
Jenis: INT32
Tidak ditentukan.
Menampilkan nilai
Jenis: HRESULT
Jika metode ini berhasil, metode akan mengembalikan S_OK. Jika tidak, kode kesalahan HRESULT akan dikembalikan.
Keterangan
Pemberitahuan panggilan balik ini dikirim oleh kerangka kerja ke aplikasi host pada setiap perubahan status Tampilan.
Contoh
Contoh berikut menunjukkan implementasi dasar metode IUIApplication::OnViewChanged .
//
// FUNCTION: OnViewChanged(UINT, UI_VIEWTYPE, IUnknown*, UI_VIEWVERB, INT)
//
// PURPOSE: Called when the state of a View (Ribbon is a view) changes - like created/destroyed/resized.
//
// PARAMETERS:
// viewId - The View identifier.
// typeID - The View type.
// pView - Pointer to the View interface.
// verb - The action performed by the View.
// uReasonCode - Not defined.
//
// COMMENTS:
//
// For this sample, return the same command handler for all commands
// specified in the .xml file.
//
//
STDMETHODIMP CApplication::OnViewChanged(
UINT viewId,
UI_VIEWTYPE typeId,
IUnknown* pView,
UI_VIEWVERB verb,
INT uReasonCode)
{
HRESULT hr = E_NOTIMPL;
// Checks to see if the view that was changed was a Ribbon view.
if (UI_VIEWTYPE_RIBBON == typeId)
{
switch (verb)
{
// The view was newly created.
case UI_VIEWVERB_CREATE:
_cwprintf(L"IUIApplication::OnViewChanged called with verb=CREATE\r\n");
if (NULL == g_pRibbon)
{
// Retrieve and store the IUIRibbon
hr = pView->QueryInterface(&g_pRibbon);
}
break;
// The view was resized.
// In the case of the Ribbon view, the application should call
// GetHeight() to determine the height of the Ribbon.
case UI_VIEWVERB_SIZE:
_cwprintf(L"IUIApplication::OnViewChanged called with verb=SIZE\r\n");
// Call to the framework to determine the height of the Ribbon.
if (NULL != g_pRibbon)
{
UINT uRibbonHeight;
hr = g_pRibbon->GetHeight(&uRibbonHeight);
}
if (!SUCCEEDED(hr))
{
//_cwprintf(L"IUIRibbon::GetHeight() failed with hr=0x%X\r\n", hr);
}
break;
// The view was destroyed.
case UI_VIEWVERB_DESTROY:
//_cwprintf(L"IUIApplication::OnViewChanged called with verb=DESTROY\r\n");
g_pRibbon = NULL;
hr = S_OK;
break;
}
}
return hr;
}
Persyaratan
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