Data from one dlg to another
-
Hi, I need help again :) I have one dialog which I will call InvoiceDlg. On this dialog I have some controls. Lets say I have a static control called IDC_INVOICENUMBER. I have a button, IDC_TENDER, and when this button is pressed it will open another dlg called TenderDlg. I want to be able to get the data from InvoiceDlg into TenderDlg. I've tried alot of things such as:
void CInvoice::OnTender() { CString invoicenumber; GetDlgItemText(IDC_INVOICENUMBER,invoicenumber); CTender dlg; dlg.DoModal(); dlg.m_invoiceme.SetWindowText(invoicenumber); }
and;void CInvoice::OnTender() { // TODO: Add your control notification handler code here CString invoicenumber; GetDlgItemText(IDC_INVOICENO,invoicenumber); CTender dlg; dlg.DoModal(); dlg.SetDlgItemText(IDC_INVOICE, _T(invoicenumber)); }
Both these compile with no dramas, however when I try them in the app; they dont do anything, its like they aren't even passing on the data through CTender dlg; Can someone please help me?! Im tired, I want to goto bed :(( lol Thanks Ashman -
Hi, I need help again :) I have one dialog which I will call InvoiceDlg. On this dialog I have some controls. Lets say I have a static control called IDC_INVOICENUMBER. I have a button, IDC_TENDER, and when this button is pressed it will open another dlg called TenderDlg. I want to be able to get the data from InvoiceDlg into TenderDlg. I've tried alot of things such as:
void CInvoice::OnTender() { CString invoicenumber; GetDlgItemText(IDC_INVOICENUMBER,invoicenumber); CTender dlg; dlg.DoModal(); dlg.m_invoiceme.SetWindowText(invoicenumber); }
and;void CInvoice::OnTender() { // TODO: Add your control notification handler code here CString invoicenumber; GetDlgItemText(IDC_INVOICENO,invoicenumber); CTender dlg; dlg.DoModal(); dlg.SetDlgItemText(IDC_INVOICE, _T(invoicenumber)); }
Both these compile with no dramas, however when I try them in the app; they dont do anything, its like they aren't even passing on the data through CTender dlg; Can someone please help me?! Im tired, I want to goto bed :(( lol Thanks AshmanAshman wrote: dlg.DoModal(); dlg.SetDlgItemText(IDC_INVOICE, _T(invoicenumber)); The call to dlg.DoModal will show the dialog and therefore any further code in your function won't be executed until the dialog is closed. You'll need to pass the CString into your class before DoModal and then inside the WM_INITDIALOG handler, set the window text of the control. e.g
void CInvoice::OnTender() { // TODO: Add your control notification handler code here CString invoicenumber; GetDlgItemText(IDC_INVOICENO,invoicenumber); CTender dlg; dlg.m_strInvoiceNo = invoiceNumber; dlg.DoModal(); } BOOL CTender::OnInitDialog() { CDialog::OnInitDialog(); m_invoiceme.SetWindowText(m_strInvoiceNo); }
Michael But you know when the truth is told, That you can get what you want or you can just get old, Your're going to kick off before you even get halfway through. When will you realise... Vienna waits for you? - "The Stranger," Billy Joel