ctlframe.cpp 2.2 KB

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