View Full Version : How To Extend Stingray Classes?

07-22-2008, 08:52 AM
Uhm , I don't know if the title is correct, but recompiling our code, I've found this problem two times:
If I create a class that "extend" a SEC button of Toolkit, in declaration I set the TOOLKIT_DECLARE_BUTTON, in implementation the TOOLKIT_IMPLEMENT_BUTTON, I'll have this error on linker:

ComboBtn.obj : error LNK2001: unresolved external symbol "public: virtual struct SECButtonClass * __thiscall SECComboBtn::GetButtonClass(void)const " (?GetButtonClass@SECComboBtn@@UBEPAUSECButtonClass @@XZ)

I think that the problem is in TOOLKIT_DECLARE_BUTTON macro, where the definition of GetButtonClass don't have the TOOLKIT_API macro setted.

Or...maybe I wrong the method of extending Stingray Classes?

10-13-2008, 06:27 AM
I'm having exactly the same problem, can anyone help or did you manage to resolve it nicjedi?

10-13-2008, 09:30 AM
If you are using Stingray Studio 2006 v3 or later, try the suggestions found in section 3.5.2 "Using CustExtDefs.h in Stingray Extensions" of the Getting Started User's Guide (CHM format) or integrated into the MSVCC or MSDN Help collection.

Using the libraries macros to extend the library functionality will just confuse the library decl_spec. Using custom extension definitions in your extenstions, rather than the predefined library macro definitions, should resolve this issue.

10-13-2008, 09:38 AM
There is a bug which has been fixed for the upcoming SS10.1 release. The TOOLKIT_API macro was missing from the TOOLKIT_DECLARE_BUTTON macro. TOOLKIT_DECLARE_BUTTON and TOOLKIT_IMPLEMENT_BUTTON should be defined as follows:
#define TOOLKIT_DECLARE_BUTTON(class_name) \
public: \
static const AFX_DATA SECButtonClass class##class_name; \
TOOLKIT_API virtual SECButtonClass* GetButtonClass() const; \
TOOLKIT_API static SECStdBtn* PASCAL CreateButton();
#define TOOLKIT_IMPLEMENT_BUTTON(class_name) \
SECStdBtn* PASCAL class_name::CreateButton() \
{ return new class_name; } \
const AFX_DATADEF SECButtonClass class_name::class##class_name = { \
class_name::CreateButton }; \
SECButtonClass* class_name::GetButtonClass() const \
{ return ((SECButtonClass*)(&class_name::class##class_name)); } \