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.

171 lines
4.4 KiB

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "KeyRing.h"
  5. #include "MainFrm.h"
  6. #include "keyobjs.h"
  7. #include "machine.h"
  8. #include "KeyDView.h"
  9. #include "KRDoc.h"
  10. #include "KRView.h"
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16. CKeyRingView* g_pTreeView;
  17. CKeyDataView* g_pDataView;
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CMainFrame
  20. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  21. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  22. //{{AFX_MSG_MAP(CMainFrame)
  23. // NOTE - the ClassWizard will add and remove mapping macros here.
  24. // DO NOT EDIT what you see in these blocks of generated code !
  25. ON_WM_CREATE()
  26. //}}AFX_MSG_MAP
  27. // Global help commands
  28. ON_COMMAND(ID_HELP_FINDER, CFrameWnd::OnHelpFinder)
  29. ON_COMMAND(ID_HELP, CFrameWnd::OnHelp)
  30. ON_COMMAND(ID_CONTEXT_HELP, CFrameWnd::OnContextHelp)
  31. ON_COMMAND(ID_DEFAULT_HELP, CFrameWnd::OnHelpFinder)
  32. END_MESSAGE_MAP()
  33. static UINT indicators[] =
  34. {
  35. ID_SEPARATOR, // status line indicator
  36. ID_INDICATOR_CAPS,
  37. ID_INDICATOR_NUM,
  38. ID_INDICATOR_SCRL,
  39. };
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CMainFrame construction/destruction
  42. //--------------------------------------------------------------
  43. CMainFrame::CMainFrame()
  44. {
  45. }
  46. //--------------------------------------------------------------
  47. CMainFrame::~CMainFrame()
  48. {
  49. }
  50. //--------------------------------------------------------------
  51. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  52. {
  53. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  54. return -1;
  55. if (!m_wndToolBar.Create(this) ||
  56. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  57. {
  58. TRACE0("Failed to create toolbar\n");
  59. return -1; // fail to create
  60. }
  61. if (!m_wndStatusBar.Create(this) ||
  62. !m_wndStatusBar.SetIndicators(indicators,
  63. sizeof(indicators)/sizeof(UINT)))
  64. {
  65. TRACE0("Failed to create status bar\n");
  66. return -1; // fail to create
  67. }
  68. // TODO: Remove this if you don't want tool tips or a resizeable toolbar
  69. m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  70. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  71. // TODO: Delete these three lines if you don't want the toolbar to
  72. // be dockable
  73. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  74. EnableDocking(CBRS_ALIGN_ANY);
  75. DockControlBar(&m_wndToolBar);
  76. return 0;
  77. }
  78. //--------------------------------------------------------------
  79. BOOL CMainFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
  80. CCreateContext* pContext)
  81. {
  82. // create the static splitter window
  83. if ( !m_wndSplitter.CreateStatic( this, 1, 2 ) )
  84. {
  85. TRACE0("Failed to CreateStaticSplitter\n");
  86. return FALSE;
  87. }
  88. // the initial size of the first pane should be a function of the width of the view
  89. // add the first splitter pane - The machine tree view
  90. if (!m_wndSplitter.CreateView(0, 0,
  91. pContext->m_pNewViewClass, CSize(260, 50), pContext))
  92. {
  93. TRACE0("Failed to create machine tree pane\n");
  94. return FALSE;
  95. }
  96. // add the second splitter pane - the key list view
  97. if (!m_wndSplitter.CreateView(0, 1,
  98. RUNTIME_CLASS(CKeyDataView), CSize(0, 0), pContext))
  99. {
  100. TRACE0("Failed to create key data view pane\n");
  101. return FALSE;
  102. }
  103. // activate the machine tree view
  104. SetActiveView((CView*)m_wndSplitter.GetPane(0,0));
  105. g_pTreeView = (CKeyRingView*)m_wndSplitter.GetPane(0,0);
  106. g_pDataView = (CKeyDataView*)m_wndSplitter.GetPane(0,1);
  107. // return success
  108. return TRUE;
  109. }
  110. //--------------------------------------------------------------
  111. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  112. {
  113. // set the initial size of the application window
  114. // it is sized to fit the data form view pane
  115. cs.cx = 566;
  116. cs.cy = 530;
  117. return CFrameWnd::PreCreateWindow(cs);
  118. }
  119. /////////////////////////////////////////////////////////////////////////////
  120. // CMainFrame diagnostics
  121. #ifdef _DEBUG
  122. //--------------------------------------------------------------
  123. void CMainFrame::AssertValid() const
  124. {
  125. CFrameWnd::AssertValid();
  126. }
  127. //--------------------------------------------------------------
  128. void CMainFrame::Dump(CDumpContext& dc) const
  129. {
  130. CFrameWnd::Dump(dc);
  131. }
  132. #endif //_DEBUG
  133. /////////////////////////////////////////////////////////////////////////////
  134. // CMainFrame message handlers
  135. //--------------------------------------------------------------
  136. // we just want the title of the app in the title bar
  137. void CMainFrame::OnUpdateFrameTitle(BOOL bAddToTitle)
  138. {
  139. CFrameWnd::OnUpdateFrameTitle(FALSE);
  140. }