I'm playing around with an MFC (dialog-based exe) project in MSVC++ 6.0 and I've run into a problem. I've spent 2 full days searching the web and haven't found an answer. It seems that it should be straight forward. Here goes:
Description of the overall project:
I created a project named paint. The main app instantiates an object called "dlg" (is this what happens?)of class CPaintDlg. It is a dialog box. I created a control class CPinButton that is derived from CButton (I added more functionality to the class) and I placed the control on the dialog. The CPaintDlg object instantiates a CButton object called "m_button1" (is this what happens?) of class CPinButton. There is a standard edit box control on the dialog box with a member variable "m_uiVariable" mapped to it. Now when I double-click the right mouse button on m_button1, I want to increment the member variable "m_uiVariable" and update the dialog box. I can do all this except I ran into the following problem:
Problem:
The class CPinButton has no know knowledge of CPaintDlg so CPinButton::OnRButtonDblClk(...) cannot increment m_uiVariable. It has no knowledge of the variable or any functions in CPaintDlg. I tried creating a pointer to the "dlg" object and a pointer to a function "CPaintDlg::UpdateVariable()" (the function increments the variable and updates the dialog box) and passing them to CPinButton. That didn't work (maybe I was just doing it wrong). I just can't seem to get any association between the two classes. Is there any way to do this? It should be easy, right??
I'm getting desperate. Any help or direction at all will be greatly appreciated!
Description of the overall project:
I created a project named paint. The main app instantiates an object called "dlg" (is this what happens?)of class CPaintDlg. It is a dialog box. I created a control class CPinButton that is derived from CButton (I added more functionality to the class) and I placed the control on the dialog. The CPaintDlg object instantiates a CButton object called "m_button1" (is this what happens?) of class CPinButton. There is a standard edit box control on the dialog box with a member variable "m_uiVariable" mapped to it. Now when I double-click the right mouse button on m_button1, I want to increment the member variable "m_uiVariable" and update the dialog box. I can do all this except I ran into the following problem:
Problem:
The class CPinButton has no know knowledge of CPaintDlg so CPinButton::OnRButtonDblClk(...) cannot increment m_uiVariable. It has no knowledge of the variable or any functions in CPaintDlg. I tried creating a pointer to the "dlg" object and a pointer to a function "CPaintDlg::UpdateVariable()" (the function increments the variable and updates the dialog box) and passing them to CPinButton. That didn't work (maybe I was just doing it wrong). I just can't seem to get any association between the two classes. Is there any way to do this? It should be easy, right??
I'm getting desperate. Any help or direction at all will be greatly appreciated!