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
Printable View
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
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 :o)
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?
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?
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);
}
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);
}