Tag Archives: WRL

WRL component with support for Event handlers

The WRL sample is updated to support event handling on a WinRT component.

It requires a special delegate type in the IDL file.

// Library1.IDL
import "inspectable.idl";
import "Windows.Foundation.idl";

#define COMPONENT_VERSION 1.0

namespace Library1
{
    interface ILogger;
    runtimeclass Logger;

    [uuid(1FCD374B-2C3C-49E3-93A7-6FB801080D45), version(COMPONENT_VERSION)]
    delegate HRESULT LoggerEventHandler([in] HSTRING e);

    [uuid(3EC4B4D6-14A6-4D0D-BB96-31DA25224A15), version(COMPONENT_VERSION)]
    interface ILogger : IInspectable
    {
        HRESULT LogInfo([in] HSTRING value);
        [eventadd] HRESULT LoggerChanged([in] LoggerEventHandler* handler, [out][retval] EventRegistrationToken* token);
        [eventremove] HRESULT LoggerChanged([in] EventRegistrationToken token);
    }

    [version(COMPONENT_VERSION), activatable(COMPONENT_VERSION)]
    runtimeclass Logger
    {
        [default] interface ILogger;
    }
}

Sample updated : http://code.msdn.microsoft.com/windowsapps/Windows-Runtime-Component-4dc6fa20

Advertisements

New article about WinRT/C++/WRL in French magazine Programmez n°174

The issue number 174 of Programmez magazine, available on May 1, will contain my technical article about WinRT, C++ and WRL.

New WRL containers updated !

Based on my first sample review (see previous post), I have updated my C++/WRL sample that implements Vector<T>, Map<K, V>, UnorderedMap<K, V>.

This file is the C++/WRL portage of the collection.h file that was designed for C++/CX.

Sample Link: http://code.msdn.microsoft.com/windowsapps/Windows-Runtime-Component-9b6c6989

WRL Sample reviewed done

My C++/WRL sample available in Dev Center – Windows Store Apps has been reviewed by the creator of WRL himself, Sridhar Madhugiri.

Because this sample source code will be the support for an upcoming technical article published in Dr Dobb’s magazine Digital Issue, I have asked the Microsoft Visual C++ Lead to give me some advices.

I had a strange bug in some circumstances. So he proposed directly to Sridhar to give me some help !

My problem was about handling HSTRING new Windows data type. It has to be wrapped with a String helper class.

The same issue occurred with interface pointers that need to be wrapped with the ComPtr<T> class.

Sample Link: http://code.msdn.microsoft.com/windowsapps/Windows-Runtime-Component-4dc6fa20

New WRL container like Vector, Map support for Standard ISO C++

I have made a portage of collection.h available for C++/CX for handling collections like Vector<T>, Map<K, V>.

This header can be only used for C++/CX so… if you want to rely on standard ISO C++, you can download my header called NewCollection.h.

It’s available on Dev Center – Windows Store Apps : http://code.msdn.microsoft.com/windowsapps/Windows-Runtime-Component-9b6c6989

TechDays 2014 Slides for C++ session available on slideshare

Microsoft has made the slides available on slideshare.

You can also download the slides material here.

You can download the sample code for C++ Interop with WinRT here.

[sample] How to make a Windows Runtime Component using WRL and Standard ISO C++

I have uploaded a Windows C++ sample to illustrate how to develop WinRT components using WRL and standard ISO C++. It demonstrates how to create async method and the usage to return a vector of string and a vector of int using a template based vector container implemented using std::vector.

http://code.msdn.microsoft.com/windowsapps/Windows-Runtime-Component-4dc6fa20