Leaked source code of windows server 2003
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.

140 lines
3.7 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: mtkinit.cxx
  3. *
  4. * Copyright (c) 1997 Microsoft Corporation
  5. *
  6. \**************************************************************************/
  7. #include <stdlib.h>
  8. #include "mtk.hxx"
  9. #include "mtkwin.hxx"
  10. #include "mtkwproc.hxx"
  11. #include "mtkinit.hxx"
  12. SS_PAL *gpssPal = NULL;
  13. HBRUSH ghbrbg = (HBRUSH) 0; // global handle to background brush
  14. HCURSOR ghArrowCursor;
  15. BOOL gbMessageLoopStarted = FALSE;
  16. MTKWIN *gpMtkwinMain = NULL; // 'main' or root window
  17. // Global strings.
  18. #define GEN_STRING_SIZE 64
  19. // This windows class stuff bites
  20. // These 2 aren't used for now, they might be templates for later
  21. LPCTSTR pszMainWindowClass = TEXT("MtkMainClass"); // main class name
  22. LPCTSTR pszUserWindowClass = TEXT("MtkUserClass"); // user class name
  23. static TCHAR szClassName[5] = TEXT("0001" );
  24. static LPTSTR pszCurClass = szClassName;
  25. // forward declarations of internal fns
  26. /**************************************************************************\
  27. * GLDoScreenSave
  28. *
  29. * Runs the screen saver in the specified mode
  30. *
  31. * GL version of DoScreenSave in scrnsave.c
  32. *
  33. * Does basic init, creates initial set of windows, and starts the message
  34. * loop, which runs until terminated by some event.
  35. *
  36. \**************************************************************************/
  37. // Called by every window on creation
  38. BOOL
  39. mtk_Init( MTKWIN *pMtkwin )
  40. {
  41. static BOOL bInited = FALSE;
  42. if( bInited )
  43. return TRUE;
  44. // Set root window
  45. // !!! ATTENTION !!! this mechanism will fail when a thread destroys all windows,
  46. // and then creates more
  47. // -> use reference count in sswtable
  48. gpMtkwinMain = pMtkwin;
  49. // Initialize randomizer
  50. ss_RandInit();
  51. // Various globals
  52. gpssPal = NULL;
  53. // Create multi-purpose black bg brush
  54. ghbrbg = (HBRUSH) GetStockObject( BLACK_BRUSH );
  55. // For now (no ss) cursor is arrow
  56. ghArrowCursor = LoadCursor( NULL, IDC_ARROW );
  57. bInited = TRUE;
  58. return TRUE;
  59. }
  60. /**************************************************************************\
  61. * mtk_RegisterClass
  62. *
  63. \**************************************************************************/
  64. LPTSTR
  65. mtk_RegisterClass( WNDPROC wndProc, LPTSTR pszClass, HBRUSH hbrBg, HCURSOR hCursor )
  66. {
  67. WNDCLASS cls;
  68. LPTSTR pszTheClass;
  69. // If no class name provided, make one by pre-incrementing the current
  70. // class name. (Can't icrement at end of function, since class used must
  71. // match return value
  72. if( !pszClass ) {
  73. pszCurClass[0] += 1;
  74. pszTheClass = pszCurClass;
  75. } else {
  76. pszTheClass = pszClass;
  77. }
  78. cls.style = CS_VREDRAW | CS_HREDRAW;
  79. cls.lpfnWndProc = wndProc;
  80. cls.cbClsExtra = 0;
  81. cls.cbWndExtra = 0;
  82. cls.hInstance = GetModuleHandle( NULL );
  83. cls.hIcon = LoadIcon( NULL, IDI_APPLICATION );
  84. cls.hCursor = hCursor;
  85. cls.hbrBackground = hbrBg;
  86. cls.lpszMenuName = (LPTSTR)NULL;
  87. cls.lpszClassName = pszTheClass;
  88. if( ! RegisterClass(&cls) )
  89. return NULL;
  90. return pszTheClass;
  91. }
  92. #if 0
  93. /**************************************************************************\
  94. * CloseWindows
  95. *
  96. * Close down any open windows.
  97. *
  98. * This sends a WM_CLOSE message to the top-level window if it is still open. If
  99. * the window has any children, they are also closed. For each window, the
  100. * SSW destructor is called.
  101. \**************************************************************************/
  102. void
  103. SCRNSAVE::CloseWindows()
  104. {
  105. if( psswMain ) {
  106. if( psswMain->bOwnWindow )
  107. DestroyWindow( psswMain->hwnd );
  108. else
  109. delete psswMain;
  110. }
  111. }
  112. #endif