home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / mfc / src / ctlframe.cpp < prev    next >
C/C++ Source or Header  |  1998-06-16  |  2KB  |  98 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #include "stdafx.h"
  12.  
  13. #ifdef _AFXDLL
  14.  
  15. #ifdef AFXCTL_CORE3_SEG
  16. #pragma code_seg(AFXCTL_CORE3_SEG)
  17. #endif
  18.  
  19. #ifdef _DEBUG
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23.  
  24. #define new DEBUG_NEW
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // Message map
  28.  
  29. BEGIN_MESSAGE_MAP(CControlFrameWnd, CWnd)
  30.     //{{AFX_MSG_MAP(CControlFrameWnd)
  31.     ON_WM_CLOSE()
  32.     ON_WM_ACTIVATE()
  33.     //}}AFX_MSG_MAP
  34. END_MESSAGE_MAP()
  35.  
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CControlFrameWnd implementation
  38.  
  39. CControlFrameWnd::CControlFrameWnd(COleControl* pCtrl) :
  40.     m_pCtrl(pCtrl)
  41. {
  42. }
  43.  
  44. BOOL CControlFrameWnd::PreCreateWindow(CREATESTRUCT& cs)
  45. {
  46.     // make sure the default window class is registered
  47.     VERIFY(AfxDeferRegisterClass(AFX_WND_REG));
  48.  
  49.     if (cs.lpszClass == NULL)
  50.         cs.lpszClass = AFX_WND;
  51.  
  52.     return TRUE;
  53. }
  54.  
  55. BOOL CControlFrameWnd::Create(LPCTSTR pszFrameTitle)
  56. {
  57.     if (!CreateEx(
  58.             0,
  59.             NULL, pszFrameTitle,
  60.             WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU,
  61.             CW_USEDEFAULT, CW_USEDEFAULT,
  62.             CW_USEDEFAULT, CW_USEDEFAULT,
  63.             NULL, NULL, NULL))
  64.     {
  65.         TRACE0("Warning: failed to create CControlFrameWnd\n");
  66.         return FALSE;
  67.     }
  68.  
  69.     return TRUE;
  70. }
  71.  
  72. void CControlFrameWnd::OnClose()
  73. {
  74.     m_pCtrl->OnFrameClose();
  75.     DestroyWindow();
  76. }
  77.  
  78. void CControlFrameWnd::PostNcDestroy()
  79. {
  80.     delete this;
  81. }
  82.  
  83. void CControlFrameWnd::OnActivate(UINT nState, CWnd* pWndOther,
  84.     BOOL bMinimized)
  85. {
  86.     CWnd::OnActivate(nState, pWndOther, bMinimized);
  87.     m_pCtrl->SetFocus();
  88. }
  89.  
  90. /////////////////////////////////////////////////////////////////////////////
  91. // Force any extra compiler-generated code into AFX_INIT_SEG
  92.  
  93. #ifdef AFX_INIT_SEG
  94. #pragma code_seg(AFX_INIT_SEG)
  95. #endif
  96.  
  97. #endif //_AFXDLL
  98.