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

Thread: Help with ReBar

  1. #1
    Join Date
    Apr 1999
    Posts
    8

    Help with ReBar

    I have made a simple sdi program with a rebar in vc++6.0
    And I have put an edit box on the rebar. How can I get data from the edit box.
    Please explain because I´m a real beginner!

    thanx


  2. #2
    Join Date
    Apr 1999
    Posts
    3

    Re: Help with ReBar

    A Rebar is nothing but an enhanced toolbar added with VC++6.0 to give that 'flat' look & feel.
    When appwizard created that rebar for u it has also added a member variable (say CReBar m_rebar) in MainFrm.h. The actual creation is done in CMainFrame::OnCreate(). Use that member variable to get a handle to the edit box. And then get the data from it. The code snippet is below:
    CWnd *pWnd = m_rebar.GetDlgItem(IDC_MYEDIT);//Where IDC_MYEDIT is the ID of the edit control added by u on the rebar dialog template.
    CString str;
    pWnd->GetWindowText(str); //str will contain the edit box contents
    Hope this helps )


  3. #3
    Join Date
    Apr 1999
    Posts
    8

    Doesn't work

    I tried it but the program exits and I get an assert message on
    pWnd->GetWindowText(str);
    here
    ASSERT(::IsWindow(m_hWnd));
    what am I doing wrong?


  4. #4
    Join Date
    Apr 1999
    Posts
    3

    Re: Doesn't work

    It basically means that the CWnd pointer to the edit control is not proper. Reasons may be due to invalid ID passed to GetDlgItem() or the wrong place where u are doing it. Could u paste the code snippet and the function where u are doing it?


  5. #5
    Join Date
    Apr 1999
    Posts
    8

    Re: Doesn't work

    When I type something in the edit box this functions is called.
    I named the edit box IDC_EDIT
    void CMainFrame::OnChangeEdit()
    {
    CWnd *pWnd = m_wndReBar.GetDlgItem(IDC_EDIT);
    CString str;
    pWnd->GetWindowText(str);
    MessageBox(str);
    }



  6. #6
    Join Date
    Apr 1999
    Posts
    8

    Re: Doesn't work

    it works..
    I changed m_wndReBar.GetDlgItem(IDC_EDIT)
    to
    m_wndDlgBar.GetDlgItem(IDC_EDIT)

    When I type something in the edit box and push enter I want to use the CHtmlView function Navigate2 to transfer me to the location that I typed in. But the problem is that m_wndDlgBar is a CMainFrm member. How can I get the data in my edit box in my CView class?
    Like this
    void CTestView::GetData()
    {
    CString str
    Get the data in my edit box
    Navigate2(str,NULL,NULL);
    }




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