History Edit Control


This sample was contributed by Ravi Bhavnani.

CHistoryEdit is a CEdit derived control that lets you to display a scrolling text history, much like Dev Studio's "Output" window during a compilation. Here's an example of the control (the "History" window) being used in a dialog box.

CHistoryEdit demo

CHistoryEdit's AppendString() method appends a text string to the control and automatically scroll the most recent entry into view. Two other methods, AllowSelection() and IsSelectable() allow you to control whether the user may select text in the control.

Using CHistoryEdit in a dialog is quite simple:

  1. Include CHistoryEdit.h in your dialog class' header file.

  2. Add member variables of type CHistoryEdit for every edit control you want to subclass.

  3. Subclass the edit controls in your dialog's OnInitDialog() method.

      m_HistoryEdit.SubclassDlgItem (EDIT_HISTORY, this);

  4. Append text to the control by using AppendString().

      m_HistoryEdit.AppendString ("Compiling D:\\XDA\\Test\\Mechanic.kb...");

Download source files (2 K) CHistoryEdit.cpp, CHistoryEdit.h
Download demo project (14 K) (includes sources)

Last updated: 11 April 1998



Comments

  • clarisonic plus reduced printing is present in australia

    Posted by iouwanzi on 06/05/2013 11:01pm

    [url=http://www.miaclarisonicaustralia.org/clarisonic-mia]clarisonic mia[/url] Denne nye forretninger med salget af den seneste teknologiske udvikling og kvalitetsudvikling i beats af forskellige mærker er en ganske næring til en. Kompatibilitet er også en grund, der gør folk kører efter de nye versioner på markedet. Beats by Dre er en af de mest populære mærker, når det kommer til hovedtelefoner af højeste kvalitet. News viser, at de har et partnerskab med Apple om at levere et eksklusivt sæt hovedtelefoner der er helt mindre i antal, men ganske højt i prisklasse. Monster beats er også en anden vigtig mærke i serien. [url=http://www.australiaclarisonic.com/clarisonic-mia]clarisonic mia[/url] BIII booo din troede involverer let jazz, med essentials involverer normal, god ole ‘, sammen med digitalkameraer sange for dig at lave en ny specifikt eksklusiv lyd. BIII øjeblikket omdefinerer private musik ekspertise til at gøre dine musikernes øretelefoner. Enhver observere, hver eneste nuance, kan optaget med aldrig-hørt-før realistisk look, plus iøjnefaldende design og stil trådløse høretelefoner bestemt ved en ny trompet mundstykke har som en installation vidnesbyrd om den mestre kunsten. Disse former for sædvanligvis er ikke kun de bedste ørepuder vedrørende jazz. Uanset hvad nogen hører, vil BIII sikkert vokset til betragtes som en af dine nuværende all-time musikalske teknologi højder. [url=http://www.australiaclarisonic.com/]clarisonic brush[/url] Medmindre selvfølgelig, at du hellere træt, du aldrig kommer i seng, headsets i tillæg til et program, ferie kontorstol, nikkende, venter på dine vegne. Uanset om du er under metroen, workout, til hjemmet, hvor du arbejder af anden vej, for eksempel, giver næsten de fleste mennesker et headset hver eneste dag. Men når du burde “dele” enhver sang alle lytte, vil du have en persons Beats det alle.

    Reply
  • How many lines can this control display?

    Posted by Legacy on 09/28/2003 12:00am

    Originally posted by: dann

    How many lines can this control display?

    Reply
  • Easier Win32 Method with 6 lines of code.

    Posted by Legacy on 08/02/2003 12:00am

    Originally posted by: Sean

    void AppendText (HWND hwndEditControl, char * szText)
    
    {//Appends text to an edit control and scrolls down.

    int iTextLength=0;

    iTextLength = SendMessage(hwndEditControl, WM_GETTEXTLENGTH , 0, 0);

    SendMessage(hwndEditControl, EM_SETSEL, iTextLength, iTextLength);

    SendMessage(hwndEditControl, EM_REPLACESEL, 0, (LPARAM)(LPCTSTR)szText);

    SendMessage(hwndEditControl, EM_SCROLL, SB_LINEDOWN, 0);

    }


    Reply
  • One question (read)

    Posted by Legacy on 10/05/2002 12:00am

    Originally posted by: icewolf

    How can I check if the vertical scrollbar is at bottom? I only want it to auto scroll down if the scrollbar is on bottom. (like in mIRC)

    Thanks.

    Reply
  • Thanks a lot

    Posted by Legacy on 05/28/2002 12:00am

    Originally posted by: sangjin

    Thanks...

    This Class is exactly the one I really needed!

    Reply
  • its more trouble than its worth?

    Posted by Legacy on 04/24/2002 12:00am

    Originally posted by: jon

    i cant believe how much trouble this simple little
    box has given me! its so simple but why doesnt it work?

    my latest problem is when i restore the window (after being minimized) it blows up. this is only one of the several issues with it...

    sigh..

    Reply
  • ExEditors Library

    Posted by Legacy on 03/19/2002 12:00am

    Originally posted by: Mike Philips

    A complete collection of editors in a single file:
    
    

    http://www.exontrol.com/sg.jsp?content=products/exeditors

    Regards,
    Mike

    Reply
  • AddString() for CEdit

    Posted by Legacy on 12/15/2001 12:00am

    Originally posted by: Kim Ji Hoon

    void CTestgame01View::AddString(CString msg)
    
    {
    CString strNickName;
    m_pNickNameBox.GetWindowText(strNickName);
    //CString strTemp="<"+strNickName+"> "+msg;
    CString strTemp=msg;
    strTemp+="\r\n";
    int len=m_pChatBox.GetWindowTextLength();
    m_pChatBox.SetSel(len,len);
    m_pChatBox.ReplaceSel(strTemp);
    }

    Reply
  • Take a look at this one...

    Posted by Legacy on 12/02/2001 12:00am

    Originally posted by: Decisoft

    ... it converts ALL edit controls to drop-downs with history: http://www.decisoft.com

    Reply
  • 'ReplaceSel' without scrolling?

    Posted by Legacy on 02/20/2001 12:00am

    Originally posted by: Tony Smith

    Can anyone help me?
    Is is possible to disable the scroll functionality in the CEdit::ReplaceSel(..) function in the same way the CEdit::SetSel(..) functions does.

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • Protecting business operations means shifting the priorities around availability from disaster recovery to business continuity. Enterprises are shifting their focus from recovery from a disaster to preventing the disaster in the first place. With this change in mindset, disaster recovery is no longer the first line of defense; the organizations with a smarter business continuity practice are less impacted when disasters strike. This SmartSelect will provide insight to help guide your enterprise toward better …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds