home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / MFC / SRC / BARDLG.CP_ / BARDLG.CP
Encoding:
Text File  |  1993-02-08  |  2.9 KB  |  117 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library. 
  2. // Copyright (C) 1992 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 Microsoft 
  7. // QuickHelp and/or WinHelp documentation provided with the library. 
  8. // See these sources for detailed information regarding the 
  9. // Microsoft Foundation Classes product. 
  10.  
  11.  
  12. #include "stdafx.h"
  13.  
  14. #ifdef AFX_CORE3_SEG
  15. #pragma code_seg(AFX_CORE3_SEG)
  16. #endif
  17.  
  18. #ifdef _DEBUG
  19. #undef THIS_FILE
  20. static char BASED_CODE THIS_FILE[] = __FILE__;
  21. #define new DEBUG_NEW
  22. #endif
  23.  
  24. IMPLEMENT_DYNAMIC(CDialogBar, CControlBar)
  25.  
  26. CDialogBar::CDialogBar()
  27. {
  28. }
  29.  
  30. CDialogBar::~CDialogBar()
  31. {
  32.     DestroyWindow();    // avoid PostNcDestroy problems
  33. }
  34.  
  35. BOOL CDialogBar::Create(CWnd* pParentWnd, LPCSTR lpszTemplateName,
  36.             UINT nStyle, UINT nID)
  37. {
  38.     ASSERT(pParentWnd != NULL);
  39.     ASSERT(lpszTemplateName != NULL);
  40.  
  41. #ifdef _DEBUG
  42.     // dialog template must exist and be invisible with WS_CHILD set
  43.     if (!_AfxCheckDialogTemplate(lpszTemplateName, TRUE))
  44.     {
  45.         ASSERT(FALSE);          // invalid dialog template name
  46.         PostNcDestroy();        // cleanup if Create fails too soon
  47.         return FALSE;
  48.     }
  49. #endif //_DEBUG
  50.  
  51. #ifndef _AFXDLL
  52.     HINSTANCE hInst = AfxGetResourceHandle();
  53. #else
  54.     HINSTANCE hInst = AfxFindResourceHandle(lpszTemplateName, RT_DIALOG);
  55. #endif
  56.     _AfxHookWindowCreate(this);
  57.     HWND hWnd = ::CreateDialog(hInst, lpszTemplateName,
  58.         pParentWnd->GetSafeHwnd(), NULL);
  59.     if (!_AfxUnhookWindowCreate())
  60.         PostNcDestroy();        // cleanup if Create fails too soon
  61.  
  62.     if (hWnd == NULL)
  63.         return FALSE;
  64.     ASSERT(hWnd == m_hWnd);
  65.  
  66.     // Dialog template MUST specify that the Dialog
  67.     // is an invisible child window
  68.  
  69.     _AfxSetDlgCtrlID(m_hWnd, nID);
  70.     CRect rect;
  71.     GetWindowRect(&rect);
  72.     m_sizeFixedLayout = rect.Size();    // set fixed size
  73.  
  74.     // OR in the control bar sub-style
  75.     ::SetWindowLong(m_hWnd, GWL_STYLE, GetStyle() | nStyle);
  76.  
  77.     // initialize VBX controls etc
  78.     if (!ExecuteDlgInit(lpszTemplateName))
  79.         return FALSE;
  80.  
  81.     // force the size to zero - resizing bar will occur later
  82.     SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW);
  83.  
  84.     return TRUE;
  85. }
  86.  
  87.  
  88. WNDPROC* CDialogBar::GetSuperWndProcAddr()
  89. {
  90.     static WNDPROC NEAR pfnSuper;
  91.     return &pfnSuper;
  92. }
  93.  
  94. ///////////////////////////////////////////////////////////////////////////
  95.  
  96. void CDialogBar::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler)
  97. {
  98.     UpdateDialogControls(pTarget, bDisableIfNoHndler);
  99. }
  100.  
  101. ///////////////////////////////////////////////////////////////////////////
  102. // CDialogBar diagnostics
  103.  
  104. #ifdef _DEBUG
  105. void CDialogBar::AssertValid() const
  106. {
  107.     CControlBar::AssertValid();
  108. }
  109.  
  110. void CDialogBar::Dump(CDumpContext& dc) const
  111. {
  112.     CControlBar::Dump(dc);
  113. }
  114. #endif
  115.  
  116. ///////////////////////////////////////////////////////////////////////////
  117.