templated class

V

Vincent RICHOMME

Hi,

I would need some help to write a templated function or method.
I am developping a GUI and on one plateform I am using a listbox
(CListBox) while on the other it's a combobox(CCombobox).
Both controls derived from a the same base class CWnd like this :

class CComboBox : public CWnd
{
....
int AddString(LPCTSTR lpszString);
}

class CListBox : public CWnd
{
....
int AddString(LPCTSTR lpszItem);
}


in my dialog I would like to write a method that take a CComboBox or a
CListBox and call the AddString method.



class CMyDialog : public CDialog
{
// take a CListBox or CCombobox
template<typename TList>
int AddListEntry(Tlist& List, LPCTSTR tszText, DWORD dwItemData);


void OnInitDialog()
{
AddListEntry(ListCtl, "eze", 0);
}



#ifdef PLATFORM1
CCombobox m_ListCtl;
#else
CListBox m_ListCtl;
#endif
};





How can I do that ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,265
Latest member
TodLarocca

Latest Threads

Top