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.

111 lines
2.3 KiB

  1. // NCEditView.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ncbrowse.h"
  5. #include "NCEditView.h"
  6. #include "ncbrowsedoc.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CNCEditView
  14. IMPLEMENT_DYNCREATE(CNCEditView, CEditView)
  15. CNCEditView::CNCEditView()
  16. {
  17. }
  18. CNCEditView::~CNCEditView()
  19. {
  20. }
  21. BEGIN_MESSAGE_MAP(CNCEditView, CEditView)
  22. //{{AFX_MSG_MAP(CNCEditView)
  23. ON_WM_CREATE()
  24. //}}AFX_MSG_MAP
  25. END_MESSAGE_MAP()
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CNCEditView drawing
  28. void CNCEditView::OnDraw(CDC* pDC)
  29. {
  30. CNcbrowseDoc* pDoc = GetDocument();
  31. // TODO: add draw code here
  32. }
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CNCEditView diagnostics
  35. #ifdef _DEBUG
  36. void CNCEditView::AssertValid() const
  37. {
  38. CEditView::AssertValid();
  39. }
  40. void CNCEditView::Dump(CDumpContext& dc) const
  41. {
  42. CEditView::Dump(dc);
  43. }
  44. CNcbrowseDoc* CNCEditView::GetDocument() // non-debug version is inline
  45. {
  46. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CNcbrowseDoc)));
  47. return (CNcbrowseDoc*)m_pDocument;
  48. }
  49. #endif //_DEBUG
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CNCEditView message handlers
  52. void CNCEditView::OnInitialUpdate()
  53. {
  54. CEditView::OnInitialUpdate();
  55. GetEditCtrl().SetReadOnly(TRUE);
  56. }
  57. int CNCEditView::OnCreate(LPCREATESTRUCT lpCreateStruct)
  58. {
  59. if (CEditView::OnCreate(lpCreateStruct) == -1)
  60. return -1;
  61. GetDocument()->m_pEditView = this;
  62. // TODO: Add your specialized creation code here
  63. HFONT hFont;
  64. hFont = (HFONT)GetStockObject(SYSTEM_FIXED_FONT);
  65. SendMessage(WM_SETFONT, (WPARAM)hFont, FALSE);
  66. CEdit &editCtrlRef = GetEditCtrl();
  67. return 0;
  68. }
  69. BOOL CNCEditView::ScrollToLine(DWORD dwLineNum)
  70. {
  71. CEdit &editCtrlRef = GetEditCtrl();
  72. int nFirstVisible = editCtrlRef.GetFirstVisibleLine();
  73. int nLinesToScroll = (dwLineNum - nFirstVisible) - 5;
  74. editCtrlRef.LineScroll(nLinesToScroll, 0);
  75. int nBegin, nEnd, nLen;
  76. if ((nBegin = editCtrlRef.LineIndex(dwLineNum-1)) != -1)
  77. {
  78. nLen = editCtrlRef.LineLength(nBegin);
  79. nEnd = nBegin + nLen + 2;
  80. editCtrlRef.SetSel(nBegin, nEnd);
  81. }
  82. return FALSE;
  83. }