locked
Compiler error for ref new GestureRecognizer()

    Question

  • So I am playing with the C++ code samples for D2DTestAnimation, and PhotoAdjustment. I have taken the D2DTextAnimation code and modified it to add the Manipulation Started event.

    Everything compiles until I add in :

    m_gestureRecognizer->ManipulationStarted += ref new TypedEventHandler<GestureRecognizer^, ManipulationStartedEventArgs^>(this, &View::OnManipulationStarted);

    So in my code, the m_gestureRecognizer = ref new GestureRecognizer(); is on line 64.

    The setting up of the manipulation started is on line 78. However when I add the line in, I get a compiler error C2664 on line 64, not 78. (not to mention 44 other Intellisense errors)

    I can comment the ManipulationStarted code out of course and it compiles just fine. And the associated error is in line with the code in ManipilationStarted, not with the creation of GestureRecognizer. Also the same code runs in the PhotoAdjustment, I checked the differences between the setup of each and its associated OnManipulationStarted function but don't see anything that would cause it to think that it should convert a ManipulationStarted to a ManipulationUpdated event args.

    Anyway, here is the error.

     

    Error 1 error C2664: '__winrt_ptrtomem_callback<TCallbackObject,TDelegateInterface,TReturnType,TP1,TP2>::__winrt_ptrtomem_callback(TCallbackObject ^,TReturnType (__cdecl View::* )(TP1,TP2))' : cannot convert parameter 2 from 'void (__cdecl View::* )(Windows::UI::Input::GestureRecognizer ^,Windows::UI::Input::ManipulationUpdatedEventArgs ^)' to 'void (__cdecl View::* )(Windows::UI::Input::GestureRecognizer ^,Windows::UI::Input::ManipulationStartedEventArgs ^)'

     file c:\projects\windows 8 developer preview metro style app samples\direct2d text animation\c++\view.cpp

    line 64 

    Thanks

    Friday, October 7, 2011 6:04 PM

Answers

  • What is the signature of your OnManipulationStarted method? From the error message it sounds like it may be using ManipulationUpdatedEventArgs instead of ManipulationStartedEventArgs.

    --Rob

    • Marked as answer by Mayarnel Monday, October 10, 2011 4:26 PM
    Saturday, October 8, 2011 1:23 AM
    Owner

All replies

  • What is the signature of your OnManipulationStarted method? From the error message it sounds like it may be using ManipulationUpdatedEventArgs instead of ManipulationStartedEventArgs.

    --Rob

    • Marked as answer by Mayarnel Monday, October 10, 2011 4:26 PM
    Saturday, October 8, 2011 1:23 AM
    Owner
  • I did indeed have a copypaste-fail in the signature of the function itself. Thanks for making me go back and review it again. I had double-checked the function names being called, and the template type in the call, but not the arguments of the function itself. I had thought the error was complaining about the template type in some round about way.  Totally embarassing on my part, my apologies for something so simple. I guess got hung up with the  m_gestureRecognizer = ref new GestureRecognizer();  on line 64.  being the wrong place I would expect the error, and I guess I just wanted to blame the compiler, so I couldnt see past it.

    Thanks again!


    • Edited by Mayarnel Monday, October 10, 2011 4:28 PM
    Monday, October 10, 2011 4:22 PM