MFC and Rebar 
Author Message
 MFC and Rebar

I give up.
I am really new to MS VC++.
I am using the MFC appwizard to create a simple single document app with a
CHtmlView that has a Rebar on the mainframe.  In the Rebar I place a CButton
and an CEdit control.  All I am trying to do is retrieve, when the button is
pushed, a url from the CEdit control so that I can then call the Navigate2
function with that string.  Again all of this is done with a message handler
in the CHtmlView::OnButton1(). A class CUrlDlg is added to the project to
represent the IDR_MAINFRAME dialog, which I refered to as Rebar earlier(I am
not sure that term is correct).  I have tried using GetWindowTextLength()
and GetWindowText() but each time I try an assertion(exception??) is thrown.
How can I use the DDX without first calling DoModal()?
Any help appreciated.

I have been able to retreive the url by creating a regular CDialog from a
menu entry, a code snippet follows:

// CBrowserView message handlers
void CBrowserView::OnDialog1()
{
  CUrlDlg d;
  d.DoModal();
  Navigate2(_T(d.getURL()),NULL,NULL);

Quote:
}

DDX transfers the string to the variable I associated with the CEdit
control.


Wed, 11 Feb 2004 01:01:40 GMT  
 MFC and Rebar


Quote:
> I give up.
> I am really new to MS VC++.
> I am using the MFC appwizard to create a simple single document app with a
> CHtmlView that has a Rebar on the mainframe.  In the Rebar I place a
CButton
> and an CEdit control.  All I am trying to do is retrieve, when the button
is
> pushed, a url from the CEdit control so that I can then call the Navigate2
> function with that string.  Again all of this is done with a message
handler
> in the CHtmlView::OnButton1(). A class CUrlDlg is added to the project to
> represent the IDR_MAINFRAME dialog, which I refered to as Rebar earlier(I
am
> not sure that term is correct).  I have tried using GetWindowTextLength()
> and GetWindowText() but each time I try an assertion(exception??) is
thrown.
> How can I use the DDX without first calling DoModal()?
> Any help appreciated.

I have thought about this quite abit and I don't think it can be done.
Well, at least with my level of experience, which is real close to NONE with
MFC. It may require editing beyond that provided by the ClassWizard, etc..,
which at this point is beyond my capability.
So I will move on and do some examples that I know I can complete.

Mike



Wed, 11 Feb 2004 10:31:53 GMT  
 MFC and Rebar
Mike!

Realizing that it is necessary to step down a bit when learning shows a good
deal of common sense. Continue like this, and you'll become a great
programmer.

Johan Rosengren


Quote:



> > I give up.
> > I am really new to MS VC++.
> > I am using the MFC appwizard to create a simple single document app with
a
> > CHtmlView that has a Rebar on the mainframe.  In the Rebar I place a
> CButton
> > and an CEdit control.  All I am trying to do is retrieve, when the
button
> is
> > pushed, a url from the CEdit control so that I can then call the
Navigate2
> > function with that string.  Again all of this is done with a message
> handler
> > in the CHtmlView::OnButton1(). A class CUrlDlg is added to the project
to
> > represent the IDR_MAINFRAME dialog, which I refered to as Rebar
earlier(I
> am
> > not sure that term is correct).  I have tried using

GetWindowTextLength()

- Show quoted text -

Quote:
> > and GetWindowText() but each time I try an assertion(exception??) is
> thrown.
> > How can I use the DDX without first calling DoModal()?
> > Any help appreciated.

> I have thought about this quite abit and I don't think it can be done.
> Well, at least with my level of experience, which is real close to NONE
with
> MFC. It may require editing beyond that provided by the ClassWizard,
etc..,
> which at this point is beyond my capability.
> So I will move on and do some examples that I know I can complete.

> Mike



Wed, 11 Feb 2004 14:41:48 GMT  
 MFC and Rebar


Quote:
> Mike!

> Realizing that it is necessary to step down a bit when learning shows a
good
> deal of common sense. Continue like this, and you'll become a great
> programmer.

Thanks for the encouragement!


Wed, 11 Feb 2004 22:23:19 GMT  
 MFC and Rebar

Quote:



> > I give up.
> > I am really new to MS VC++.
> > I am using the MFC appwizard to create a simple single document app with a
> > CHtmlView that has a Rebar on the mainframe.  In the Rebar I place a
> CButton
> > and an CEdit control.  All I am trying to do is retrieve, when the button
> is
> > pushed, a url from the CEdit control so that I can then call the Navigate2
> > function with that string.  Again all of this is done with a message
> handler
> > in the CHtmlView::OnButton1(). A class CUrlDlg is added to the project to
> > represent the IDR_MAINFRAME dialog, which I refered to as Rebar earlier(I
> am
> > not sure that term is correct).  I have tried using GetWindowTextLength()
> > and GetWindowText() but each time I try an assertion(exception??) is
> thrown.
> > How can I use the DDX without first calling DoModal()?
> > Any help appreciated.

The GetWindowTextLength and GetWindowText functions call the underlying
Windows edit control for the information.  That edit control does not
exist before the call to DoModal, and it does not exist when DoModal
returns.  You must get infomation out of the control into member
variables before the edit control is destroyed.  In a dialog this is
usualy done in OnOK().  Then the code that follows DoModal can read the
member variables that save the information.

--
Scott McPhillips [VC++ MVP]



Thu, 12 Feb 2004 00:43:35 GMT  
 MFC and Rebar


Quote:




<snip>

Quote:
> The GetWindowTextLength and GetWindowText functions call the underlying
> Windows edit control for the information.  That edit control does not
> exist before the call to DoModal, and it does not exist when DoModal
> returns.  You must get infomation out of the control into member
> variables before the edit control is destroyed.  In a dialog this is
> usualy done in OnOK().  Then the code that follows DoModal can read the
> member variables that save the information.

Yeah, I think I understand that.
When using the AppWizard I chose the "Internet Explorer Rebars" option.
Part of my problem is that I associated that Rebar with a CDialog object.
When first opening the ClassWizard a dialog pops up and requests that the
Rebar or IDR_MAINFRAME(I am not sure if this is the correct term) be
associated with a class.  I just chose the CDialog, which I think was a
mistake.  I should have associated it with the CMainFrame class because that
is where the handles are to the resource.   So I am mixing apples and
oranges.  What I was trying to do is retrieve the string/url from the CEdit
control in the Rebar to use in the Navigate2 function of the CViewHtml
class.
I know I could do some hacking to get it to work but I am simply am tired of
hacking like that.  That is why, I am moving on.  There has to be clean way
of doing it and until I understand what that way is - I am putting it on the
shelf.

Mike



Thu, 12 Feb 2004 00:12:07 GMT  
 MFC and Rebar

Quote:




<snip>

This is kind of a hack but once I learned about some of the functions in the
CWnd class, it was relatively easy.  I am not sure that it follows good OO
principles though but here it is.

void CMainFrame::OnButton1()
{
 CString m_str;
 m_wndDlgBar.GetDlgItemText(IDC_EDIT1, m_str);
 ((CSimpleBrowserView*)GetActiveView())->Navigate2(m_str, 0, NULL);

Quote:
}

When the ClassWizard prompts to associate the IDR_MAINFRAME resource to a
particular class, I associated it with CMainFrame.  And then added the
message handler for the button I added to the IDR_MAINFRAME resource.  I
also added a CEdit control to the resource.  Pretty simple but again I am
not sure that it follows good OO principles.  Quite frankly their is no
other way of doing it.  It must be done from the CMainFrame class.  The
framework forces you to do it this way because the handles to the
IDR_MAINFRAME resource  are in this class.

Onto greener pastures!!!
THE END!



Thu, 12 Feb 2004 08:09:17 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. non-mfc rebar

2. Rebars in MFC for Windows CE

3. Transparent Rebar/Toolbar (MFC VC++ 6.0)

4. How can I use Coolbar(Rebar) in MFC?

5. How to use Rebar from Commctrl in MFC?

6. Rebars for MFC

7. Trouble getting creating a Rebar in an MFC app

8. Rebar and MFC

9. Rebar/Coolbar in MFC

10. rebar in mfc

11. ReBar / CoolBar MFC support

12. ReBar / CoolBar MFC support

 

 
Powered by phpBB® Forum Software