Tabbed dialog
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: Tabbed dialog

  1. #1
    Join Date
    Nov 2012
    Posts
    19

    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

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,927

    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

  3. #3
    Join Date
    Nov 2012
    Posts
    19

    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.

  4. #4
    Join Date
    Nov 2012
    Posts
    19

    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);

  5. #5
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,927

    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

  6. #6
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,927

    Re: Tabbed dialog

    Quote Originally Posted by terryeverlast View Post
    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

  7. #7
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,291

    Re: Tabbed dialog

    Quote Originally Posted by terryeverlast View Post
    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

  8. #8
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,055

    Re: Tabbed dialog

    Quote Originally Posted by terryeverlast View Post
    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.

  9. #9
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,291

    Re: Tabbed dialog

    Quote Originally Posted by terryeverlast View Post
    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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center