Compartilhar via


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

Chamado quando o estado de uma Exibição é alterado.

Sintaxe

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

Parâmetros

[in] viewId

Tipo: UINT32

A ID do Modo de Exibição. Somente um valor de 0 é válido.

[in] typeID

Tipo: UI_VIEWTYPE

O UI_VIEWTYPE hospedado pelo aplicativo.

[in] view

Tipo: IUnknown*

Um ponteiro para a interface View.

[in] verb

Tipo: UI_VIEWVERB

A UI_VIEWVERB (ou ação) executada pelo Modo de Exibição.

[in] uReasonCode

Tipo: INT32

Não definido.

Valor retornado

Tipo: HRESULT

Se o método for bem-sucedido, ele retornará S_OK. Caso contrário, ele retornará um código de erro HRESULT.

Comentários

Essa notificação de retorno de chamada é enviada pela estrutura para o aplicativo host em cada alteração de estado de exibição.

Importante Esse retorno de chamada ocorre apenas para o Modo de Exibição da Faixa de Opções com uma viewId de 0.
 
IUIApplication::OnViewChanged é útil para inicializar as propriedades da Faixa de Opções quando o aplicativo host é iniciado, modificando as propriedades da Faixa de Opções com base em ações do usuário, como redimensionar a janela do aplicativo e consultar propriedades da Faixa de Opções quando o aplicativo for fechado.

Exemplos

O exemplo a seguir demonstra uma implementação básica do método 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;
}

Requisitos

   
Cliente mínimo com suporte Windows 7 [somente aplicativos da área de trabalho]
Servidor mínimo com suporte Windows Server 2008 R2 [somente aplicativos da área de trabalho]
Plataforma de Destino Windows
Cabeçalho uiribbon.h
DLL Mshtml.dll

Confira também

IUIApplication

Exemplos da Estrutura da Faixa de Opções do Windows