home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / vrac / dlgcbr.zip / DLGBARS.CPP < prev    next >
C/C++ Source or Header  |  1994-06-30  |  4KB  |  125 lines

  1. /*****************************************************************************
  2.   DLGBARS.CPP
  3.  
  4.   Purpose: 
  5.       Interface for CDlgToolBar, a special type of CToolBar which does not
  6.       expect a parent frame window to be available, and CDlgStatusBar, which
  7.       does the same for CStatusBars.  This allows the control bars
  8.       to be used in applications where the main window is a dialog bar.
  9.  
  10.   Functions:
  11.     CDlgToolBar::CDlgToolBar()          -- constructor
  12.     CDlgToolBar::~CDlgToolBar()         -- destructor
  13.     CDlgToolBar::OnIdleUpdateCmdUI()    -- WM_IDLEUPDATECMDUI handler
  14.     
  15.     CDlgStatusBar::CDlgStatusBar()      -- constructor
  16.     CDlgStatusBar::~CDlgStatusBar()     -- destructor
  17.     CDlgStatusBar::OnIdleUpdateCmdUI()    -- WM_IDLEUPDATECMDUI handler
  18.  
  19.   Development Team:
  20.     Mary Kirtland
  21.  
  22.   Written by Microsoft Product Support Services, Premier ISV Support
  23.   Copyright (c) 1994 Microsoft Corporation. All rights reserved.
  24. \****************************************************************************/
  25.  
  26. #include "stdafx.h" 
  27. #include <afxpriv.h>
  28. #include "dlgbars.h"
  29.  
  30. #ifdef _DEBUG
  31.     #undef THIS_FILE
  32.     static char BASED_CODE THIS_FILE[] = __FILE__;
  33. #endif
  34.  
  35. /////////////////////////////////////////////////////////////////////////////
  36. // CDlgToolBar
  37.  
  38. BEGIN_MESSAGE_MAP(CDlgToolBar, CToolBar)
  39.     //{{AFX_MSG_MAP(CDlgToolBar)
  40.     ON_MESSAGE(WM_IDLEUPDATECMDUI, OnIdleUpdateCmdUI)
  41.     //}}AFX_MSG_MAP
  42. END_MESSAGE_MAP()
  43.                  
  44. /////////////////////////////////////////////////////////////////////////////
  45. // CDlgToolBar Construction/Destruction
  46.  
  47. CDlgToolBar::CDlgToolBar()
  48. {
  49. }
  50.  
  51. CDlgToolBar::~CDlgToolBar()
  52. {
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CDlgToolBar::OnIdleUpdateCmdUI
  56. //        OnIdleUpdateCmdUI handles the WM_IDLEUPDATECMDUI message, which is 
  57. //      used to update the status of user-interface elements within the MFC 
  58. //        framework.
  59. //
  60. //         We have to get a little tricky here: CToolBar::OnUpdateCmdUI 
  61. //      expects a CFrameWnd pointer as its first parameter.  However, it
  62. //      doesn't do anything but pass the parameter on to another function
  63. //      which only requires a CCmdTarget pointer.  We can get a CWnd pointer
  64. //      to the parent window, which is a CCmdTarget, but may not be a 
  65. //       CFrameWnd.  So, to make CToolBar::OnUpdateCmdUI happy, we will call
  66. //      our CWnd pointer a CFrameWnd pointer temporarily.      
  67.  
  68. LRESULT CDlgToolBar::OnIdleUpdateCmdUI(WPARAM wParam, LPARAM) 
  69. {
  70.     if (IsWindowVisible()) 
  71.     {
  72.         CFrameWnd *pParent = (CFrameWnd *)GetParent();
  73.         if (pParent)
  74.             OnUpdateCmdUI(pParent, (BOOL)wParam);
  75.     }
  76.     return 0L;
  77. }
  78.  
  79. /////////////////////////////////////////////////////////////////////////////
  80. // CDlgStatusBar
  81.  
  82. BEGIN_MESSAGE_MAP(CDlgStatusBar, CStatusBar)
  83.     //{{AFX_MSG_MAP(CDlgStatusBar)
  84.     ON_MESSAGE(WM_IDLEUPDATECMDUI, OnIdleUpdateCmdUI)
  85.     //}}AFX_MSG_MAP
  86. END_MESSAGE_MAP()
  87.                  
  88. /////////////////////////////////////////////////////////////////////////////
  89. // CDlgStatusBar Construction/Destruction
  90.  
  91. CDlgStatusBar::CDlgStatusBar()
  92. {
  93. }
  94.  
  95. CDlgStatusBar::~CDlgStatusBar()
  96. {
  97.  
  98. /////////////////////////////////////////////////////////////////////////////
  99. // CDlgStatusBar::OnIdleUpdateCmdUI
  100. //        OnIdleUpdateCmdUI handles the WM_IDLEUPDATECMDUI message, which is 
  101. //      used to update the status of user-interface elements within the MFC 
  102. //        framework.
  103. //
  104. //         We have to get a little tricky here: CStatusBar::OnUpdateCmdUI 
  105. //      expects a CFrameWnd pointer as its first parameter.  However, it
  106. //      doesn't do anything but pass the parameter on to another function
  107. //      which only requires a CCmdTarget pointer.  We can get a CWnd pointer
  108. //      to the parent window, which is a CCmdTarget, but may not be a 
  109. //       CFrameWnd.  So, to make CStatusBar::OnUpdateCmdUI happy, we will call
  110. //      our CWnd pointer a CFrameWnd pointer temporarily.      
  111.  
  112. LRESULT CDlgStatusBar::OnIdleUpdateCmdUI(WPARAM wParam, LPARAM) 
  113. {
  114.     if (IsWindowVisible()) 
  115.     {
  116.         CFrameWnd *pParent = (CFrameWnd *)GetParent();
  117.         if (pParent)
  118.             OnUpdateCmdUI(pParent, (BOOL)wParam);
  119.     }
  120.     return 0L;
  121. }
  122.  
  123.