Click here to Skip to main content
15,844,673 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
When I am writing in first dialog IDD_SERVICES_DIALOG ServicesDlg.cpp edit control void CServicesDlg::EdtCompanyName() and click at a button void CServicesDlg::BtnNextSecondDlg(), I want to put this data to third dialog IDD_DIALOG2 ThirdDlg.cpp and make it show in void CThirdDlg::EdtCompanyNameEnd().

What I have tried:

I have tried writing down to ChatGPT, but it didn't work for now. I am using ChatGPT because I am a newbie in MFC App, I have student internships for earning money and I don't have enough time to read some tutorials from microsoft.com .When I go home I like to rest like most of the people. I did some code in first dialog like that:
C++
void CServicesDlg::BtnNextSecondDlg()
{
   CThirdDlg dlgThird;
   dlgThird.SetCompanyName(m_companyName); // Przekazanie danych do CThirdDlg

	if (dlgThird.DoModal() == IDOK)
	{
		// Tutaj możesz obsłużyć wynik, jeśli to jest konieczne
	}
And third dialog like that:
// Wyświetl dane w kontrolce EdtCompanyNameEnd (załóżmy, że to kolejne pole Edit w Twoim dialogu)
	SetDlgItemText(IDC_EDIT1, m_strCompanyName);

	// W miejscu, gdzie otwierasz dialog ThirdDlg
	CThirdDlg dlgThird;
	dlgThird.m_strCompanyName = m_strCompanyName; // Przypisz wartość
	INT_PTR nResponse2 = dlgThird.DoModal();

	if (nResponse2 == IDOK)
	{
		// Zaktualizuj m_strCompanyName, jeśli użytkownik dokonał zmian
		m_strCompanyName = dlgThird.m_strCompanyName;
	}

When I write something in edit control void CServicesDlg::EdtCompanyName(), click on button void CServicesDlg::BtnNextSecondDlg() and click on button void CSecondDlg::BtnNextThirdDlg() I don't see any data in void CThirdDlg::EdtCompanyNameEnd() and when I want to edit CThirdDlg::EdtCompanyNameEnd() it gives me sort overflow.
Posted
Updated 12-Sep-23 5:51am
v4
Comments
Dave Kreskowiak 4-Sep-23 12:16pm    
ChatGPT can NOT write code if it's any more complex than "Hello World".
Richard MacCutchan 12-Sep-23 10:55am    
I cannot see any logic in that code, or decide what it is supposed to do. I get the distinct impression that you do not really understand how to use dialogs, and you are just throwing random code together and hoping for the best.

You keep repeating what is essentially the same question, and expecting ChatGPT to write the code for you, which is unlikely. And as I keep telling you, you can find out all you need to know about edit controls at CEdit Class | Microsoft Learn[^].
 
Share this answer
 
If I interpret the question correctly there are two dialogs ServicesDlg and CThirdDlg. On the ServicesDlg dialog there is an Edit control EdtCompanyName and a button BtnNextSecondDlg. If you press the button, the text from EdtCompanyName should be taken over and the ServicesDlg dialog should be closed? After that a new dialog with an edit control EdtCompanyNameEnd should be opened directly and the saved text should be displayed there again?

Here I assumed that both dialogs are modal dialogs, which are displayed with DoModal().
Usually such dialogs are terminated with one of the buttons OK or Cancel. With OK, data is usually accepted by the caller, with Cancel, all input is usually discarded. So the button BtnNextSecondDlg could be the OK button?

An alternative would be that both dialogs are not modal and are displayed simultaneously with the main program. The first dialog would then not have to be closed. The dialogs would then behave like multiple windows. To display data from a control in one window also in another control in another window you could send the text as a message to the control.

A better description of the problem as well as excerpts of the source code would possibly allow better answers. I suspect that ChatGPT would also need more specifics to make suggestions.

I would suggest that you first read how dialogs work, then start the corresponding program. If you have concrete questions or problems you could discuss them here.

Maybe a link to these topics will help: Working with Dialog Boxes in MFC
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900