home *** CD-ROM | disk | FTP | other *** search
/ distrib.akp.su/Programming/Vb-6+Rus/ / distrib.akp.su.tar / distrib.akp.su / Programming / Vb-6+Rus / COMMON / MSDEV98 / BIN / IDE / MFCAPWZ.DLL / TEMPLATE / CHILDFRM.CPP < prev    next >
C/C++ Source or Header  |  1998-06-18  |  8KB  |  334 lines

  1. // $$child_frame_ifile$$.cpp : implementation of the $$CHILD_FRAME_CLASS$$ class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "$$root$$.h"
  6.  
  7. #include "$$child_frame_hfile$$.h"
  8. $$IF(PROJTYPE_EXPLORER)
  9. #include "$$treeview_hfile$$.h"
  10. #include "$$view_hfile$$.h"
  11. $$ENDIF
  12.  
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18.  
  19. /////////////////////////////////////////////////////////////////////////////
  20. // $$CHILD_FRAME_CLASS$$
  21.  
  22. IMPLEMENT_DYNCREATE($$CHILD_FRAME_CLASS$$, $$CHILD_FRAME_BASE_CLASS$$)
  23.  
  24. BEGIN_MESSAGE_MAP($$CHILD_FRAME_CLASS$$, $$CHILD_FRAME_BASE_CLASS$$)
  25.     //{{AFX_MSG_MAP($$CHILD_FRAME_CLASS$$)
  26. $$IF(VERBOSE)
  27.         // NOTE - the ClassWizard will add and remove mapping macros here.
  28.         //    DO NOT EDIT what you see in these blocks of generated code !
  29. $$ENDIF
  30. $$IF(NODOCVIEW)
  31.         ON_COMMAND(ID_FILE_CLOSE, OnFileClose)
  32.         ON_WM_SETFOCUS()
  33.         ON_WM_CREATE()
  34. $$ENDIF
  35. $$IF( REBAR )
  36. $$IF(MINI_SERVER || FULL_SERVER || CONTAINER_SERVER)
  37.         ON_WM_CREATE()
  38. $$ENDIF // (ANY SERVER)
  39. $$ENDIF // REBAR
  40.     //}}AFX_MSG_MAP
  41. $$IF(PROJTYPE_EXPLORER)
  42. $$IF(CListView)
  43.     ON_UPDATE_COMMAND_UI_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, OnUpdateViewStyles)
  44.     ON_COMMAND_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, OnViewStyle)
  45. $$ENDIF
  46. $$ENDIF
  47. END_MESSAGE_MAP()
  48.  
  49. /////////////////////////////////////////////////////////////////////////////
  50. // $$CHILD_FRAME_CLASS$$ construction/destruction
  51.  
  52. $$CHILD_FRAME_CLASS$$::$$CHILD_FRAME_CLASS$$()
  53. {
  54. $$IF(VERBOSE)
  55.     // TODO: add member initialization code here
  56.     
  57. $$ENDIF
  58. }
  59.  
  60. $$CHILD_FRAME_CLASS$$::~$$CHILD_FRAME_CLASS$$()
  61. {
  62. }
  63. $$IF(SPLITTER_MDI || PROJTYPE_EXPLORER)
  64.  
  65. BOOL $$CHILD_FRAME_CLASS$$::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
  66.     CCreateContext* pContext)
  67. {
  68. $$IF(PROJTYPE_EXPLORER)
  69.     // create splitter window
  70.     if (!m_wndSplitter.CreateStatic(this, 1, 2))
  71.         return FALSE;
  72.  
  73.     if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS($$TREEVIEW_CLASS$$), CSize(100, 100), pContext) ||
  74.         !m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS($$VIEW_CLASS$$), CSize(100, 100), pContext))
  75.     {
  76.         m_wndSplitter.DestroyWindow();
  77.         return FALSE;
  78.     }
  79.  
  80.     return TRUE;
  81. $$ELSE //!PROJTYPE_EXPLORER
  82.     return m_wndSplitter.Create( this,
  83. $$IF(VERBOSE)
  84.         2, 2,                 // TODO: adjust the number of rows, columns
  85.         CSize( 10, 10 ),      // TODO: adjust the minimum pane size
  86. $$ELSE //!VERBOSE
  87.         2, 2,
  88.         CSize( 10, 10 ),
  89. $$ENDIF //VERBOSE
  90.         pContext );
  91. $$ENDIF //PROJTYPE_EXPLORER
  92. }
  93. $$ENDIF //SPLITTER || EXPLORER
  94.  
  95. BOOL $$CHILD_FRAME_CLASS$$::PreCreateWindow(CREATESTRUCT& cs)
  96. {
  97. $$IF(VERBOSE)
  98.     // TODO: Modify the Window class or styles here by modifying
  99.     //  the CREATESTRUCT cs
  100.  
  101. $$ENDIF //VERBOSE
  102.     if( !$$CHILD_FRAME_BASE_CLASS$$::PreCreateWindow(cs) )
  103.         return FALSE;
  104.  
  105. $$IF(CHILD_FRAME_STYLES)
  106.     cs.style = WS_CHILD | WS_VISIBLE | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU
  107.         | FWS_ADDTOTITLE$$CHILD_FRAME_STYLE_FLAGS$$;
  108.  
  109. $$ENDIF //CHILD_FRAME_STYLES
  110. $$IF(NODOCVIEW)
  111.     cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
  112.     cs.lpszClass = AfxRegisterWndClass(0);
  113.  
  114. $$ENDIF
  115.     return TRUE;
  116. }
  117.  
  118. $$IF(CHILD_FRAME_MAXIMIZED || CHILD_FRAME_MINIMIZED)
  119. void $$CHILD_FRAME_CLASS$$::ActivateFrame(int nCmdShow)
  120. {
  121. $$IF(VERBOSE)
  122.     // TODO: Modify this function to change how the frame is activated.
  123.  
  124. $$ENDIF //VERBOSE
  125. $$IF(CHILD_FRAME_MAXIMIZED)
  126.     nCmdShow = SW_SHOWMAXIMIZED;
  127. $$ENDIF //CHILD_FRAME_MAXIMIZED
  128. $$IF(CHILD_FRAME_MINIMIZED)
  129.     nCmdShow = SW_SHOWMINIMIZED;
  130. $$ENDIF //CHILD_FRAME_MINIMIZED
  131.     $$CHILD_FRAME_BASE_CLASS$$::ActivateFrame(nCmdShow);
  132. }
  133. $$ENDIF //CHILD_FRAME_MAXIMIZED || CHILD_FRAME_MINIMIZED
  134.  
  135.  
  136. /////////////////////////////////////////////////////////////////////////////
  137. // $$CHILD_FRAME_CLASS$$ diagnostics
  138.  
  139. #ifdef _DEBUG
  140. void $$CHILD_FRAME_CLASS$$::AssertValid() const
  141. {
  142.     $$CHILD_FRAME_BASE_CLASS$$::AssertValid();
  143. }
  144.  
  145. void $$CHILD_FRAME_CLASS$$::Dump(CDumpContext& dc) const
  146. {
  147.     $$CHILD_FRAME_BASE_CLASS$$::Dump(dc);
  148. }
  149.  
  150. #endif //_DEBUG
  151.  
  152. /////////////////////////////////////////////////////////////////////////////
  153. // $$CHILD_FRAME_CLASS$$ message handlers
  154. $$IF(PROJTYPE_EXPLORER)
  155. $$IF(CListView)
  156. $$VIEW_CLASS$$* $$CHILD_FRAME_CLASS$$::GetRightPane()
  157. {
  158.     CWnd* pWnd = m_wndSplitter.GetPane(0, 1);
  159.     $$VIEW_CLASS$$* pView = DYNAMIC_DOWNCAST($$VIEW_CLASS$$, pWnd);
  160.     return pView;
  161. }
  162.  
  163. void $$CHILD_FRAME_CLASS$$::OnUpdateViewStyles(CCmdUI* pCmdUI)
  164. {
  165. $$IF(VERBOSE)
  166.     // TODO: customize or extend this code to handle choices on the
  167.     // View menu.
  168. $$ENDIF //VERBOSE
  169.  
  170.     $$VIEW_CLASS$$* pView = GetRightPane(); 
  171.  
  172. $$IF(VERBOSE)
  173.     // if the right-hand pane hasn't been created or isn't a view,
  174.     // disable commands in our range
  175. $$ENDIF //VERBOSE
  176.  
  177.     if (pView == NULL)
  178.         pCmdUI->Enable(FALSE);
  179.     else
  180.     {
  181.         DWORD dwStyle = pView->GetStyle() & LVS_TYPEMASK;
  182.  
  183. $$IF(VERBOSE)
  184.         // if the command is ID_VIEW_LINEUP, only enable command
  185.         // when we're in LVS_ICON or LVS_SMALLICON mode
  186.  
  187. $$ENDIF //VERBOSE
  188.         if (pCmdUI->m_nID == ID_VIEW_LINEUP)
  189.         {
  190.             if (dwStyle == LVS_ICON || dwStyle == LVS_SMALLICON)
  191.                 pCmdUI->Enable();
  192.             else
  193.                 pCmdUI->Enable(FALSE);
  194.         }
  195.         else
  196.         {
  197. $$IF(VERBOSE)
  198.             // otherwise, use dots to reflect the style of the view
  199. $$ENDIF //VERBOSE
  200.             pCmdUI->Enable();
  201.             BOOL bChecked = FALSE;
  202.  
  203.             switch (pCmdUI->m_nID)
  204.             {
  205.             case ID_VIEW_DETAILS:
  206.                 bChecked = (dwStyle == LVS_REPORT);
  207.                 break;
  208.  
  209.             case ID_VIEW_SMALLICON:
  210.                 bChecked = (dwStyle == LVS_SMALLICON);
  211.                 break;
  212.  
  213.             case ID_VIEW_LARGEICON:
  214.                 bChecked = (dwStyle == LVS_ICON);
  215.                 break;
  216.  
  217.             case ID_VIEW_LIST:
  218.                 bChecked = (dwStyle == LVS_LIST);
  219.                 break;
  220.  
  221.             default:
  222.                 bChecked = FALSE;
  223.                 break;
  224.             }
  225.  
  226.             pCmdUI->SetRadio(bChecked ? 1 : 0);
  227.         }
  228.     }
  229. }
  230.  
  231.  
  232. void $$CHILD_FRAME_CLASS$$::OnViewStyle(UINT nCommandID)
  233. {
  234. $$IF(VERBOSE)
  235.     // TODO: customize or extend this code to handle choices on the
  236.     // View menu.
  237. $$ENDIF //VERBOSE
  238.     $$VIEW_CLASS$$* pView = GetRightPane();
  239.  
  240. $$IF(VERBOSE)
  241.     // if the right-hand pane has been created and is a $$VIEW_CLASS$$,
  242.     // process the menu commands...
  243. $$ENDIF //VERBOSE
  244.     if (pView != NULL)
  245.     {
  246.         DWORD dwStyle = -1;
  247.  
  248.         switch (nCommandID)
  249.         {
  250.         case ID_VIEW_LINEUP:
  251.             {
  252. $$IF(VERBOSE)
  253.                 // ask the list control to snap to grid
  254. $$ENDIF //VERBOSE
  255.                 CListCtrl& refListCtrl = pView->GetListCtrl();
  256.                 refListCtrl.Arrange(LVA_SNAPTOGRID);
  257.             }
  258.             break;
  259.  
  260. $$IF(VERBOSE)
  261.         // other commands change the style on the list control
  262. $$ENDIF //VERBOSE
  263.         case ID_VIEW_DETAILS:
  264.             dwStyle = LVS_REPORT;
  265.             break;
  266.  
  267.         case ID_VIEW_SMALLICON:
  268.             dwStyle = LVS_SMALLICON;
  269.             break;
  270.  
  271.         case ID_VIEW_LARGEICON:
  272.             dwStyle = LVS_ICON;
  273.             break;
  274.  
  275.         case ID_VIEW_LIST:
  276.             dwStyle = LVS_LIST;
  277.             break;
  278.         }
  279.  
  280. $$IF(VERBOSE)
  281.         // change the style; window will repaint automatically
  282. $$ENDIF //VERBOSE
  283.         if (dwStyle != -1)
  284.             pView->ModifyStyle(LVS_TYPEMASK, dwStyle);
  285.     }
  286. }
  287. $$ENDIF
  288. $$ENDIF
  289. $$IF(NODOCVIEW)
  290. void $$CHILD_FRAME_CLASS$$::OnFileClose() 
  291. {
  292. $$IF(VERBOSE)
  293.     // To close the frame, just send a WM_CLOSE, which is the equivalent
  294.     // choosing close from the system menu.
  295. $$ENDIF
  296.  
  297.     SendMessage(WM_CLOSE);
  298. }
  299.  
  300. int $$CHILD_FRAME_CLASS$$::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  301. {
  302.     if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
  303.         return -1;
  304.     
  305.     // create a view to occupy the client area of the frame
  306.     if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, 
  307.         CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
  308.     {
  309.         TRACE0("Failed to create view window\n");
  310.         return -1;
  311.     }
  312.  
  313.     return 0;
  314. }
  315.  
  316. void $$CHILD_FRAME_CLASS$$::OnSetFocus(CWnd* pOldWnd) 
  317. {
  318.     CMDIChildWnd::OnSetFocus(pOldWnd);
  319.  
  320.     m_wndView.SetFocus();
  321. }
  322.  
  323. BOOL $$CHILD_FRAME_CLASS$$::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
  324. {
  325.     // let the view have first crack at the command
  326.     if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
  327.         return TRUE;
  328.     
  329.     // otherwise, do default handling
  330.     return CMDIChildWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  331. }
  332.  
  333. $$ENDIF
  334.