I'm new to WinRT. I'm converting my Windows UWP app written C++/CX over to C++/WinRT. I have a C++/CX ref class that basically does the same thing as the Microsoft.VisualStudio.PlatformUI.DelegateCommand class does in C#. My C++ class implements ICommand where the Execute and CanExecute callbacks are handled by delegates. The abbreviated code for the header file looks like this:
public delegate void ExecuteDelegate(Platform::Object^ parameter);
public delegate bool CanExecuteDelegate(Platform::Object^ parameter);
public ref class DelegateCommand sealed :
Windows::UI::Xaml::DependencyObject,
Windows::UI::Xaml::Data::INotifyPropertyChanged,
public Windows::UI::Xaml::Input::ICommand
{
public:
DelegateCommand(ExecuteDelegate^ execute, CanExecuteDelegate^ canExecute);
.
.
.
private:
ExecuteDelegate^ m_executeDelegate = nullptr;
CanExecuteDelegate^ m_canExecuteDelegate = nullptr;
.
.
.
};
And a typical instantiation of my DelegateCommand class passes a weak pointer and a function pointer into the constructor from a class that has the implementation of the Execute and CanExecute methods:
Commands::Instance->UndoCommand = ref new DelegateCommand(
ref new ExecuteDelegate(this, &SVGDocumentUserControl::ExecuteUndoCommand),
ref new CanExecuteDelegate(this, &SVGDocumentUserControl::CanExecuteUndoCommand));
I'm sure this is a simple question, but it is unclear to me from what I have read, so exactly how would one define the two C++/CX delegates in C++/WinRT?
public delegate void ExecuteDelegate(Platform::Object^ parameter);
public delegate bool CanExecuteDelegate(Platform::Object^ parameter);
[Edit: I am also scratching my head on how to define the constructor's function pointers in the *.idl file.]
Thank you for your patience.