home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / general / dlgcbr32 / dlgbars.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  3.7 KB  |  116 lines

  1. // DLGBARS.cpp : Defines the class behaviors for the dialog tool bar
  2. //               and status bar.
  3. //
  4. // This is a part of the Microsoft Foundation Classes C++ library.
  5. // Copyright (C) 1992-1998 Microsoft Corporation
  6. // All rights reserved.
  7. //
  8. // This source code is only intended as a supplement to the
  9. // Microsoft Foundation Classes Reference and related
  10. // electronic documentation provided with the library.
  11. // See these sources for detailed information regarding the
  12. // Microsoft Foundation Classes product.
  13.  
  14. #include "stdafx.h"
  15. #include <afxpriv.h>
  16.  
  17. #include "dlgbars.h"
  18.  
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CDlgToolBar
  27.  
  28. BEGIN_MESSAGE_MAP(CDlgToolBar, CToolBar)
  29.     //{{AFX_MSG_MAP(CDlgToolBar)
  30.     ON_MESSAGE(WM_IDLEUPDATECMDUI, OnIdleUpdateCmdUI)
  31.         // NOTE - the ClassWizard will add and remove mapping macros here.
  32.         //    DO NOT EDIT what you see in these blocks of generated code!
  33.     //}}AFX_MSG_MAP
  34. END_MESSAGE_MAP()
  35.  
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CDlgToolBar Construction/Destruction
  38.  
  39. CDlgToolBar::CDlgToolBar()
  40. {
  41. }
  42.  
  43. CDlgToolBar::~CDlgToolBar()
  44. {
  45. }
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CDlgToolBar::OnIdleUpdateCmdUI
  49. //      OnIdleUpdateCmdUI handles the WM_IDLEUPDATECMDUI message, which is
  50. //      used to update the status of user-interface elements within the MFC
  51. //      framework.
  52. //
  53. //      We have to get a little tricky here: CToolBar::OnUpdateCmdUI
  54. //      expects a CFrameWnd pointer as its first parameter.  However, it
  55. //      doesn't do anything but pass the parameter on to another function
  56. //      which only requires a CCmdTarget pointer.  We can get a CWnd pointer
  57. //      to the parent window, which is a CCmdTarget, but may not be a
  58. //      CFrameWnd.  So, to make CToolBar::OnUpdateCmdUI happy, we will call
  59. //      our CWnd pointer a CFrameWnd pointer temporarily.
  60.  
  61. LRESULT CDlgToolBar::OnIdleUpdateCmdUI(WPARAM wParam, LPARAM)
  62. {
  63.     if (IsWindowVisible())
  64.     {
  65.         CFrameWnd *pParent = (CFrameWnd *)GetParent();
  66.         if (pParent)
  67.             OnUpdateCmdUI(pParent, (BOOL)wParam);
  68.     }
  69.     return 0L;
  70. }
  71.  
  72. /////////////////////////////////////////////////////////////////////////////
  73. // CDlgStatusBar
  74.  
  75. BEGIN_MESSAGE_MAP(CDlgStatusBar, CStatusBar)
  76.     //{{AFX_MSG_MAP(CDlgStatusBar)
  77.     ON_MESSAGE(WM_IDLEUPDATECMDUI, OnIdleUpdateCmdUI)
  78.     //}}AFX_MSG_MAP
  79. END_MESSAGE_MAP()
  80.  
  81. /////////////////////////////////////////////////////////////////////////////
  82. // CDlgStatusBar Construction/Destruction
  83.  
  84. CDlgStatusBar::CDlgStatusBar()
  85. {
  86. }
  87.  
  88. CDlgStatusBar::~CDlgStatusBar()
  89. {
  90. }
  91.  
  92. /////////////////////////////////////////////////////////////////////////////
  93. // CDlgStatusBar::OnIdleUpdateCmdUI
  94. //      OnIdleUpdateCmdUI handles the WM_IDLEUPDATECMDUI message, which is
  95. //      used to update the status of user-interface elements within the MFC
  96. //      framework.
  97. //
  98. //      We have to get a little tricky here: CStatusBar::OnUpdateCmdUI
  99. //      expects a CFrameWnd pointer as its first parameter.  However, it
  100. //      doesn't do anything but pass the parameter on to another function
  101. //      which only requires a CCmdTarget pointer.  We can get a CWnd pointer
  102. //      to the parent window, which is a CCmdTarget, but may not be a
  103. //      CFrameWnd.  So, to make CStatusBar::OnUpdateCmdUI happy, we will call
  104. //      our CWnd pointer a CFrameWnd pointer temporarily.
  105.  
  106. LRESULT CDlgStatusBar::OnIdleUpdateCmdUI(WPARAM wParam, LPARAM)
  107. {
  108.     if (IsWindowVisible())
  109.     {
  110.         CFrameWnd *pParent = (CFrameWnd *)GetParent();
  111.         if (pParent)
  112.             OnUpdateCmdUI(pParent, (BOOL)wParam);
  113.     }
  114.     return 0L;
  115. }
  116.