Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modeless Dialog's & Data Transfer...

Status
Not open for further replies.

DrkPaladin

Programmer
May 18, 2002
33
CA
I would like to create a modeless dialog that runs in the background that I can use to transfer data to and take data from it with mutliple modal dialogs...

I created my Modeless Dialog using this:
//////////////////////////////////////////////
CStatisticsDlg *pStats = new CStatisticsDlg();

pStats->Create(IDD_STATISTICS, this);
pStats->ShowWindow(SW_SHOW);
//////////////////////////////////////////////
and my Modal Dialogs using this:
//////////////////////////////////////////////
CBeginningDlg dlgBegin(this);
dlgBegin.DoModal();
//////////////////////////////////////////////

What is the code to transfer data to and take data from the Modeless Dialog???
 
If I understand you correctly I'd use Custom SendMessages for this. So that when the data in a control in the Modeless Dlg was updated the control would then:

SendMessage(HWND_BROADCAST (or hWnd if you know it), XYZ_CTRL_UPDATED, 0, (LPARAM) m_EditCtrl.GetBuffer(m_EditCtrl.GetLength())) ;

In the Modal Dlg it then listens for the XYZ_CTRL_UPDATED message and then updates it display.

OnXYZUpdated(WPARAM, LPARAM lParam)
{
char * pPtr = (char *) lParam ;
MyEditControl.SetWindowText(pPtr) ;
}


HTH

William
Software Engineer
ICQ No. 56047340
 
Isn't there a simpler way...
I was thinking using something like:

pStats->m_Variable = m_Variable;
m_Variable = pStats->m_Variable;

I am a beginner
Thanks...
 
I successfully open the modeless dialog and send the information throught to it from a Main modal dialog... At the same time another modal dialog opens then i get a error, "debug assertion failed" and brings me to this line:
//**********************************************************
BOOL CWnd::UpdateData(BOOL bSaveAndValidate)
{
-> ASSERT:):IsWindow(m_hWnd));
// calling UpdateData before DoModal?

CDataExchange dx(this, bSaveAndValidate);
//**********************************************************
In my main dialog when I open the Modeless Dialog and Modal Dialog and send the information to the modeless one I have:
//**********************************************************
//*****Main Dialog On New Button*****
UpdateData();
CMenuDlg dlgMenu(this);

CStatisticsDlg *pStats = new CStatisticsDlg();

//***Open Statistics Dialog***
pStats->Create(IDD_STATISTICS, this);
pStats->ShowWindow(SW_SHOW);

pStats->UpdateData();
//Time
pStats->m_Sec = 0;
pStats->m_Min = 0;
pStats->m_Hour = 0;
pStats->UpdateData(FALSE);

dlgMenu.DoModal();
UpdateData(FALSE);
//***********************************
//**********************************************************
In my OnInitDialog of my Menu Dialog I have:
//*****Menu Dialog OnInitDialog*****
UpdateData();

CStatisticsDlg *pStats = new CStatisticsDlg();

pStats->UpdateData();
//Time
m_Hour = pStats->m_Hour;
m_Min = pStats->m_Min;
m_Sec = pStats->m_Sec;
pStats->UpdateData(FALSE);

UpdateData(FALSE);
//**********************************
//**********************************************************
Its when the Menu Dialog open that I get the Error...

Please Help Me.
Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top