Advertisement
r00m

win32 insert into rich edit

Jun 7th, 2011
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement