Search code examples
c++wtl

Tutorial does not compile


The following code from Michael Dunns series on WTL does not compile

template <bool t_bVertical = true>
class CMySplitterWindowT : public CSplitterWindowImpl<CMySplitterWindowT<t_bVertical>, t_bVertical>

First line of errors is: 'WTL::CSplitterWindowImpl' : 't_bVertical' is not a valid template type argument for parameter 'TBase'


Solution

  • WTL changed between 8 and 9

    The base constructor needs to be called to set the member variable

    template <bool t_bVertical = true>
    class CMySplitterWindowT : public CSplitterWindowImpl<CMySplitterWindowT<t_bVertical> >
    {
    public:
        DECLARE_WND_CLASS_EX(_T("My_SplitterWindow"), CS_DBLCLKS, COLOR_WINDOW)
    
        CMySplitterWindowT() : m_bPatternBar(false), CSplitterWindowImpl<CMySplitterWindowT<t_bVertical> >(t_bVertical)
        { }
    

    from the readme -

    "Splitter Window:

    •Changed orientation from template argument to data member to reduce memory use"