CDialogBar, how to interact with member variables & controls

I have created a CDialogBar, there are some controls on it. Lets say one edit box and one list box. These controls can interact with from the CMainFrame class. But the question is: It is an MDI Application. I need to set value of edit box and list box in the CDialogBar through the View class. In detail:

1. I have a CDialogBar
2. I can interact through CMainFrame.
3. But I want to interact (set and retreive) values from CDlgView class.

Is there any way.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Check out MFC sample CTRLBARS.
All messages from CDialogBar controls are sent to dialog bar parent and not to dialog bar itself. Usually program doesn't contain CDialogBar-derived class, instead of this all controls are managed in the parent form.

See the following code fragments from CTRLBARS sample:

CDialogBar  m_wndDlgBar;

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
    if (!m_wndDlgBar.Create(this, IDD_VIEWSELECT,

void CMainFrame::OnUpdatePalette(CCmdUI* pCmdUI)
    CComboBox* pCBox = (CComboBox*)m_wndDlgBar.GetDlgItem(IDC_PALETTE);    // talk with combobox on the dialog bar
    UINT nIndex = pCBox->GetCurSel();
    pCmdUI->SetCheck((UINT)(ID_PALETTE_BASE + nIndex) == pCmdUI->m_nID);
jhapakAuthor Commented:
I still can't understand it properly. Actually the thing is, I have a document in MDI, when I click in the document, the list box in CDialogBar must also update itself.
Read the sample. Messages from all controls placed on CDialogBar are handled in CMainFrame. For example, if you want to add UPDATE_UI message handler for some control in the dialog bar, add this message handler to CMainFrame. If you want to handle button click, add this handler to CMainFrame.
If you want to access some control and change it's state, do this from CMainFrame. For example, you want to set text in IDC_EDIT1 edit box on CDialogBar. Let's say that CMainnFrame class has public member CDialogBar  m_wndDlgBar. You can add this code to any class:

CMainFrame* pFrame = (CMainFrame*)AfxGetMainFrame();
CEdit* pEdit = (CEdit*)pFrame->m_wndDlgBar.GetDlgItem(IDC_EDIT1);    
pEdit->SetWindowText(_T("New text"));

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jhapakAuthor Commented:
oh man!, I am doing same. But the error is:
'AfxGetMainFrame' : undeclared identifier
jhapakAuthor Commented:
thanks, it worked!
use AfxGetMainWnd instead of AfxGetMainFrame
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.