Méthode IUIApplication::OnViewChanged (uiribbon.h)

Appelé lorsque l’état d’une vue change.

Syntaxe

HRESULT OnViewChanged(
  [in] UINT32      viewId,
  [in] UI_VIEWTYPE typeID,
  [in] IUnknown    *view,
  [in] UI_VIEWVERB verb,
  [in] INT32       uReasonCode
);

Paramètres

[in] viewId

Type : UINT32

ID de l’affichage. Seule la valeur 0 est valide.

[in] typeID

Type : UI_VIEWTYPE

Le UI_VIEWTYPE hébergé par l’application.

[in] view

Type : IUnknown*

Pointeur vers l’interface View.

[in] verb

Type : UI_VIEWVERB

UI_VIEWVERB (ou action) effectuée par l’affichage.

[in] uReasonCode

Type : INT32

Non défini.

Valeur retournée

Type : HRESULT

Si cette méthode réussit, elle retourne S_OK. Sinon, elle retourne un code d’erreur HRESULT.

Remarques

Cette notification de rappel est envoyée par l’infrastructure à l’application hôte à chaque changement d’état d’affichage.

Important Ce rappel se produit uniquement pour l’affichage ruban avec un viewId de 0.
 
IUIApplication::OnViewChanged est utile pour initialiser les propriétés du ruban au démarrage de l’application hôte, modifier les propriétés du ruban en fonction des actions de l’utilisateur, telles que le redimensionnement de la fenêtre d’application, et interroger les propriétés du ruban lorsque l’application se ferme.

Exemples

L’exemple suivant illustre une implémentation de base de la méthode 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;
}

Configuration requise

   
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

IUIApplication

Exemples d’infrastructure du ruban Windows