Leaked source code of windows server 2003
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.

355 lines
9.3 KiB

  1. #include "precomp.h"
  2. #pragma hdrstop
  3. #include "private.h"
  4. #include "mainform.h"
  5. #include "resource.h"
  6. IMPLEMENT_DYNCREATE( MainForm, CFrameWnd )
  7. BEGIN_MESSAGE_MAP( MainForm, CFrameWnd )
  8. ON_WM_CREATE()
  9. ON_WM_CLOSE()
  10. ON_WM_SIZING()
  11. ON_COMMAND(ID_FILE_LOAD_HOSTLIST, OnFileLoadHostlist)
  12. ON_COMMAND(ID_FILE_SAVE_HOSTLIST, OnFileSaveHostlist)
  13. ON_COMMAND( ID_WORLD_CONNECT, OnWorldConnect )
  14. ON_COMMAND( ID_WORLD_NEW, OnWorldNewCluster )
  15. ON_COMMAND( ID_REFRESH, OnRefresh )
  16. ON_COMMAND( ID_CLUSTER_PROPERTIES, OnClusterProperties )
  17. ON_COMMAND( ID_CLUSTER_REMOVE, OnClusterRemove )
  18. ON_COMMAND( ID_CLUSTER_UNMANAGE, OnClusterUnmanage )
  19. ON_COMMAND( ID_CLUSTER_ADD_HOST, OnClusterAddHost )
  20. ON_COMMAND( ID_OPTIONS_CREDENTIALS, OnOptionsCredentials )
  21. ON_COMMAND( ID_OPTIONS_LOGSETTINGS, OnOptionsLogSettings )
  22. ON_COMMAND_RANGE( ID_CLUSTER_EXE_QUERY, ID_CLUSTER_EXE_RESUME,
  23. OnClusterControl )
  24. ON_COMMAND_RANGE( ID_CLUSTER_EXE_PORT_CONTROL, ID_CLUSTER_EXE_PORT_CONTROL,
  25. OnClusterPortControl )
  26. ON_COMMAND( ID_HOST_PROPERTIES, OnHostProperties )
  27. ON_COMMAND( ID_HOST_STATUS, OnHostStatus )
  28. ON_COMMAND( ID_HOST_REMOVE, OnHostRemove )
  29. ON_COMMAND_RANGE( ID_HOST_EXE_QUERY, ID_HOST_EXE_RESUME,
  30. OnHostControl )
  31. ON_COMMAND_RANGE( ID_HOST_EXE_PORT_CONTROL, ID_HOST_EXE_PORT_CONTROL,
  32. OnHostPortControl )
  33. END_MESSAGE_MAP()
  34. MainForm::MainForm()
  35. : m_pLeftView(NULL)
  36. {
  37. m_bAutoMenuEnable = FALSE;
  38. }
  39. //
  40. // 2/14/01: JosephJ This is used by class Document -- couldn't figure
  41. // out what MFC calls to make to get the main frame class.
  42. // See notes.txt entry:
  43. // 02/14/2002 JosephJ Processing UI updates in the foreground
  44. //
  45. CWnd *g_pMainFormWnd;
  46. int
  47. MainForm::OnCreate( LPCREATESTRUCT lpCreateStruct )
  48. {
  49. static const unsigned int indicator = ID_SEPARATOR;
  50. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  51. return -1;
  52. statusBar.Create( this );
  53. statusBar.SetIndicators( &indicator, 1 );
  54. g_pMainFormWnd = this;
  55. return 0;
  56. }
  57. BOOL MainForm::PreCreateWindow(CREATESTRUCT& cs)
  58. {
  59. if( !CFrameWnd::PreCreateWindow(cs) )
  60. return FALSE;
  61. // The following will prevent the "-" getting added to the window title
  62. cs.style &= ~FWS_ADDTOTITLE;
  63. return TRUE;
  64. }
  65. LRESULT
  66. MainForm::WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
  67. //
  68. // For design information, see notes.txt entry:
  69. // 02/14/2002 JosephJ Processing UI updates in the foreground
  70. //
  71. {
  72. if (message == MYWM_DEFER_UI_MSG)
  73. {
  74. CUIWorkItem *pWorkItem = NULL;
  75. Document *pDocument = this->GetDocument();
  76. pWorkItem = (CUIWorkItem *) lParam;
  77. if (pWorkItem != NULL && pDocument != NULL)
  78. {
  79. pDocument->HandleDeferedUIWorkItem(pWorkItem);
  80. }
  81. delete pWorkItem;
  82. return 0;
  83. }
  84. else
  85. {
  86. return CFrameWnd::WindowProc(message, wParam, lParam);
  87. }
  88. }
  89. /*
  90. * Method: OnSizing
  91. * Description: This method is called when the main window is being re-sized.
  92. * We use this callback to preserve the window size ratios by
  93. * moving the splitter windows as the window is re-sized.
  94. */
  95. void
  96. MainForm::OnSizing(UINT fwSide, LPRECT pRect)
  97. {
  98. /* Call the base class OnSizing method. */
  99. CFrameWnd::OnSizing(fwSide, pRect);
  100. // go for 30-70 split column split
  101. // and 60-40 row split.
  102. CRect rect;
  103. GetWindowRect( &rect );
  104. splitterWindow2.SetColumnInfo( 0, rect.Width() * 0.3, 10 );
  105. splitterWindow2.SetColumnInfo( 1, rect.Width() * 0.7, 10 );
  106. splitterWindow2.RecalcLayout();
  107. splitterWindow.SetRowInfo( 0, rect.Height() * 0.6, 10 );
  108. splitterWindow.SetRowInfo( 1, rect.Height() * 0.4, 10 );
  109. splitterWindow.RecalcLayout();
  110. }
  111. BOOL
  112. MainForm::OnCreateClient( LPCREATESTRUCT lpcs, CCreateContext* pContext )
  113. {
  114. // create the splitter window.
  115. // it is really a splitter within a splitter
  116. // ---------------------------------
  117. // | | List |
  118. // | | |
  119. // | Tree | |
  120. // | | |
  121. // |-------------------------------|
  122. // | Edit |
  123. // | |
  124. // | |
  125. // ---------------------------------
  126. // left pane is a treeview control
  127. // right pane is another splitter with listview control
  128. // and bottom is editview control.
  129. splitterWindow.CreateStatic( this, 2, 1 );
  130. // create nested splitter.
  131. splitterWindow2.CreateStatic( &splitterWindow, 1, 2,
  132. WS_CHILD | WS_VISIBLE | WS_BORDER,
  133. splitterWindow.IdFromRowCol( 0, 0 )
  134. );
  135. splitterWindow2.CreateView( 0,
  136. 0,
  137. RUNTIME_CLASS( LeftView ),
  138. CSize( 0, 0 ),
  139. pContext );
  140. splitterWindow2.CreateView( 0,
  141. 1,
  142. RUNTIME_CLASS( DetailsView ),
  143. CSize( 0, 0 ),
  144. pContext );
  145. //
  146. // Save a way a pointer to the left view -- we use this to send
  147. // it menu operations.
  148. //
  149. m_pLeftView = (LeftView*) splitterWindow2.GetPane(0,0);
  150. //
  151. // create log view
  152. //
  153. splitterWindow.CreateView( 1,
  154. 0,
  155. RUNTIME_CLASS( LogView ),
  156. CSize( 0, 0 ),
  157. pContext );
  158. // go for 30-70 split column split
  159. // and 60-40 row split.
  160. CRect rect;
  161. GetWindowRect( &rect );
  162. splitterWindow2.SetColumnInfo( 0, rect.Width() * 0.3, 10 );
  163. splitterWindow2.SetColumnInfo( 1, rect.Width() * 0.7, 10 );
  164. splitterWindow2.RecalcLayout();
  165. splitterWindow.SetRowInfo( 0, rect.Height() * 0.6, 10 );
  166. splitterWindow.SetRowInfo( 1, rect.Height() * 0.4, 10 );
  167. splitterWindow.RecalcLayout();
  168. return TRUE;
  169. }
  170. // world level.
  171. void MainForm::OnFileLoadHostlist()
  172. {
  173. if (m_pLeftView != NULL) m_pLeftView->OnFileLoadHostlist();
  174. }
  175. void MainForm::OnFileSaveHostlist()
  176. {
  177. if (m_pLeftView != NULL) m_pLeftView->OnFileSaveHostlist();
  178. }
  179. void MainForm::OnWorldConnect()
  180. {
  181. if (m_pLeftView != NULL) m_pLeftView->OnWorldConnect();
  182. }
  183. void MainForm::OnWorldNewCluster()
  184. {
  185. if (m_pLeftView != NULL) m_pLeftView->OnWorldNewCluster();
  186. }
  187. // cluster level.
  188. void MainForm::OnRefresh()
  189. {
  190. if (m_pLeftView != NULL) m_pLeftView->OnRefresh(FALSE);
  191. }
  192. void MainForm::OnClusterProperties()
  193. {
  194. if (m_pLeftView != NULL) m_pLeftView->OnClusterProperties();
  195. }
  196. void MainForm::OnClusterRemove()
  197. {
  198. if (m_pLeftView != NULL) m_pLeftView->OnClusterRemove();
  199. }
  200. void MainForm::OnClusterUnmanage()
  201. {
  202. if (m_pLeftView != NULL) m_pLeftView->OnClusterUnmanage();
  203. }
  204. void MainForm::OnClusterAddHost()
  205. {
  206. if (m_pLeftView != NULL) m_pLeftView->OnClusterAddHost();
  207. }
  208. void MainForm::OnOptionsCredentials()
  209. {
  210. if (m_pLeftView != NULL) m_pLeftView->OnOptionsCredentials();
  211. }
  212. void MainForm::OnOptionsLogSettings()
  213. {
  214. if (m_pLeftView != NULL) m_pLeftView->OnOptionsLogSettings();
  215. }
  216. void MainForm::OnClusterControl(UINT nID )
  217. {
  218. if (m_pLeftView != NULL) m_pLeftView->OnClusterControl(nID);
  219. }
  220. void MainForm::OnClusterPortControl(UINT nID )
  221. {
  222. if (m_pLeftView != NULL) m_pLeftView->OnClusterPortControl(nID);
  223. }
  224. // host level
  225. void MainForm::OnHostProperties()
  226. {
  227. if (m_pLeftView != NULL) m_pLeftView->OnHostProperties();
  228. }
  229. void MainForm::OnHostStatus()
  230. {
  231. if (m_pLeftView != NULL) m_pLeftView->OnHostStatus();
  232. }
  233. void MainForm::OnHostRemove()
  234. {
  235. if (m_pLeftView != NULL) m_pLeftView->OnHostRemove();
  236. }
  237. void MainForm::OnHostControl(UINT nID )
  238. {
  239. if (m_pLeftView != NULL) m_pLeftView->OnHostControl(nID);
  240. }
  241. void MainForm::OnHostPortControl(UINT nID )
  242. {
  243. if (m_pLeftView != NULL) m_pLeftView->OnHostPortControl(nID);
  244. }
  245. void MainForm::OnClose( )
  246. {
  247. Document *pDocument = NULL;
  248. BOOL fBlock = !theApplication.IsProcessMsgQueueExecuting();
  249. //
  250. // Display pending operations ...
  251. //
  252. //
  253. CLocalLogger logOperations;
  254. UINT uCount = 0;
  255. logOperations.Log(IDS_LOG_PENDING_OPERATIONS_ON_EXIT_MSG);
  256. uCount = gEngine.ListPendingOperations(logOperations);
  257. if (uCount != 0)
  258. {
  259. int sel;
  260. sel = ::MessageBox(
  261. NULL,
  262. logOperations.GetStringSafe(),
  263. GETRESOURCEIDSTRING(IDS_LOG_PENDING_OPERATIONS_ON_EXIT_CAP),
  264. MB_ICONINFORMATION | MB_OKCANCEL
  265. );
  266. if (sel != IDOK)
  267. {
  268. goto end;
  269. }
  270. }
  271. pDocument = this->GetDocument();
  272. if (pDocument != NULL)
  273. {
  274. pDocument->PrepareToClose(fBlock);
  275. }
  276. if (fBlock)
  277. {
  278. CFrameWnd::OnClose();
  279. }
  280. else
  281. {
  282. theApplication.SetQuit();
  283. }
  284. end:
  285. return;
  286. }