Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7527743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:10:50+00:00 2026-05-30T04:10:50+00:00

I have an EDIT control created like this: hwndEDIT_5 = CreateWindowEx ( 0, EDIT,

  • 0

I have an EDIT control created like this:

hwndEDIT_5 = CreateWindowEx (
  0, "EDIT",  NULL,
  WS_VSCROLL | WS_BORDER | WS_VISIBLE | WS_CHILD | ES_MULTILINE | ES_READONLY,
  135, 450, 555, 200,
  h2, ( HMENU ) ID_EDIT_CONSOLE,
  h1, NULL
);

As you can see it is a read-only EDIT area where multi lines text can be displayed. It is supposed to be a console where I can display some information for users when they use the program. I would like the text area to automatically scroll to the bottom-most entry (the newest one) whenever a new line (or message for an user) is added. I’ve implemented this:

 SetDlgItemText ( h2, ID_EDIT_CONSOLE, ch_s );
 SCROLLINFO scr;
 SCROLLINFO * scr_p = &scr;
 scr.cbSize = sizeof ( SCROLLINFO );
 scr.fMask = SIF_RANGE;
 GetScrollInfo ( GetDlgItem ( h2, ID_EDIT_CONSOLE), SB_VERT, scr_p );
 int mmax = scr.nMax;
 scr.fMask = SIF_POS;
 scr.nPos = mmax;
 SetScrollInfo ( GetDlgItem ( h2, ID_EDIT_CONSOLE), SB_VERT, scr_p, TRUE );

That code is scrolling vertical scrollbar to the end of an EDIT control after adding new msg and it works great, the scrollbar gets scrolled but the text still remains visible from the beginning – it rewinds to the beginning after addition while scrollbar rewinds to the bottom. How to make it properly?

Last but not least – this is might be important – in order to display a message firstly I capture the text that is already displayed by using:
GetDlgItemText ( h2, ID_EDIT_CONSOLE, buf, len + 1 );
then I convert buf into string and add to that string a new message that I want to display. Then I convert it back to char array and set it up with SetDlgItemText. I seperate lines by using \r\n. I’ve coded it that way because I didn’t know how to add a line to an EDIT control in different way than using SetDlgItemText. And it adds only one entry AFAIK – if used twice I will not come up with two entries added to an EDIT control, but the first one will get replaced by second function call.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:10:52+00:00Added an answer on May 30, 2026 at 4:10 am

    You can add text by setting the beginning and end of the selection to the end of the text in the control (EM_SETSEL), then replacing the (empty) selection with your new text (EM_REPLACESEL).

    Scrolling to the bottom can be done with EM_SCROLLCARET after the caret (the selection) is at the end of the text. There are other ways, but if you’re doing it immediately after adding text, this is probably the easiest.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to develop using MVVM: I have this Csla.PropertyStatus control that is created in
I have created my own ControlTemplate for Button, like this: <Style x:Key=LightButtonStyle TargetType={x:Type ButtonBase}>
Ok I created simple user control that look like this <%@ Control Language=C# AutoEventWireup=true
I have a dialog-based app with an edit-control in it. When I minimize /
Using MS Visual Studio, I have attached a spin control to an edit control
I have been using the .NET WebBrowser control in edit mode as part of
How to implement CEditListCtrl?. List control with edit capabality (Report/Grid view). I have a
I currently have a user control that is used on both an /Address/Edit and
I've got a treeview control, and have caught its after-label-edit event. I want to
I'm creating a custom charting control and I would like to have the possibility

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.