Originally posted by: JeongHoon Lee
Thanks for your hint...
I have a question.
How can I give priority for Edit control over another control....
I have several class for one project. After I execute the program, I input text in Edit control and press <enter key>.
but I can't see it updated in Edit box and only see executing the other Botton Control.
Only if I press <add> botton, It works very well.
when I press <Enter key>, I want to update it in Edit box.
Give me your advice.
Originally posted by: Mike Genetu
please e-mail me on what ever you think about it
thank you
Hi
I read all of your commnet and it is nice. I wonder if any one of you have an idea or a source code on wide char text edit control. well i mean to use a unicode based font which is a ttf file extention.
Originally posted by: Kevin Cao
Here are two lines will probably save you some time.
void CHistoryEdit::AppendString
(CString str)
{ SendMessage(EM_SETSEL,0xFFFFFFFF,-1);
SendMessage(EM_REPLACESEL,FALSE,(LPARAM)(LPCTSTR)str);
}
Originally posted by: Peggy Van Lierde
void CHistoryEdit::OnSetFocus(CWnd* pOldWnd)
Greetings,
There is a possible crash in OnSetFocus() when the user clicks the HistoryEditBox after clicking a custom control.
{
// Don't allow user to select text
if (m_bSelectable)
CEdit::OnSetFocus (pOldWnd);
else
//if (pOldWnd)
//added check because crash happens in
//SetFocus() if the CWnd* is not a CWindow*
if ((pOldWnd) && (::IsWindow(pOldWnd->m_hWnd)))
pOldWnd->SetFocus();
}
Peggy.
Originally posted by: John Lawrence
Something like this...
void CTextOutputPane::AddLine(LPCTSTR new_line)
// now scroll the text into view
// get the current end of the window
// scroll the bottom into view
I have implemented a similar control. However rather than
using the GetWindowText()/SetWindowText() method (which can
be very slow for large buffers) I have implemented it using
the ReplaceSel() function which, if no text is selected,
inserts text at the current cursor position.
{
// Move the selection to the end of the window
SetSel( -1, -1 );
// put a new line character at the end of the line
CString line(new_line);
line += _T("\r\n");
// replace the selection with the supplied text
ReplaceSel(line);
CPoint point = GetCharPos(GetTextLength());
CRect rect; GetClientRect(&rect);
while (point.y > rect.bottom)
{
LineScroll(1);
point = GetCharPos(GetTextLength());
}
}
Originally posted by: Thomas Russell
void CCoolDlg::AppendString(CString str)
// Append string
// Scroll the edit control
Apologies for extra line breaks in the above listing!
Tom Russell
I was able to implement the Append() function easily by using Class Wizard to add a new function to my dialog class like so:
{
//
// Purpose:
// Appends a text string to the history buffer.
//
// Returns:
// None.
//
CString strBuffer; // current contents of edit control
m_ctlHistory.GetWindowText (strBuffer);
if (!strBuffer.IsEmpty())
strBuffer += "\r\n";
strBuffer += str;
m_ctlHistory.SetWindowText (strBuffer);
m_ctlHistory.LineScroll (m_ctlHistory.GetLineCount(), 0);
}
Originally posted by: Aleksander �hrn
Thanks for a useful control! However, employing it in a project of mine I run into some noticable efficiency
issues. As it is, the control seems best suited for Histories with not too many History items, i.e., with few
lines of messages to the user. Having to repeatedly do a Get/Append/Set seems to bog things down if the
control is "flooded" with very many History items (lines), resulting in a very large text buffer.
Originally posted by: chen liuwei
it took me half day to solve a problem , finally I see your code...
ReplyOriginally posted by: Oleg Pilipenko
1. Set Horizontal scroll and Auto HScroll edit control styles in the dialog resource.
2. Hid the horizontal scrollbar in the OnInitDialog():
m_HistoryEdit.ShowScrollBar(SB_HORZ, FALSE);
3. Modified AppendString() method:
void CHistoryEdit::AppendString
// Append string
CRect rcWindow;
CDC* pDC = GetDC();
if (szText.cx > rcWindow.Width())
ReleaseDC(pDC);
// Scroll the edit control
I have posted a question about smart showing/hiding scroll bars in the CHistoryEdit. I have added horizontal
scroll bar support. To do this I went throug following steps:
(CString str)
//
// Purpose:
// Appends a text string to the history buffer.
//
// Returns:
// None.
//
{
CString strBuffer; // current contents of edit control
GetWindowText (strBuffer);
if (!strBuffer.IsEmpty())
strBuffer += "\r\n";
strBuffer += str;
SetWindowText (strBuffer);
GetWindowRect(rcWindow);
ScreenToClient(rcWindow);
CSize szText = pDC->GetTextExtent(str);
ShowScrollBar(SB_HORZ);
LineScroll (GetLineCount(), 0);
}
Originally posted by: Oleg Pilipenko
Is it possible to extend the CHistoryEdit to show scrollbars only if it has too many lines (vertical scroll bar), or has a long enough line (horizontal scroll bar) ?
Reply