To allow your stock tool to be specialized, you define properties whose values are persisted by the Tool Palette framework. The values of these properties distinguish various instances of a single stock tool. Because your project communicates with the framework through COM interfaces, you start by defining Automation properties using ATL. To handle the properties at runtime, you define get and put functions in your coclass.
For this sample project, you define a single property, CmdName, of type BSTR.
TCHAR m_tcCmdName[256];
STDMETHOD(get_CmdName)(/*out, retval*/ BSTR* pVal); STDMETHOD(put_CmdName)(/*in*/ BSTR newVal);
STDMETHODIMP CSimpleTool:get_CmdName(BSTR* pVal) { CComBSTR bStr(m_tcCmdName); bStr.CopyTo(pVal); return S_OK; } STDMETHODIMP CSimpleTool:put_CmdName(BSTR newVal) { CComBSTR bStr(newVal); COLE2T szName(bStr); _tcscpy(m_tcCmdName, szName); return S_OK; }
This example uses a CComBSTR class object and the COLE2T macro provided by ATL 7.0 to handle string type conversions. Consult the Microsoft documentation for caveats and guidelines to consider if you use these ATL features.