|
-
April 9th, 1999, 09:18 PM
#1
Need help getting text from edit box into client area
I'm building an HTML Editor (MFC Appwizard) and I've created a dialog to
insert hyperlinks.The dialog contains 2 edit boxes IDC_HYP_EDIT
(m_hyp/member variable) andIDC_TEXT_EDIT (m_text/member variable)
The idea here is you type the URL into the first edit box and the text
you want displayed into the second edit box,you then push the insert button (IDOK) and this inserts the link into the HTML code. The problem is that I
can't seem to figure out how to insert the text from the edit boxes into the
client area (MDI Child Window)this is the code that I am using:
void CGoldenFlashHTMLEditorView::OnOpenHyplink()
{
CHypLinkDialog HLdlg;
if (HLdlg.DoModal() ==IDOK)
{
CString m_hyp;
CString m_text;
GetEditCtrl().ReplaceSel("<A HREF=");
GetEditCtrl().ReplaceSel(m_hyp);
GetEditCtrl().ReplaceSel(">");
GetEditCtrl().ReplaceSel(m_text);
GetEditCtrl().ReplaceSel("</A>");
}
}
Any body know what is wrong or missing? There are no build errors it just inserts everything except the text from the edit boxes.
-
April 9th, 1999, 09:45 PM
#2
Re: Need help getting text from edit box into client area
You want to have 2 CStrings in your CHypLinkDialog class.
CString m_hyp;
CString m_text;
You can do that in the class wizard and adding member variables for
each of the 2 edit controls.
Then again in your CHypLinkDialog dialog class
create 2 public functions:
CString GetHyperLink()
CString GetLinkText()
Those 2 functions should simply return m_hyp and m_text respectively.
Also in CHypLinkDialog you'll need to override OnOk and do
an UpdateData(TRUE)
Now you can do this:
CHypLinkDialog HLdlg;
if (HLdlg.DoModal() ==IDOK)
{
CString m_hyp = HLdlg.GetHyperlink();
CString m_text = HLdlg.GetLinkText();
-
April 9th, 1999, 09:49 PM
#3
Re: Need help getting text from edit box into client area
Clearly if you see when the following line of code is executed, the dialog is already destroyed, so m_text and m_hyp are not valid.-->
if (HLdlg.DoModal() ==IDOK)
///////////
// you may have to do the following
//in CGoldenFlashHTMLEditorView class, define following member variables.
public:
CString m_text;
CString m_hyp;
//in the dialog class, add following function.
//include view's header in dialogs cpp in the end.
....
#include "GoldenFlashHTMLEditorView.h"
//in the onok() function() do the following
..
void CHdlg::OnOK()
{
CGoldenFlashHTMLEditorView* pView = ( CGoldenFlashHTMLEditorView* )GetParent();
UpdateData(TRUE);
pView->m_text = m_text;
pView->m_hyp = m_hyp;
return CDialog::OnOk();
}
//// that should solve your problem....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|