home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / appwiz / hierwiz / template / ipframe.cpp < prev    next >
C/C++ Source or Header  |  1998-03-05  |  3KB  |  127 lines

  1. // ipframe.cpp : implementation of the CInPlaceFrame class
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and Microsoft
  9. // QuickHelp and/or WinHelp documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13.  
  14. #include "stdafx.h"
  15. #include "$$root$$.h"
  16. #include "ipframe.h"
  17.  
  18. #ifdef _DEBUG
  19. #undef THIS_FILE
  20. static char BASED_CODE THIS_FILE[] = __FILE__;
  21. #endif
  22.  
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CInPlaceFrame
  25.  
  26. IMPLEMENT_DYNCREATE(CInPlaceFrame, COleIPFrameWnd)
  27.  
  28. BEGIN_MESSAGE_MAP(CInPlaceFrame, COleIPFrameWnd)
  29.     //{{AFX_MSG_MAP(CInPlaceFrame)
  30.     ON_WM_CREATE()
  31.     ON_UPDATE_COMMAND_UI(ID_CONTEXT_HELP, OnUpdateContextHelp)
  32.     //}}AFX_MSG_MAP
  33.     // Global help commands
  34.     ON_COMMAND(ID_HELP_INDEX, COleIPFrameWnd::OnHelpIndex)
  35.     ON_COMMAND(ID_HELP_USING, COleIPFrameWnd::OnHelpUsing)
  36.     ON_COMMAND(ID_HELP, COleIPFrameWnd::OnHelp)
  37.     ON_COMMAND(ID_DEFAULT_HELP, COleIPFrameWnd::OnHelpIndex)
  38.     ON_COMMAND(ID_CONTEXT_HELP, COleIPFrameWnd::OnContextHelp)
  39. END_MESSAGE_MAP()
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. // arrays of IDs used to initialize control bars
  43.  
  44. // toolbar buttons - IDs are command buttons
  45. static UINT BASED_CODE buttons[] =
  46. {
  47.     // same order as in the bitmap 'toolbar.bmp'
  48.     ID_EDIT_CUT,
  49.     ID_EDIT_COPY,
  50.     ID_EDIT_PASTE,
  51.         ID_SEPARATOR,
  52.     ID_APP_ABOUT,
  53.     ID_CONTEXT_HELP,
  54. };
  55.  
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CInPlaceFrame construction/destruction
  58.  
  59. CInPlaceFrame::CInPlaceFrame()
  60. {
  61. }
  62.  
  63. CInPlaceFrame::~CInPlaceFrame()
  64. {
  65. }
  66.  
  67. int CInPlaceFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  68. {
  69.     if (COleIPFrameWnd::OnCreate(lpCreateStruct) == -1)
  70.         return -1;
  71.  
  72.     if (!m_wndResizeBar.Create(this))
  73.     {
  74.         TRACE0("Failed to create resize bar\n");
  75.         return -1;      // fail to create
  76.     }
  77.  
  78.     m_dropTarget.Register(this);
  79.     return 0;
  80. }
  81.  
  82. // OnCreateControlBars is called by the framework to create control
  83. //  bars on the container application's windows.
  84. BOOL CInPlaceFrame::OnCreateControlBars(CFrameWnd* pWndFrame,
  85.     CFrameWnd* /*pWndDoc*/)
  86. {
  87.     // create toolbar on client's frame window
  88.     if (!m_wndToolBar.Create(pWndFrame) ||
  89.         !m_wndToolBar.LoadBitmap(IDR_HIERSVRTYPE_SRVR_IP) ||
  90.         !m_wndToolBar.SetButtons(buttons,
  91.           sizeof(buttons)/sizeof(UINT)))
  92.     {
  93.         TRACE0("Failed to create toolbar\n");
  94.         return FALSE;
  95.     }
  96.  
  97.     // set owner to this window, so messages are delivered to correct app
  98.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  99.     pWndFrame->EnableDocking(CBRS_ALIGN_ANY);
  100.     pWndFrame->DockControlBar(&m_wndToolBar);
  101.     m_wndToolBar.SetOwner(this);
  102.     return TRUE;
  103. }
  104.  
  105. /////////////////////////////////////////////////////////////////////////////
  106. // CInPlaceFrame diagnostics
  107.  
  108. #ifdef _DEBUG
  109. void CInPlaceFrame::AssertValid() const
  110. {
  111.     COleIPFrameWnd::AssertValid();
  112. }
  113.  
  114. void CInPlaceFrame::Dump(CDumpContext& dc) const
  115. {
  116.     COleIPFrameWnd::Dump(dc);
  117. }
  118. #endif //_DEBUG
  119.  
  120. /////////////////////////////////////////////////////////////////////////////
  121. // CInPlaceFrame commands
  122.  
  123. void CInPlaceFrame::OnUpdateContextHelp(CCmdUI* pCmdUI)
  124. {
  125.     pCmdUI->SetCheck(!!m_bHelpMode);
  126. }
  127.