in MainFrm.h :
class CMainFrame : public FrameWnd
{...
protected:
CString m_strmyString;
CDialogBar m_myDialogBar;
virtual void DoDataExchange( CDataExchange * pDX);
...}
And in MainFrm.cpp:
int CMainFrame:OnCreate(LPCREATESTRUCT lpCreateStruct)
{
...
m_myDialogBar.Create(this, IDD_DIALOGBAR /*the associated Dialog*/,
CBRS_TOP|CBRS_TOOLTIPS|WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS, IDD_DIALOGBAR)
...
}
void CMainFrame::DoDataExchange(CDataExchange*pDX)
{
CMainFrame::DoDataExchange (pDX);
DDX_Text(pDX,IDC_MYEDIT/* the associated edit box for m_strmyString*/
,m_strmyString);
}
Thanks in advance
Yves.
CDialog::DoDataExchange(pDX); before your DDX routines instead of
CMainFrame's
Dave
I don't use CDialogBar, but don't you need to have a derived CDialogBar class
and put the data exchange there? The edits you are talking about are child
controls of the dialog bar, not the mainframe, no?
Burt when you get "Debug assertion failed" you need to go into the debugger
and see what the ASSERT was related to. ASSERT's are your friend, because they
are about to tell you what is wrong with your code.
HTH,
David Wilkinson
=============================
This is one of the few places where UpdateData, which is otherwise
misused, is exactly the right thing to do. Just use ClassWizard in
your dialogs to create the DDXs for value variables. When you want the
values from a dialog, send a user-defined message to the dialog (we're
presumably talking modeless dialogs, like dialog bars, here), telling
it to call UpdateData with the Boolean that causes control values to
be snapped back to the member variables. When this SendMessage
returns, you can simply reach into the dialog's public variables and
retrieve what you want.
My own preference is to send a message to the dialog that retrieves
the value I want, and avoid UpdateData entirely, but if you have a lot
of controls this would be clumsy. Most of my toolbox-like modeless
dialogs have only a couple parameters they are managing.
But get rid of that DoDataExchange in the mainframe. It is
meaningless, harmful, and the wrong approach to the problem.
joe
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm