Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
2.3 KiB

  1. // ChildView.cpp : implementation of the CChildView class
  2. //
  3. #include "stdafx.h"
  4. #include "mditest.h"
  5. #include "ChildView.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CChildView
  13. CChildView::CChildView()
  14. : _hwndEdit(NULL)
  15. {
  16. }
  17. CChildView::~CChildView()
  18. {
  19. }
  20. BEGIN_MESSAGE_MAP(CChildView,CWnd )
  21. //{{AFX_MSG_MAP(CChildView)
  22. ON_WM_PAINT()
  23. ON_WM_CREATE()
  24. ON_WM_SIZE()
  25. //}}AFX_MSG_MAP
  26. END_MESSAGE_MAP()
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CChildView message handlers
  29. BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs)
  30. {
  31. if (!CWnd::PreCreateWindow(cs))
  32. return FALSE;
  33. cs.dwExStyle |= WS_EX_CLIENTEDGE;
  34. cs.style &= ~WS_BORDER;
  35. cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,
  36. ::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_WINDOW+1), NULL);
  37. return TRUE;
  38. }
  39. void CChildView::OnPaint()
  40. {
  41. CPaintDC dc(this); // device context for painting
  42. // Do not call CWnd::OnPaint() for painting messages
  43. }
  44. int CChildView::OnCreate(LPCREATESTRUCT pcs)
  45. {
  46. if (CWnd ::OnCreate(pcs) == -1)
  47. return -1;
  48. RECT rc;
  49. GetClientRect( &rc );
  50. _hwndEdit = CreateWindowEx( 0, TEXT("Edit"), NULL,
  51. WS_CHILD|WS_VISIBLE|WS_VSCROLL|ES_MULTILINE|ES_AUTOHSCROLL,
  52. 0, 0, RECTWIDTH(&rc), RECTHEIGHT(&rc), *this, NULL,
  53. AfxGetInstanceHandle(), 0 );
  54. if( IsWindow( _hwndEdit ) )
  55. {
  56. HFONT hf = CreateFont(-14, 0,0,0, FW_NORMAL, 0,0,0, ANSI_CHARSET, 0,0,0,0, TEXT("MS Sans Serif") );
  57. if( hf )
  58. ::SendMessage( _hwndEdit, WM_SETFONT, (WPARAM)hf, 0 );
  59. for( int i = 0; i < 100; i++ )
  60. {
  61. ::SendMessage( _hwndEdit, EM_REPLACESEL, 0,
  62. (LPARAM)TEXT("Some random text and some more random text and some more random text. ")\
  63. TEXT("Some random text and some more random text and some more random text.\r\n") );
  64. ::SendMessage( _hwndEdit, EM_SETSEL, -1, -1 );
  65. }
  66. }
  67. return 0;
  68. }
  69. void CChildView::OnSize(UINT nType, int cx, int cy)
  70. {
  71. CWnd ::OnSize(nType, cx, cy);
  72. if( IsWindow( _hwndEdit ) )
  73. {
  74. ::SetWindowPos( _hwndEdit, NULL, 0, 0, cx, cy, SWP_NOZORDER|SWP_NOACTIVATE );
  75. }
  76. }