Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dialog Base Class using static member afx message functions and static member variable

9 views
Skip to first unread message

valenci...@gmail.com

unread,
Feb 13, 2006, 8:38:11 PM2/13/06
to
I have a need to use a base class for CDialog in which I would like to
reuese a static member vector.

I only want one instance of the personel vector in memory
but I want the ability to open multiple employee dialogs whether Bosses
or Workers.


Class CDataThread::CWndThread
{

public:
RegisterForData(HWnd*); // CEmployeeDlg will register for post
messages


}

// implemtation of datathread will PostMessage(m_Hwnd, UpdateVector);
// posting vector updates to the Base CEmployeeDlg which will maintian
only one copy of
// pPersonelData.

Class CEmployeeDlg: CDialog
{
CEmployeeDlg::CEmployeeDlg(*hwnd)
{
if(!m_bFirst_Instance)
pDataThread->RegisterForData(this->hwnd);
m_bFirst_Instance=true;
};

static m_bFirst_Instance;
static std::vector *pPersonelData;

afx_msg void OnUpdateVector(); // somehow static and maintains
one static copy of
//
pPersonelData.
};

Class CBossDlg::CBaseDlg
{
CBossDlg::CBossDlg()

// Timer refreshes dialog data with pPersonelData gathered from the
base
// class CEmployeeDlg for a particular Boss.
}


Class CWorkerDlg::CBaseDlg
{
CWorkerDlg::CWorkerDlg()

// Timer refreshes dialog data with pPersonelData gathered from
the base
// class CEmployeeDlg for a particular Worker.
}

The dialogs are very similar only slight differences on controls.
Can this be done by only registering one hwnd to the DataThread so as
to limit the datahandler to post only one message to the CEmployeeDlg
having only one employee vector shared by all open dialogs. Of course
I will lock the vector when making changes etc...

Thanks,

Diana

0 new messages