-
April 26th, 2014, 02:11 PM
#1
Tabbed dialog
I have a tabbed dialog with a couple of Separate dialogs. I created classes of CDialog for each dialog. Im trying to get the text from the edit control from the tabbed dialog and it appears in a message box when I press a button on the main dialog.
Code:
myDialog test;
test.UpdateData(TRUE);
CString bla = test.m_edit1;
test.UpdateData(FALSE);
MessageBox(bla,bla,MB_OK);
the m_edit is a variable of CString for the edit box
it gives me a error and crashes
how do I get the text from the other dialogs edit control?
oh yeah..im not cross posting..i deleted this post on stack overflow from no responses
-
April 26th, 2014, 02:25 PM
#2
Re: Tabbed dialog
The code makes no sense. It creates a C++ object without any real window behind it. Of course it must crash on accessing information supposed to be gotten from real window controls.
You should use the dialog object created on activating tab, or earlier maybe. Unfortunately I cannot provide any more detailed advice as I know nothing about your code.
Best regards,
Igor
-
April 26th, 2014, 02:33 PM
#3
Re: Tabbed dialog
Another question.
My thread that I created is global and cannot access the varialbes for my dialgos. How do I fix this?
Code:
UINT WritingThreadFunc(LPVOID pParam)
{
m_ft.UpdateData(TRUE);
m_ft2.UpdateData(TRUE);
CString ok = m_ft.m_dedit1;
CString ok2 = m_ft.m_dedit2;
CString ook3 = m_ft2.m_dedit3;
m_ft.UpdateData(FALSE);
m_ft2.UpdateData(FALSE);
return 0;
}
I call it with
Code:
AfxBeginThread(WritingThreadFunc, NULL);
I tried making those variables virtual..thinking that it would make them global, but that did not work
the error example is
error C2065: 'm_ft' : undeclared identifier
Last edited by terryeverlast; April 26th, 2014 at 02:57 PM.
-
April 26th, 2014, 03:14 PM
#4
Re: Tabbed dialog
I created a object from the original dialog class
I get the error
Debug assertion failed Wincore.cpp line 3095
something to do with updatedata
Code:
CIRCBOTDlg okok;
okok.m_ft.UpdateData(TRUE);
okok.m_ft2.UpdateData(TRUE);
CString AA = okok.m_ft.m_dedit1;
CString AA2 = okok.m_ft.m_dedit2;
CString AA3 = okok.m_ft2.m_dedit3;
okok.m_ft.UpdateData(FALSE);
okok.m_ft2.UpdateData(FALSE);
-
April 26th, 2014, 03:21 PM
#5
Re: Tabbed dialog
You cannot access it like that. You cannot operate with MFC windowed object from any other thread but threat it was created in.
Typically this sort of data exchange is based on windows messages sent from worker thread directly to window controls, or main thread itself. The data can be returned directly via message params, or by means of some global structure object.
Best regards,
Igor
-
April 26th, 2014, 03:32 PM
#6
Re: Tabbed dialog
Originally Posted by terryeverlast
I created a object from the original dialog class
I get the error
Debug assertion failed Wincore.cpp line 3095
something to do with updatedata
Code:
CIRCBOTDlg okok;
okok.m_ft.UpdateData(TRUE);
okok.m_ft2.UpdateData(TRUE);
CString AA = okok.m_ft.m_dedit1;
CString AA2 = okok.m_ft.m_dedit2;
CString AA3 = okok.m_ft2.m_dedit3;
okok.m_ft.UpdateData(FALSE);
okok.m_ft2.UpdateData(FALSE);
You should stop writing random code, and start reading technical documentation instead, on the classes and methods you're trying to use. This is the only way you do things right.
Besides, download some samples from MSDN and learn those carefully. Try to modify the code and see the effect. Learn to trace the code execution in debugger and dig deep enough to see where the problem roots.
You cannot learn programming just by posting odd code snippets to public forums, please be sure of that.
Best regards,
Igor
-
April 26th, 2014, 04:06 PM
#7
Re: Tabbed dialog
Originally Posted by terryeverlast
Another question.
My thread that I created is global and cannot access the varialbes for my dialgos. How do I fix this?
You might want to read this great essay: Using Worker Threads
Victor Nijegorodov
-
April 26th, 2014, 04:10 PM
#8
Re: Tabbed dialog
Originally Posted by terryeverlast
I created a object from the original dialog class
I get the error
Debug assertion failed Wincore.cpp line 3095
something to do with updatedata
Code:
CIRCBOTDlg okok;
okok.m_ft.UpdateData(TRUE);
okok.m_ft2.UpdateData(TRUE);
CString AA = okok.m_ft.m_dedit1;
CString AA2 = okok.m_ft.m_dedit2;
CString AA3 = okok.m_ft2.m_dedit3;
okok.m_ft.UpdateData(FALSE);
okok.m_ft2.UpdateData(FALSE);
In this case, you have instantiated a C++ CDialog object, but it hasn't created the Window and controls it represents yet. When you call UpdateData, you're trying to access Windows controls that don't exist. Igor's right. You won't learn Windows programming by guessing. Find a good tutorial and really get to know it.
-
April 26th, 2014, 04:11 PM
#9
Re: Tabbed dialog
Originally Posted by terryeverlast
I have a tabbed dialog with a couple of Separate dialogs. I created classes of CDialog for each dialog.
Did you consider using the MFC classes CPropertySheet and CPropertyPage instead?
http://msdn.microsoft.com/en-us/libr...(v=vs.90).aspx
http://msdn.microsoft.com/en-us/libr...(v=vs.90).aspx
http://msdn.microsoft.com/en-us/libr...(v=vs.90).aspx
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|