locked
_In_ and Activated += ref new

    Question

  • In learning Direct3D tutorial, I don't quite understand the following two statements:

        virtual void Initialize(
            _In_ CoreApplicationView^ applicationView
            )
        {
            applicationView->Activated +=
                ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &Direct3DTutorialFrameworkView::OnActivated);
        }

    Is the keyword _In_ similar to const of C++?

    Why not write

    applicationView->Activated = ref new TypedEventHandler...

    Wednesday, June 27, 2012 5:00 PM

Answers

  • Is the keyword _In_ similar to const of C++?

    No. _In_ is a SAL keyword. SAL Keywords describe how a function uses its parameters. They are used by C++ static code analyzer. More information on SAL keywords.

    Why not write
    > applicationView->Activated = ref new TypedEventHandler

    An event can have more than one event handlers. When one event is fired, it can call more than one event handlers. This is why you *add* an event handler. See C++/CX Events.

    • Proposed as answer by Jesse Jiang Thursday, June 28, 2012 6:37 AM
    • Marked as answer by Jesse Jiang Wednesday, July 4, 2012 7:18 AM
    Wednesday, June 27, 2012 11:20 PM