Want more features on Pastebin? Sign Up, it's FREE!
Guest

win32 insert into rich edit

By: r00m on Jun 7th, 2011  |  syntax: C++  |  size: 0.53 KB  |  views: 142  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. void insertMessage(HWND hWnd, char *message) {
  2.  
  3.   // get handle
  4.   HWND hEdit1 = GetDlgItem(hWnd, IDC_MAIN_EDIT);
  5.  
  6.   // get string length
  7.   int strLen = GetWindowTextLength(hEdit1);
  8.  
  9.   // allocate memory
  10.   char *buffer = new char[strLen+strlen(message)+11];
  11.  
  12.   // get text
  13.   GetWindowText(hEdit1, buffer, strLen + 1);
  14.  
  15.  
  16.   // update window text
  17.   SetWindowText(hEdit1, buffer);
  18.  
  19.   // auto scroll
  20.   SendMessage(hEdit1, WM_VSCROLL, (WPARAM)SB_BOTTOM, MAKELPARAM(FALSE, 0));
  21.  
  22.   // free allocated memory
  23.   delete [] buffer;
  24.  
  25. }
clone this paste RAW Paste Data