title | description | manager | ms.date | ms.audience | ms.topic | ms.service | ms.localizationpriority | api_name | api_type | ms.assetid | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|
IMAPIFormSetViewContext |
Describes the syntax, parameters, and return value of IMAPIFormSetViewContext, which establishes a view context for the form. |
lindalu |
03/09/2015 |
Developer |
reference |
office-online-server |
medium |
|
|
a7b10007-42d8-4755-8362-f8ad9a8dad68 |
Applies to: Outlook 2013 | Outlook 2016
Establishes a view context for the form.
HRESULT SetViewContext(
LPMAPIVIEWCONTEXT pViewContext
);
pViewContext
[in] A pointer to the new view context for the form.
S_OK
The view context was successfully set.
Form viewers call the IMAPIForm::SetViewContext method to establish a particular form view context as current. A form can have only one view context at a time.
Most form servers implement SetViewContext by using the following algorithm:
-
If a view context already exists for the form, cancel the form's registration by calling the IMAPIViewContext::SetAdviseSink method with null in the pmnvs parameter, and then call the view context's IUnknown::Release method to decrement its reference count.
-
If the new view context is not null, call IMAPIViewContext::SetAdviseSink by using the pViewContext parameter to set up a new view advise sink.
-
If the new view context is not null, call the IMAPIViewContext::GetViewStatus method to determine which status flags have been set.
-
If the new view context is not null, store it and call its IUnknown::AddRef method to increment its reference count.
-
Update any user interface elements that depend on the view context.
Depending on the status flags returned from IMAPIViewContext::GetViewStatus, SetViewContext can also perform other actions. For example, if the VCSTATUS_NEXT and VCSTATUS_PREV flags are returned, SetViewContext can enable the Next and Previous buttons for the new view context.
For MFCMAPI sample code, see the following table.
File | Function | Comment |
---|---|---|
MAPIFormFunctions.cpp |
CreateAndDisplayNewMailInFolder |
MFCMAPI uses the IMAPIForm::SetViewContext method to set MFCMAPI's view context on the form before the form is displayed. |
IMAPIViewContext::GetViewStatus