ctrlbars.cpp
上传用户:dfguandao
上传日期:2020-06-07
资源大小:23k
文件大小:3k
源码类别:

工具条

开发平台:

Visual C++

  1. #include "stdafx.h"
  2. #include <afxpriv.h>    // for idle-update windows message
  3. #include "ctrlbars.h"
  4. #include "mainfrm.h"
  5. #ifdef _DEBUG
  6. #undef THIS_FILE
  7. static char BASED_CODE THIS_FILE[] = __FILE__;
  8. #endif
  9. /////////////////////////////////////////////////////////////////////////////
  10. // CCtrlbarsApp
  11. BEGIN_MESSAGE_MAP(CCtrlbarsApp, CWinApp)
  12. //{{AFX_MSG_MAP(CCtrlbarsApp)
  13. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  14. //}}AFX_MSG_MAP
  15. END_MESSAGE_MAP()
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CCtrlbarsApp construction
  18. CCtrlbarsApp::CCtrlbarsApp()
  19. {
  20. // Place all significant initialization in InitInstance
  21. }
  22. /////////////////////////////////////////////////////////////////////////////
  23. // The one and only CCtrlbarsApp object
  24. CCtrlbarsApp NEAR theApp;
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CCtrlbarsApp initialization
  27. BOOL CCtrlbarsApp::InitInstance()
  28. {
  29. // Standard initialization
  30. Enable3dControls(); // use 3d controls in dialogs
  31. // create a new SDI main frame window
  32. CFrameWnd* pMainFrame = new CMainFrame;
  33. if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  34. return FALSE;
  35. pMainFrame->ShowWindow(m_nCmdShow);
  36. pMainFrame->UpdateWindow();
  37. m_pMainWnd = pMainFrame;
  38. pMainFrame->SendMessage(WM_COMMAND, IDM_VIEWPALETTE, (LPARAM)0);
  39. return TRUE;
  40. }
  41. // In this override of OnIdle we are doing UI for our app.
  42. // Since this needs to be as fast as possible to give the user
  43. // the best result we do our updates first when lCount is zero
  44. // then we call the library to do its work.
  45. BOOL CCtrlbarsApp::OnIdle(LONG lCount)
  46. {
  47. if (lCount == 0)
  48. {
  49. ASSERT(m_pMainWnd != NULL);
  50. // look for any top-level windows owned by us
  51. // we use 'HWND's to avoid generation of too many temporary CWnds
  52. for (HWND hWnd = ::GetWindow(m_pMainWnd->m_hWnd, GW_HWNDFIRST);
  53. hWnd != NULL; hWnd = ::GetNextWindow(hWnd, GW_HWNDNEXT))
  54. {
  55. if (::GetParent(hWnd) == m_pMainWnd->m_hWnd)
  56. {
  57. // if owned window is active, move the activation to the
  58. //   application window
  59. if (GetActiveWindow() == hWnd && (::GetCapture() == NULL))
  60. m_pMainWnd->SetActiveWindow();
  61. // also update the buttons for the top-level window
  62. SendMessage(hWnd, WM_IDLEUPDATECMDUI, (WPARAM)TRUE, 0L);
  63. }
  64. }
  65. }
  66. return CWinApp::OnIdle(lCount);
  67. }
  68. /////////////////////////////////////////////////////////////////////////////
  69. // CCtrlbarsApp commands
  70. void CCtrlbarsApp::OnAppAbout()
  71. {
  72. CDialog(IDD_ABOUTBOX).DoModal();
  73. }
  74. /////////////////////////////////////////////////////////////////////////////