MainFrm.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. // MainFrm.cpp : CMainFrame 类的实现
  2. //
  3. #include "stdafx.h"
  4. #include "SkinBuilder.h"
  5. #include "MainFrm.h"
  6. #include ".\mainfrm.h"
  7. #include "ImageView.h"
  8. #include "SkinBuilderView.h"
  9. #include "PropertyView.h"
  10. #include "ImageDlg.h"
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #endif
  14. // CMainFrame
  15. IMPLEMENT_DYNCREATE( CMainFrame , CFrameWnd )
  16. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  17. ON_WM_CREATE()
  18. ON_WM_CLOSE()
  19. END_MESSAGE_MAP()
  20. static UINT indicators[] ={ID_SEPARATOR, // 状态行指示器
  21. ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, };
  22. // CMainFrame 构造/析构
  23. CMainFrame::CMainFrame()
  24. {
  25. // TODO: 在此添加成员初始化代码
  26. }
  27. CMainFrame::~CMainFrame()
  28. {
  29. }
  30. int CMainFrame::OnCreate( LPCREATESTRUCT lpCreateStruct )
  31. {
  32. if ( CFrameWnd::OnCreate( lpCreateStruct ) == -1 )
  33. {
  34. return -1;
  35. }
  36. if ( !m_wndToolBar.CreateEx( this,TBSTYLE_FLAT,WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC ) || !m_wndToolBar.LoadToolBar( IDR_MAINFRAME ) )
  37. {
  38. TRACE0( "未能创建工具栏\n" );
  39. return -1; // 未能创建
  40. }
  41. if ( !m_wndStatusBar.Create( this ) || !m_wndStatusBar.SetIndicators( indicators,sizeof( indicators ) / sizeof( UINT ) ) )
  42. {
  43. TRACE0( "Failed to create status bar\n" );
  44. return -1; // fail to create
  45. }
  46. m_wndToolBar.EnableDocking( CBRS_ALIGN_ANY );
  47. EnableDocking( CBRS_ALIGN_ANY );
  48. DockControlBar( &m_wndToolBar );
  49. return TRUE;
  50. }
  51. BOOL CMainFrame::PreCreateWindow( CREATESTRUCT & cs )
  52. {
  53. if ( !CFrameWnd::PreCreateWindow( cs ) )
  54. {
  55. return FALSE;
  56. }
  57. // TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或
  58. // 样式
  59. cs.lpszClass = AfxRegisterWndClass( 0,NULL,NULL,AfxGetApp()->LoadIcon( IDR_MAINFRAME ) );
  60. return TRUE;
  61. }
  62. // CMainFrame 诊断
  63. #ifdef _DEBUG
  64. void CMainFrame::AssertValid() const
  65. {
  66. CFrameWnd::AssertValid();
  67. }
  68. void CMainFrame::Dump( CDumpContext & dc ) const
  69. {
  70. CFrameWnd::Dump( dc );
  71. }
  72. #endif //_DEBUG
  73. void CMainFrame::OnClose()
  74. {
  75. /*SaveCommandBars(_T("命令栏"));
  76. CXTPDockingPaneLayout layoutNormal(GetDockingPaneManager());
  77. GetDockingPaneManager()->GetLayout(&layoutNormal);
  78. layoutNormal.Save(_T("布局"));*/
  79. CFrameWnd::OnClose();
  80. }
  81. BOOL CMainFrame::OnCreateClient( LPCREATESTRUCT lpcs , CCreateContext * pContext )
  82. {
  83. // TODO: Add your specialized code here and/or call the base class
  84. if ( !m_wndSplitter.CreateStatic( this,1,3 ) )
  85. {
  86. TRACE0( "Failed to create splitter window\n" );
  87. return FALSE;
  88. }
  89. if ( !m_wndSplitter.CreateView( 0,0,RUNTIME_CLASS( CImageView ),CSize( 0,0 ),pContext ) )
  90. {
  91. TRACE0( "Failed to create imageview\n" );
  92. return FALSE;
  93. }
  94. m_pViewImage = ( CImageView * ) m_wndSplitter.GetPane( 0,0 );
  95. if ( !m_wndSplitter.CreateView( 0,1,RUNTIME_CLASS( CSkinBuilderView ),CSize( 0,0 ),pContext ) )
  96. {
  97. TRACE0( "Failed to create main\n" );
  98. return FALSE;
  99. }
  100. m_pViewMain = ( CSkinBuilderView * ) m_wndSplitter.GetPane( 0,1 );
  101. if ( !m_wndSplitter.CreateView( 0,2,RUNTIME_CLASS( CPropertyView ),CSize( 0,0 ),pContext ) )
  102. {
  103. TRACE0( "Failed to create propertyview\n" );
  104. return FALSE;
  105. }
  106. m_pViewProperty = ( CPropertyView * ) m_wndSplitter.GetPane( 0,1 );
  107. //m_pViewProperty->SetParent(this);
  108. CRect r;
  109. GetClientRect( &r );
  110. m_wndSplitter.SetRowInfo( 0,r.Height(),0 );
  111. m_wndSplitter.SetColumnInfo( 0,r.Width() / 4,0 );
  112. m_wndSplitter.SetColumnInfo( 1,r.Width() / 2,0 );
  113. return TRUE;
  114. }