I have read about the chain of responsibility design pattern (http://www.pluralsight.com/articlecontent/cpprep0796.htm
) and am implementing it in a simple dialog based application. However, I have come across a concern, and am wondering if how I am about to implement this pattern is correct or not.
I have a dialog class CMyDlg. I have a custom command target class CMyCommandTarget. The dialog class has an instance of the command target class, and in its OnCmdMsg function, it forwards commands to this command target, just as in the example linked to above. Now, say I have a button on my dialog, that, when clicked, is to disable another button on the dialog. So I have
// Disable some button, say, with ID IDC_MYBUTTON, or, even better,
// CMyDlg::m_myButton with DDX
How does CMyCommandTarget know about IDC_MYBUTTON, or CMyDlg::m_myButton ? (I know there are many obvious ways of doing this, but *I want to do it the best way*).
I am considering:
1) Pass a pointer to the dialog in the CMyCommandTarget constructor, and access controls via access functions.
2) Do the same as 1), except make the command target class a friend of the dialog, thereby avoiding excessive access functions.
3) A suggestion by you experts ??
What is the proper way, and the way that pro programmers use ? (There are enough of you participate on EE, so someone must have come across this.)