Hi Guys,
I'm trying to write a program (MFC) that while working displays a log to the user. For this log I thought I'd use an Edit Box because I can set it to be "multiline".
What I had in mind is to display each new log entry in a new row. Now I don't know any other function that I can use in order to display my text except "SetWindowText".
I tried using it with "LineScroll()" to write to a new line but it doesn't work. It only overwrites the first row.
So clearly I'm using the wrong function and maybe even the wrong Object to display my log.
Please Help....

Thank you,
Gadi

The problem is easy to solve, instead of adding a new line to the text box, simply add the line to a global string, then assign the string to the textbox.

#include <windows.h>
#include <iostream>

HWND hEdit; // Text Box
std::string log;

void AddLogLine(char *line) {
  log += line;
  log += "\n";
  SetWindowText( hEdit, log.c_str() );
}

/* Rest of the Code *

You could also consider using a Listbox instead.

Hope this helps.

Okay the idea with the string worked! (Only for some reason "\n" isn't enough and you need to write "\r\n").
But I would've thought there is a much simpler way to do this using MFC. Maybe there's some object for output to dialog window using the "<<" operator?

I don't use MFC, so i'm not sure. Either way, as far as I know, there's no function in the windows api that allows you to add text to a window. If it were me, i'd just stick with the way I just showed you :icon_cheesygrin: It works.

Okay,
thanks a lot!! I'll stick to your method.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.