MainFrm.cpp
上传用户:wlkj888
上传日期:2022-08-01
资源大小:806k
文件大小:10k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "resource.h"
  5. #include "MainFrm.h"
  6. #include "Gui_DevStudio.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CMainFrame
  14. IMPLEMENT_DYNAMIC(CMainFrame, CGuiMDIFrame)
  15. BEGIN_MESSAGE_MAP(CMainFrame, CGuiMDIFrame)
  16. //{{AFX_MSG_MAP(CMainFrame)
  17. ON_WM_CREATE()
  18. ON_WM_SIZE()
  19. ON_COMMAND(ID_VIEW_TOOLBAR, OnViewToolbar)
  20. ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
  21. ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, OnUpdateEditPaste)
  22. ON_WM_CLOSE()
  23. ON_COMMAND(ID_VIEW_LOOK_2003, OnViewLook2003)
  24. ON_COMMAND(ID_VIEW_LOOK_XP, OnViewLookXp)
  25. ON_COMMAND(ID_NEW_ITEM, OnNewItem)
  26. ON_COMMAND(ID_UNDO, OnUndo)
  27. ON_COMMAND(ID_REDO, OnRedo)
  28. ON_COMMAND(ID_NAVIBACK, NaviBack)
  29. ON_COMMAND(ID_START, Start)
  30. ON_COMMAND(ID_FINDINFILES, FinFiles)
  31. ON_COMMAND(ID_SOLUTION, Solution)
  32. ON_COMMAND(ID_EXISTITEM,OnExistItem)
  33. ON_COMMAND(ID_ADDCLASS,OnAddClass)
  34. ON_COMMAND(ID_CLASSVIEW,OnClassView)
  35. ON_COMMAND(ID_SERVER,OnServer)
  36. ON_COMMAND(ID_HELP,OnHelp)
  37. ON_COMMAND(ID_OUTPUTNORMAL,OnOutputNormal)
  38. ON_COMMAND(ID_OUTPUT,OnOutput)
  39. ON_COMMAND(ID_WORKSPACE,OnWorkSpace)
  40. ON_WM_SPOOLERSTATUS()
  41. ON_WM_SYSCOLORCHANGE()
  42. //}}AFX_MSG_MAP
  43. END_MESSAGE_MAP()
  44. static UINT indicators[] =
  45. {
  46. ID_SEPARATOR,           // status line indicator
  47. ID_INDICATOR_CAPS,
  48. ID_INDICATOR_NUM,
  49. ID_INDICATOR_SCRL,
  50. };
  51. static UINT Toolbars[] = {
  52. IDR_MAINFRAME,
  53. IDR_TOOLBARS,
  54. IDR_NEWITEM
  55. };
  56. static UINT ToolCombos[] = {
  57. ID_COMBO1,
  58. ID_COMBO2,
  59. ID_COMBO3
  60. };
  61. /////////////////////////////////////////////////////////////////////////////
  62. // CMainFrame construction/destruction
  63. //toolbars
  64. void CMainFrame::OnNewItem()
  65. {
  66. }
  67. void CMainFrame::OnUndo()
  68. {
  69. }
  70. void CMainFrame::OnExistItem(){}
  71. void CMainFrame::OnAddClass(){}
  72. void CMainFrame::OnRedo(){}
  73. void CMainFrame::NaviBack(){}
  74. void CMainFrame::Start(){}
  75. void CMainFrame::FinFiles(){}
  76. void CMainFrame::Solution(){}
  77. void CMainFrame::OnClassView()
  78. {
  79. }
  80. void CMainFrame::OnServer()
  81. {
  82. ShowHideBar(&m_Server);
  83. }
  84. void CMainFrame::OnHelp()
  85. {
  86. ShowHideBar(&m_GuiHelp);
  87. }
  88. void CMainFrame::OnOutputNormal()
  89. {
  90. ShowHideBar(&m_OutNormal);
  91. }
  92. void CMainFrame::OnOutput()
  93. {
  94. ShowHideBar(&m_OutPut);
  95. }
  96. void CMainFrame::OnWorkSpace()
  97. {
  98. ShowHideBar(&m_GuiSolEx);
  99. }
  100. CMainFrame::CMainFrame()
  101. {
  102. // TODO: add member initialization code here
  103. }
  104. CMainFrame::~CMainFrame()
  105. {
  106. }
  107. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  108. {
  109. if (CGuiMDIFrame::OnCreate(lpCreateStruct) == -1)
  110. return -1;
  111. InitMenu(IDR_MAINFRAME);
  112. InitToolBar(IDR_MAINFRAME);
  113. InitStatusBar(indicators,sizeof(indicators)/sizeof(UINT));
  114. m_wndToolBar.SetWindowText("ToolBar");
  115. if (!m_ToolCombos.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
  116. | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC,CRect(0,0,0,0),IDR_TOOLCOMBOS) ||
  117. !m_ToolCombos.LoadToolBar(IDR_TOOLCOMBOS))
  118. {
  119. TRACE0("Failed to create toolbarn");
  120. return -1;      // fail to create
  121. }
  122. if (!m_GuiSolEx.Create(_T("Workspace"),WS_CHILD | WS_VISIBLE, this, 0x999))
  123.     {
  124.         TRACE0("Failed to create m_GuiSolExn");
  125.         return -1;      
  126. }
  127. if (!m_GuiHelp.Create(_T("Help"),WS_CHILD | WS_VISIBLE, this, 0x998))
  128.     {
  129.         TRACE0("Failed to create m_GuiSolExn");
  130.         return -1;     
  131. }
  132. if (!m_OutPut.Create(_T("OutPut"),WS_CHILD | WS_VISIBLE, this, 0x997))
  133.     {
  134.         TRACE0("Failed to create m_GuiSolExn");
  135.         return -1;      
  136. }
  137. if (!m_Server.Create(_T("Server Explorer"),WS_CHILD | WS_VISIBLE, this, 0x996))
  138.     {
  139.         TRACE0("Failed to create m_GuiSolExn");
  140.         return -1;      
  141. }
  142. if (!m_OutNormal.Create(_T("Output Normal"),WS_CHILD | WS_VISIBLE, this, 0x995))
  143.     {
  144.         TRACE0("Failed to create m_GuiSolExn");
  145.         return -1;      
  146. }
  147. m_GuiSolEx.SetBarStyle(m_GuiSolEx.GetBarStyle() |
  148. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  149. m_GuiHelp.SetBarStyle(m_GuiHelp.GetBarStyle() |
  150. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  151. m_OutPut.SetBarStyle(m_OutPut.GetBarStyle() |
  152. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  153. m_Server.SetBarStyle(m_Server.GetBarStyle() |
  154. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  155. m_OutNormal.SetBarStyle(m_OutNormal.GetBarStyle() |
  156. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  157. const DWORD dwStyle =  LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL ;
  158. m_tree.Create (dwStyle, CRect(0,0,100,100), this, 1);
  159. m_tree.ShowWindow(SW_HIDE);
  160. CString str;
  161. for (int i=0;i < 100;i++)
  162. {
  163. str.Format(_T("esta es una cadena larga %d"), i);
  164. m_tree.AddString( str);
  165. }
  166. m_wndToolBar.SetButtonDropDown(ID_FILE_NEW,0,IDR_MENUNEW);
  167. m_wndToolBar.SetButtonDropDown(ID_NEW_ITEM,1,IDR_MENUNEWITEM);
  168. m_wndToolBar.SetButtonDropDown(ID_UNDO,8,&m_tree,_T("Prueba"));
  169. m_wndToolBar.SetButtonDropDown(ID_REDO,9,IDR_MENUNEW);
  170. m_wndToolBar.SetButtonDropDown(ID_CLASSVIEW,14,IDR_MENUTOOLBARS);
  171. m_wndToolBar.SetMenuContext(IDR_MENUTOOLBARS);
  172. // CreateCombos();
  173. m_ToolCombos.CreateCombo(&m_comboDebug,ID_COMBO1,150,WS_CHILD|WS_VISIBLE|CBS_DROPDOWN  | 
  174. WS_VSCROLL | CBS_HASSTRINGS |CBS_OWNERDRAWVARIABLE);
  175. m_ToolCombos.CreateCombo(&m_combo2,ID_COMBO2,150);
  176. CFont m_Font;
  177. m_Font.CreateStockObject (DEFAULT_GUI_FONT);
  178. m_comboDebug.SetFont (&m_Font);
  179. m_combo2.AddString("m_TreeClassView.");
  180. m_combo2.AddString("m_TreeSolExplorer.");
  181. m_combo2.AddString("m_FileView->");
  182. m_combo2.SetFont (&m_Font);
  183. EnableDocking(CBRS_ALIGN_ANY);
  184. m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
  185. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  186. m_ToolCombos.EnableDocking(CBRS_ALIGN_ANY);
  187. m_GuiSolEx.EnableDocking(CBRS_ALIGN_ANY);
  188. m_GuiHelp.EnableDocking(CBRS_ALIGN_ANY);
  189. m_OutPut.EnableDocking(CBRS_ALIGN_ANY);
  190. m_Server.EnableDocking(CBRS_ALIGN_ANY);
  191. m_OutNormal.EnableDocking(CBRS_ALIGN_ANY);
  192. m_GuiSolEx.SetMenuContext(IDR_MENUTOOLBARS);
  193. m_Server.SetMenuContext(IDR_MENUTOOLBARS);
  194. m_GuiHelp.SetMenuContext(IDR_MENUTOOLBARS);
  195. m_OutPut.SetMenuContext(IDR_MENUTOOLBARS);
  196. m_wndMenuBar.SetMenuContext(IDR_MENUTOOLBARS);
  197. DockControlBar(&m_wndMenuBar,m_dockTop);
  198. DockControlBar(&m_wndToolBar,m_dockLeft);
  199. DockControlBar(&m_ToolCombos,m_dockTop);
  200. DockControlBar(&m_GuiSolEx, AFX_IDW_DOCKBAR_RIGHT);
  201. DockControlBar(&m_GuiHelp, AFX_IDW_DOCKBAR_LEFT);
  202. DockControlBar(&m_OutPut, AFX_IDW_DOCKBAR_BOTTOM);
  203. DockControlBar(&m_Server, AFX_IDW_DOCKBAR_LEFT);
  204. DockControlBar(&m_OutNormal, AFX_IDW_DOCKBAR_BOTTOM);
  205. sProfile = _T("Gui_DevStudio");
  206. LoadBars();
  207. InitMDITabbed();
  208. m_MdiTabbed.SetTabsMenu(IDR_MENUTABS);
  209. #define _countof(array) (sizeof(array)/sizeof(array[0]))
  210. m_wndCool.LoadToolbars(Toolbars, _countof(Toolbars));
  211. RecalcLayout();
  212. m_MdiTabbed.SetTabMenu(0,0);
  213. if(m_StyleDisplay== GUISTYLE_2003)
  214. OnViewLook2003();
  215. else
  216. OnViewLookXp();
  217. return 0;
  218. }
  219. void CMainFrame::CreateCombos()
  220. {
  221. CFont m_Font;
  222. m_Font.CreateStockObject (DEFAULT_GUI_FONT);
  223. m_wndToolBar.CreateCombo(&m_comboDebug,ID_COMBODEBUG,150,WS_CHILD|WS_VISIBLE|CBS_DROPDOWN  | 
  224.                     WS_VSCROLL | WS_TABSTOP | CBS_HASSTRINGS |CBS_OWNERDRAWFIXED );
  225. /*m_comboDebug.AddString("Debug");
  226. m_comboDebug.AddString("Release");
  227. m_comboDebug.AddString("Configuration Manager...");
  228. m_comboDebug.SetFont (&m_Font);*/
  229. //m_comboDebug.EnableWindow(FALSE);     
  230. m_wndToolBar.CreateCombo(&m_comboFind,ID_COMBOFIND,200);
  231. m_comboFind.AddString("m_TreeClassView.");
  232. m_comboFind.AddString("m_TreeSolExplorer.");
  233. m_comboFind.AddString("m_FileView->");
  234. m_comboFind.SetFont (&m_Font);
  235. // m_comboFind.EnableWindow(FALSE);
  236. }
  237. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  238. {
  239. if( !CGuiMDIFrame::PreCreateWindow(cs) )
  240. return FALSE;
  241. // TODO: Modify the Window class or styles here by modifying
  242. //  the CREATESTRUCT cs
  243. return TRUE;
  244. }
  245. /////////////////////////////////////////////////////////////////////////////
  246. // CMainFrame diagnostics
  247. #ifdef _DEBUG
  248. void CMainFrame::AssertValid() const
  249. {
  250. CGuiMDIFrame::AssertValid();
  251. }
  252. void CMainFrame::Dump(CDumpContext& dc) const
  253. {
  254. CGuiMDIFrame::Dump(dc);
  255. }
  256. #endif //_DEBUG
  257. /////////////////////////////////////////////////////////////////////////////
  258. // CMainFrame message handlers
  259. void CMainFrame::OnSize(UINT nType, int cx, int cy) 
  260. {
  261. CGuiMDIFrame::OnSize(nType, cx, cy);
  262. // m_MdiTabbed::OnSize((nType, cx, cy);
  263. // TODO: Add your message handler code here
  264. }
  265. void CMainFrame::OnViewToolbar() 
  266. {
  267. // TODO: Add your command handler code here
  268. ShowHideBar(&m_wndToolBar);
  269. }
  270. void CMainFrame::OnEditPaste() 
  271. {
  272. // TODO: Add your command handler code here
  273. }
  274. void CMainFrame::OnUpdateEditPaste(CCmdUI* pCmdUI) 
  275. {
  276. // TODO: Add your command update UI handler code here
  277. pCmdUI->SetCheck();
  278. }
  279. void CMainFrame::OnClose() 
  280. {
  281. // TODO: Add your message handler code here and/or call default
  282. CGuiMDIFrame::OnClose();
  283. }
  284. void CMainFrame::OnWindowCascade()
  285. {
  286. // TODO: Add your command handler code here
  287. }
  288. void CMainFrame::OnViewLook2003() 
  289. {
  290. // TODO: Add your command handler code here
  291. GuiDrawLayer::m_Style=GUISTYLE_2003;
  292. StyleDispl(GUISTYLE_2003);
  293. m_GuiSolEx.StyleDispl(GUISTYLE_2003);
  294. m_GuiHelp.StyleDispl(GUISTYLE_2003);
  295. m_OutPut.StyleDispl(GUISTYLE_2003);
  296. m_Server.StyleDispl(GUISTYLE_2003);
  297. m_OutNormal.StyleDispl(GUISTYLE_2003);
  298. m_ToolCombos.StyleDispl(GUISTYLE_2003);
  299. m_OutPut.StyleDispl(GUISTYLE_2003);
  300. }
  301. void CMainFrame::OnViewLookXp() 
  302. {
  303. // TODO: Add your command handler code here
  304. GuiDrawLayer::m_Style=GUISTYLE_XP;
  305. GuiDrawLayer::m_Theme=0;
  306. m_GuiSolEx.StyleDispl();
  307. m_GuiHelp.StyleDispl();
  308. m_OutPut.StyleDispl();
  309. m_Server.StyleDispl();
  310. m_OutNormal.StyleDispl();
  311. m_ToolCombos.StyleDispl();
  312. StyleDispl();
  313. RecalcLayout();
  314. Invalidate();
  315. UpdateWindow();
  316. }
  317. void CMainFrame::OnSpoolerStatus(UINT nStatus, UINT nJobs) 
  318. {
  319. CGuiMDIFrame::OnSpoolerStatus(nStatus, nJobs);
  320. // TODO: Add your message handler code here
  321. }
  322. void CMainFrame::OnSysColorChange() 
  323. {
  324. CGuiMDIFrame::OnSysColorChange();
  325. GuiDrawLayer::IsThemeXP();
  326. // TODO: Add your message handler code here
  327. }