void insertMessage(HWND hWnd, char *message) { // get handle HWND hEdit1 = GetDlgItem(hWnd, IDC_MAIN_EDIT); // get string length int strLen = GetWindowTextLength(hEdit1); // allocate memory char *buffer = new char[strLen+strlen(message)+11]; // get text GetWindowText(hEdit1, buffer, strLen + 1); // update window text SetWindowText(hEdit1, buffer); // auto scroll SendMessage(hEdit1, WM_VSCROLL, (WPARAM)SB_BOTTOM, MAKELPARAM(FALSE, 0)); // free allocated memory delete [] buffer; }