Звезда не активнаЗвезда не активнаЗвезда не активнаЗвезда не активнаЗвезда не активна
 
TCHAR buf_to_add_field[100];

void AppendText(HWND hwndOutput, char * newText )
{
  // convert to wchar_t array
  mbstowcs(buf_to_add_field, newText, sizeof(buf_to_add_field)/sizeof(TCHAR));
  // get new length to determine buffer size
  int outLength = GetWindowTextLength( hwndOutput ) + lstrlen(buf_to_add_field) + 1;
  
  // create buffer to hold current and new text and some extra for new string
  TCHAR * buf = ( TCHAR * ) GlobalAlloc( GPTR, outLength * sizeof(TCHAR) + 4 );
  if (!buf) return;
  
  // get existing text from edit control and put into buffer
  GetWindowText( hwndOutput, buf, outLength );
  
  // append the newText to the buffer
  wcscat (buf, buf_to_add_field );
  // add a new string
  wcscat (buf, L"\n");
  // Set the text in the edit control
  
  SetWindowText( hwndOutput, buf );
  /// scroll to the end
  SendMessageA(hwndOutput, EM_SETSEL, 0, -1); //Select all
  SendMessageA(hwndOutput, EM_SETSEL, -1, -1);
  SendMessageA(hwndOutput, EM_SCROLLCARET, 0, 0); //Set scrollcaret to the current Pos
  
  // free the buffer
  GlobalFree( buf );
}