SHARE
TWEET

win32 insert into rich edit

r00m Jun 7th, 2011 178 Never
  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. }
RAW Paste Data
Top