home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / MS_VC.50 / VC / MFC / SRC / CTLFRAME.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-30  |  2.1 KB  |  95 lines

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