IUIApplication::OnViewChanged 메서드(uiribbon.h)

보기 상태가 변경되면 호출합니다.

구문

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

매개 변수

[in] viewId

형식: UINT32

보기의 ID입니다. 값 0만 유효합니다.

[in] typeID

형식: UI_VIEWTYPE

애플리케이션에서 호스트하는 UI_VIEWTYPE .

[in] view

형식: IUnknown*

보기 인터페이스에 대한 포인터입니다.

[in] verb

형식: UI_VIEWVERB

보기에서 수행하는 UI_VIEWVERB (또는 작업)입니다.

[in] uReasonCode

형식: INT32

정의되지 않았습니다.

반환 값

형식: HRESULT

메서드가 성공하면 S_OK를 반환하고, 그러지 않으면 HRESULT 오류 코드를 반환합니다.

설명

이 콜백 알림은 프레임워크에서 각 보기 상태 변경 시 호스트 애플리케이션으로 전송됩니다.

중요 이 콜백은 viewId가 0인 리본 보기에 대해서만 발생합니다.
 
IUIApplication::OnViewChanged 는 호스트 애플리케이션이 시작될 때 리본 속성을 초기화하고, 애플리케이션 창 크기 조정과 같은 사용자 작업에 따라 리본 속성을 수정하고, 애플리케이션을 닫을 때 리본 속성을 쿼리하는 데 유용합니다.

예제

다음 예제에서는 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;
}

요구 사항

   
지원되는 최소 클라이언트 Windows 7 [데스크톱 앱만 해당]
지원되는 최소 서버 Windows Server 2008 R2 [데스크톱 앱만 해당]
대상 플랫폼 Windows
헤더 uiribbon.h
DLL Mshtml.dll

추가 정보

IUI애플리케이션

Windows 리본 프레임워크 샘플