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.

270 lines
8.3 KiB

  1. //
  2. // contwnd.h: TS client Shell Container window
  3. // hosts TS ActiveX control
  4. // Copyright Microsoft Corporation 1999-2000
  5. //
  6. #ifndef _CONTWND_H_
  7. #define _CONTWND_H_
  8. #include "sh.h"
  9. #include "evsink.h" //Event sink
  10. #include "connectingdlg.h"
  11. #include "auierr.h"
  12. #include "axhostwnd.h"
  13. #include "framewnd.h"
  14. #include "shlobj.h"
  15. #define MAIN_CLASS_NAME TEXT("TSSHELLWND")
  16. typedef enum logonDlgState
  17. {
  18. dlgUnexpanded = 0,
  19. dlgTabGeneral = 1,
  20. dlgTabLocalResources= 2
  21. } LOGONDLGSTATE;
  22. typedef struct tagLOGONDLGSTARTUPINFO
  23. {
  24. LOGONDLGSTATE state;
  25. int xPos;
  26. int yPos;
  27. } LOGONDLGSTARTUPINFO, *PLOGONDLGSTARTUPINFO;
  28. class CMainDlg;
  29. class CRGN
  30. {
  31. public:
  32. CRGN (void) { mRgn = CreateRectRgn(0, 0, 0, 0);}
  33. CRGN (const RECT& rc) { mRgn = CreateRectRgnIndirect(&rc);}
  34. ~CRGN (void) { DeleteObject(mRgn);}
  35. operator HRGN (void) const { return(mRgn);}
  36. void SetRegion (const RECT& rc) {
  37. SetRectRgn(mRgn, rc.left, rc.top, rc.right, rc.bottom);}
  38. private:
  39. HRGN mRgn;
  40. };
  41. #define SET_CONTWND_STATE(x) \
  42. TRC_NRM((TB,_T("Set contwnd state from %d to %d"), _state, x)); \
  43. _state = x; \
  44. class CContainerWnd : public CTscFrameWnd
  45. {
  46. public:
  47. CContainerWnd();
  48. ~CContainerWnd();
  49. //
  50. // API Methods
  51. //
  52. DCBOOL Init(HINSTANCE hInstance, CTscSettings* pTscSet, CSH* pSh);
  53. BOOL StartConnection();
  54. DCBOOL Disconnect();
  55. DCBOOL FinishDisconnect(BOOL fExit = FALSE);
  56. //
  57. // Window proc
  58. //
  59. LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,
  60. WPARAM wParam, LPARAM lParam);
  61. //
  62. // Property accessers
  63. //
  64. DCVOID SetConnectDialogHandle(HWND hwnd)
  65. {
  66. _hwndMainDialog = hwnd;
  67. }
  68. HWND GetConnectDialogHandle()
  69. {
  70. return _hwndMainDialog;
  71. }
  72. DCVOID SetStatusDialogHandle(HWND hwnd)
  73. {
  74. _hwndStatusDialog = hwnd;
  75. }
  76. BOOL GetHaveConnected() {return _fHaveConnected;}
  77. HWND GetWndHandle() {return _hWnd;}
  78. VOID ResetConnectionSuccessFlag() {_fConnectionSuccess = FALSE;}
  79. VOID SetConnectionSuccessFlag() {_fConnectionSuccess = TRUE;}
  80. BOOL GetConnectionSuccessFlag() {return _fConnectionSuccess;}
  81. BOOL IsConnected();
  82. //
  83. // Message handlers
  84. //
  85. LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam);
  86. LRESULT OnDestroy(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  87. LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam);
  88. LRESULT OnMove(UINT uMsg, WPARAM wParam, LPARAM lParam);
  89. LRESULT OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam);
  90. LRESULT OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam);
  91. LRESULT OnInitMenu(UINT uMsg, WPARAM wParam, LPARAM lParam);
  92. LRESULT OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lParam);
  93. LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam);
  94. LRESULT OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam);
  95. LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam);
  96. LRESULT OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam);
  97. LRESULT OnNCDestroy(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  98. LRESULT OnDeviceChange(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  99. LRESULT OnHelp(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  100. LRESULT OnPaletteChange(UINT uMsg, WPARAM wParam, LPARAM lParam);
  101. LRESULT OnExitMenuLoop(UINT uMsg, WPARAM wParam, LPARAM lParam);
  102. LRESULT OnCaptureChanged(UINT uMsg, WPARAM wParam, LPARAM lParam);
  103. LRESULT OnEnterSizeMove(UINT uMsg, WPARAM wParam, LPARAM lParam);
  104. LRESULT OnExitSizeMove(UINT uMsg, WPARAM wParam, LPARAM lParam);
  105. LRESULT OnSysColorChange(UINT uMsg, WPARAM wParam, LPARAM lParam);
  106. VOID ExitAndQuit();
  107. //
  108. // Event notification handlers (called by _eventSink)
  109. //
  110. LONG EnterEventHandler();
  111. LONG LeaveEventHandler();
  112. VOID OnConnected();
  113. VOID OnLoginComplete();
  114. VOID OnDisconnected(DCUINT discReason);
  115. VOID OnEnterFullScreen();
  116. VOID OnLeaveFullScreen();
  117. VOID OnFatalError(LONG errorCode);
  118. VOID OnWarning(LONG WarnCode);
  119. VOID OnRemoteDesktopSizeNotify(long width, long height);
  120. VOID OnRequestMinimize();
  121. HRESULT OnConfirmClose(BOOL* pfConfirmClose);
  122. BOOL _fPreventClose;
  123. BOOL _fBeenThroughDestroy;
  124. BOOL _fBeenThroughNCDestroy;
  125. DCINT _PostedQuit;
  126. private:
  127. HRESULT CreateTsControl();
  128. BOOL SetupSystemMenu();
  129. void SetMinMaxPlacement(WINDOWPLACEMENT& windowPlacement);
  130. void RecalcMaxWindowSize(DCVOID);
  131. DCSIZE GetMaximizedWindowSize(DCSIZE& maximizedSize);
  132. LPTSTR GetFatalString(DCINT errorID);
  133. void DisplayFatalError(PDCTCHAR errorString, DCINT error);
  134. BOOL InControlEventHandler();
  135. BOOL StartConnectDialog(BOOL fStartExpanded = FALSE,
  136. INT nStartTabIndex = 0);
  137. void CalcTrackingMaxWindowSize(UINT cliWidth,
  138. UINT cliHeight,
  139. UINT* pMaxX,
  140. UINT* pMaxY);
  141. ULONG GetCurrentDesktopWidth() {return _curDesktopWidth;}
  142. ULONG GetCurrentDesktopHeight() {return _curDesktopHeight;}
  143. void SetCurrentDesktopWidth(LONG w) {_curDesktopWidth = w;}
  144. void SetCurrentDesktopHeight(LONG h) {_curDesktopHeight = h;}
  145. BOOL IsUsingDialogUI();
  146. BOOL IsRemoteResMatchMonitorSize();
  147. #ifndef OS_WINCE
  148. void EnsureWindowIsCompletelyOnScreen(RECT *prc);
  149. #endif
  150. BOOL IsOkToToggleFocus();
  151. private:
  152. HMENU _hSystemMenu;
  153. HMENU _hHelpMenu;
  154. // The activeX view window (child of the container)
  155. #ifdef USE_ATL_CONTAINER
  156. CAxWindow* _pWndView;
  157. #else
  158. CAxHostWnd* _pWndView;
  159. #endif
  160. CSH* _pSh;
  161. HINSTANCE _hInst;
  162. DCBOOL _bContainerIsFullScreen;
  163. #ifdef DC_DEBUG
  164. HMENU _hDebugMenu;
  165. #endif
  166. // ActiveX control instance pointer
  167. IMsRdpClient* _pTsClient;
  168. HWND _hwndMainDialog;
  169. HWND _hwndStatusDialog;
  170. DCSIZE _maxMainWindowSize;
  171. //
  172. // Current desktop width and height
  173. // these can change in response to an
  174. // event from the control (e.g on shadow)
  175. //
  176. ULONG _curDesktopWidth, _curDesktopHeight;
  177. //Active tab on the connect dialog
  178. //used to return to that tab when the dialog
  179. //is relaunched.
  180. DCBOOL _fFirstTimeToLogonDlg;
  181. LOGONDLGSTARTUPINFO _logonDlgStartupInfo;
  182. //
  183. // Flag signals that the login phase has completed for this
  184. // connection
  185. //
  186. DCBOOL _fLoginComplete;
  187. DCTCHAR _errorString[UI_ERR_MAX_STRLEN];
  188. //
  189. // Count of how many times we entered
  190. // an event handler.
  191. // This is used to protect entry into non-rentrant
  192. // code paths.
  193. //
  194. LONG _cInEventHandlerCount;
  195. BOOL _fInOnCloseHandler;
  196. CMainDlg* _pMainDlg;
  197. CTscSettings* _pTscSet;
  198. BOOL _fClientWindowIsUp;
  199. TCHAR _szAppName[MAX_PATH];
  200. BOOL _fHaveConnected;
  201. TCHAR _szPathToDefaultFile[MAX_PATH];
  202. INT _successConnectCount;
  203. BOOL _fConnectionSuccess;
  204. BOOL _fClosePending;
  205. #ifndef OS_WINCE
  206. //Cached interface pointer to shell task bar
  207. ITaskbarList2* _pTaskBarList2;
  208. //Flag indicaticating we already tried to get the TaskBarList2
  209. //so we shouldn't bother trying again
  210. BOOL _fQueriedForTaskBarList2;
  211. #endif
  212. //
  213. // Are we in the modal size/move loop
  214. //
  215. BOOL _fInSizeMove;
  216. BOOL _fRunningOnWin9x;
  217. typedef enum
  218. {
  219. stateNotInitialized = 0x0,
  220. stateNotConnected = 0x1,
  221. stateConnecting = 0x2,
  222. stateConnected = 0x3,
  223. } contWndState;
  224. contWndState _state;
  225. };
  226. #endif // _CONTWND_H_