Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
3.4 KiB

  1. /*************************************************
  2. * cblocks.cpp *
  3. * *
  4. * Copyright (C) 1995-1999 Microsoft Inc. *
  5. * *
  6. *************************************************/
  7. // block.cpp : Defines the class behaviors for the application.
  8. //
  9. #include "stdafx.h"
  10. #include <afxpriv.h> // for idle-update windows message
  11. #include "cblocks.h"
  12. #include "dib.h"
  13. #include "dibpal.h"
  14. #include "spriteno.h"
  15. #include "sprite.h"
  16. #include "phsprite.h"
  17. #include "myblock.h"
  18. #include "splstno.h"
  19. #include "spritlst.h"
  20. #include "mainfrm.h"
  21. #include "osbview.h"
  22. #include "blockvw.h"
  23. #include "blockdoc.h"
  24. #ifdef _DEBUG
  25. #undef THIS_FILE
  26. static char BASED_CODE THIS_FILE[] = __FILE__;
  27. #endif
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CBlockApp
  30. BEGIN_MESSAGE_MAP(CBlockApp, CWinApp)
  31. //{{AFX_MSG_MAP(CBlockApp)
  32. ON_COMMAND(ID_HELP_RULE, OnHelpRule)
  33. //}}AFX_MSG_MAP
  34. // Standard file based document commands
  35. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  36. ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  37. END_MESSAGE_MAP()
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CBlockApp construction
  40. CBlockApp::CBlockApp()
  41. {
  42. m_pIdleDoc = NULL;
  43. }
  44. /////////////////////////////////////////////////////////////////////////////
  45. // The one and only CBlockApp object
  46. CBlockApp NEAR theApp;
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CBlockApp initialization
  49. BOOL CBlockApp::InitInstance()
  50. {
  51. // Standard initialization
  52. // If you are not using these features and wish to reduce the size
  53. // of your final executable, you should remove from the following
  54. // the specific initialization routines you do not need.
  55. Enable3dControls();
  56. SetDialogBkColor(); // set dialog background color to gray
  57. LoadStdProfileSettings(); // Load standard INI file options (including MRU)
  58. // Register the application's document templates. Document templates
  59. // serve as the connection between documents, frame windows and views.
  60. AddDocTemplate(new CSingleDocTemplate(IDR_MAINFRAME,
  61. RUNTIME_CLASS(CBlockDoc),
  62. RUNTIME_CLASS(CMainFrame), // main SDI frame window
  63. RUNTIME_CLASS(CBlockView)));
  64. OnFileNew();
  65. // simple command line parsing
  66. return TRUE;
  67. }
  68. // App command to run the dialog
  69. /////////////////////////////////////////////////////////////////////////////
  70. // CBlockApp commands
  71. BOOL CBlockApp::OnIdle(LONG lCount)
  72. {
  73. if (lCount == RANK_USER)
  74. {
  75. ASSERT(m_pMainWnd != NULL);
  76. // look for any top-level windows owned by us
  77. // we use 'HWND's to avoid generation of too many temporary CWnds
  78. for (HWND hWnd = ::GetWindow(m_pMainWnd->m_hWnd, GW_HWNDFIRST);
  79. hWnd != NULL; hWnd = ::GetNextWindow(hWnd, GW_HWNDNEXT))
  80. {
  81. if (::GetParent(hWnd) == m_pMainWnd->m_hWnd)
  82. {
  83. // if owned window is active, move the activation to the
  84. // application window
  85. if (GetActiveWindow() == hWnd && (::GetCapture() == NULL))
  86. m_pMainWnd->SetActiveWindow();
  87. // also update the buttons for the top-level window
  88. SendMessage(hWnd, WM_IDLEUPDATECMDUI, (WPARAM)TRUE, 0L);
  89. }
  90. }
  91. }
  92. return CWinApp::OnIdle(lCount);
  93. }
  94. void CBlockApp::OnHelpRule()
  95. {
  96. ::WinHelp(GetFocus(), TEXT("CBLOCKS.HLP"), HELP_FINDER, 0L);
  97. }