CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Location
    Surrey, England
    Posts
    23

    Displaying a database record in CEditView

    VC++6.0, Windows 98

    I am hoping someone can help me.

    I have created an application with AppWizard, using document/view, and
    have turned it into a splitter application with three panes, one of
    which is a CEditView. In this editview I wish to display a text message
    which is in a text field in a local Access database.

    I have put the following code in the CEditView class constructor:

    CPTEditView::CPTEditView()
    {
    CSplytRecordset MyRecordset;
    MyRecordset.Open();
    MyRecordset.MoveFirst();

    CEdit &pEdit = GetEditCtrl();

    pEdit.SetWindowText((LPCTSTR)MyRecordset.m_Subjectfld);
    }




    In the above I have opened a CDAORecordset, and accessed the first
    record, and tried to display it in the editview with SetWindowText from
    the underlying edit control. The program compiles OK, but when I run it
    I get a debug error in the base CWnd::SetWindowText in the MFC file
    Winocc.cpp:


    void CWnd::SetWindowText(LPCTSTR lpszString)
    {
    ASSERT(::IsWindow(m_hWnd));

    if (m_pCtrlSite == NULL)
    ::SetWindowText(m_hWnd, lpszString);
    else
    m_pCtrlSite->SetWindowText(lpszString);
    }




    The program fails on the assert.

    What am I doing wrong? Should I not try and display the text in the
    editview constructor? The program seems not to be able to find the edit
    control underlying the editview.

    All help would be appreciated, especially with code.

    TrimTrom

    ----------------------------------
    Paul Trimming
    Email: [email protected]
    4, High St, Merstham
    Surrey RH1 3EA, England
    ----------------------------------


  2. #2
    Guest

    Re: Displaying a database record in CEditView

    Tried TexOut Function???

    Kitai


  3. #3
    Guest

    Re: Displaying a database record in CEditView

    Place the call to SetWindowText later (ie: CPTEditView::OnInitialUpdate).


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured