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.

178 lines
5.3 KiB

  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // File: Desktop.h
  4. // Created: Jan 1996
  5. // By: Ryan Marshall (a-ryanm) and Martin Holladay (a-martih)
  6. //
  7. // Project: Resource Kit Desktop Switcher (MultiDesk)
  8. //
  9. //
  10. // Revision History:
  11. //
  12. // March 1997 - Add external icon capability
  13. //
  14. ////////////////////////////////////////////////////////////////////////////////
  15. #ifndef __MULTIDESK_DESKTOP_H__
  16. #define __MULTIDESK_DESKTOP_H__
  17. //
  18. // Constants
  19. //
  20. #define MAX_NAME_LENGTH 255
  21. #define DEFAULT_NUM_DESKTOPS 1
  22. #define MAX_DESKTOPS 6
  23. #define NUM_BUILTIN_ICONS 27
  24. //
  25. // MUST match the number of elements in nColorElements[]
  26. // and the number of #define COLOR_ constants in Registry.Cpp
  27. //
  28. #define NUM_COLOR_ELEMENTS 23
  29. //
  30. // Error Codes
  31. //
  32. #define ERROR_CANNOT_DELETE_DESKTOP_ZERO 1
  33. #define ERROR_INVALID_DESKTOP_NUMBER 2
  34. #define ERROR_OPEN_PROCESSES 3
  35. #define ERROR_CANNOT_DELETE_ACTIVE_DESKTOP 4
  36. #define SUCCESS_THREAD_TERMINATION 5
  37. #define SUCCESS_VIRTUAL_MOVE 6
  38. //
  39. // Messages
  40. //
  41. #define WM_THREAD_TERMINATE (WM_USER + 301)
  42. #define WM_PUMP_TERMINATE (WM_USER + 302)
  43. #define WM_THREAD_SCHEME_UPDATE (WM_USER + 303)
  44. #define WM_KILL_APPS (WM_USER + 304)
  45. #define WM_NO_CLOSE (WM_USER + 305)
  46. #define WM_UPDATEMINIMIZE (WM_USER + 306)
  47. //
  48. // Dispatch function pointer prototype
  49. //
  50. typedef VOID (* DispatchFnType) ( VOID ) ;
  51. //
  52. // Data Structures
  53. //
  54. typedef struct _DESKTOP_SCHEME
  55. {
  56. BOOL Initialized;
  57. DWORD dwColor[NUM_COLOR_ELEMENTS];
  58. TCHAR szWallpaper[MAX_NAME_LENGTH + 1];
  59. TCHAR szTile[MAX_NAME_LENGTH + 1];
  60. TCHAR szPattern[MAX_NAME_LENGTH + 1];
  61. TCHAR szScreenSaver[MAX_PATH + 1];
  62. TCHAR szSecure[MAX_NAME_LENGTH + 1];
  63. TCHAR szTimeOut[MAX_NAME_LENGTH + 1];
  64. TCHAR szActive[MAX_NAME_LENGTH + 1];
  65. } DESKTOP_SCHEME, * PDESKTOP_SCHEME;
  66. typedef struct _DESKTOP_NODE
  67. {
  68. HWND hWnd;
  69. HDESK hDesktop;
  70. BOOL bThread;
  71. BOOL bShellStarted;
  72. DWORD ThreadId;
  73. UINT nIconID;
  74. LPSECURITY_ATTRIBUTES lpSA;
  75. DESKTOP_SCHEME DS;
  76. struct _DESKTOP_NODE* nextDN;
  77. TCHAR DesktopName[MAX_NAME_LENGTH];
  78. TCHAR SaiferName[MAX_NAME_LENGTH];
  79. TCHAR RealDesktopName[MAX_NAME_LENGTH];
  80. } DESKTOP_NODE, * PDESKTOP_NODE;
  81. typedef struct _THREAD_DATA
  82. {
  83. HDESK hDesktop;
  84. HDESK hDefaultDesktop;
  85. TCHAR RealDesktopName[MAX_NAME_LENGTH];
  86. DispatchFnType CreateDisplayFn;
  87. } THREAD_DATA, * PTHREAD_DATA;
  88. //
  89. // Function Prototypes
  90. //
  91. VOID ThreadInit(LPVOID hData);
  92. //
  93. // The Class
  94. //
  95. class CDesktop
  96. {
  97. public:
  98. // Construction, destruction, and initialization.
  99. CDesktop();
  100. ~CDesktop();
  101. UINT InitializeDesktops(DispatchFnType CreateDisplayFn, HINSTANCE hInstance);
  102. public:
  103. UINT GetNumDesktops(VOID) const;
  104. UINT GetActiveDesktop(VOID) const;
  105. UINT AddDesktop(DispatchFnType CreateDisplayFn,
  106. LPSECURITY_ATTRIBUTES lpSA, UINT uTemplate = 0);
  107. UINT RemoveDesktop(UINT DesktopNumber);
  108. BOOL ActivateDesktop(UINT DesktopNumber);
  109. BOOL SetDesktopName(UINT DesktopNumber, LPCTSTR DesktopName);
  110. BOOL GetDesktopName(UINT DesktopNumber, LPTSTR DesktopName, UINT size) const;
  111. BOOL SetSaiferName(UINT DesktopNumber, LPCTSTR SaiferName);
  112. BOOL GetSaiferName(UINT DesktopNumber, LPTSTR SaiferName, UINT size) const;
  113. BOOL SetDesktopIconID(UINT DesktopNumber, UINT nIconID);
  114. HICON GetDesktopIcon(UINT DesktopNumber) const;
  115. UINT GetDesktopIconID(UINT DesktopNumber) const;
  116. HICON GetBuiltinIcon(UINT IconNumber) const;
  117. public:
  118. // the functions are public, but have limited.
  119. DESKTOP_NODE *GetDesktopNode(UINT uNode);
  120. BOOL SaveCurrentDesktopScheme();
  121. HDESK GetDefaultDesktop(VOID) const;
  122. BOOL SetThreadWindow(DWORD ThreadId, HWND hWnd);
  123. HWND GetThreadWindow(DWORD ThreadId) const;
  124. UINT GetThreadDesktopID(DWORD ThreadId) const;
  125. HWND GetWindowDesktop(UINT DesktopNumber) const;
  126. BOOL GetRealDesktopName(HWND hWnd, LPTSTR szRealDesktopName) const;
  127. BOOL FindSchemeAndSet(VOID);
  128. BOOL KillAppsOnDesktop(HDESK hDesk, HWND hWnd);
  129. BOOL RegSaveSettings(VOID);
  130. BOOL RunDown(VOID);
  131. private:
  132. HINSTANCE hDeskInstance;
  133. BOOL BeginRundown;
  134. UINT NumOfDesktops;
  135. UINT CurrentDesktop;
  136. HICON DefaultIconArray[NUM_BUILTIN_ICONS];
  137. HDESK DefaultDesktop;
  138. PDESKTOP_NODE m_DesktopList; // List of desktop nodes
  139. private:
  140. BOOL DuplicateDefaultScheme(UINT DesktopNumber);
  141. BOOL GetRegColorStruct(UINT DesktopNumber);
  142. BOOL GetDesktopSchemeRegistry(UINT DesktopNumber, PDESKTOP_SCHEME pDS);
  143. BOOL SetDesktopSchemeRegistry(UINT DesktopNumber, PDESKTOP_SCHEME pDS);
  144. };
  145. #endif