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.

373 lines
6.8 KiB

  1. //
  2. // arcdlg.h Autoreconnect dialog box
  3. //
  4. // Copyright Microsoft Corportation 2001
  5. // (nadima)
  6. //
  7. #ifndef _arcdlg_h_
  8. #define _arcdlg_h_
  9. #define DISPLAY_STRING_LEN 256
  10. #define MAX_ARC_CONNECTION_ATTEMPTS 20
  11. #include "progband.h"
  12. //
  13. // Minimal UI - just a flashing icon, introduced for XPSP1
  14. // where we couldn't add resources
  15. //
  16. //#define ARC_MINIMAL_UI 0
  17. typedef DWORD (*PFNGDI_SETLAYOUT)(HDC, DWORD);
  18. //
  19. // Base class for the ARC UI
  20. //
  21. class CAutoReconnectUI
  22. {
  23. public:
  24. CAutoReconnectUI(
  25. HWND hwndOwner,
  26. HINSTANCE hInst,
  27. CUI* pUi);
  28. virtual ~CAutoReconnectUI();
  29. virtual HWND
  30. StartModeless() = 0;
  31. //
  32. // Notifications
  33. //
  34. virtual VOID
  35. OnParentSizePosChange() = 0;
  36. virtual VOID
  37. OnNotifyAutoReconnecting(
  38. UINT discReason,
  39. ULONG attemptCount,
  40. ULONG maxAttemptCount,
  41. BOOL* pfContinueArc
  42. ) = 0;
  43. virtual VOID
  44. OnNotifyConnected() = 0;
  45. virtual BOOL
  46. ShowTopMost() = 0;
  47. virtual HWND
  48. GetHwnd() {return _hwnd;}
  49. virtual BOOL
  50. Destroy() = 0;
  51. protected:
  52. //
  53. // Private member functions
  54. //
  55. VOID
  56. CenterWindow(
  57. HWND hwndCenterOn,
  58. INT xRatio,
  59. INT yRatio
  60. );
  61. VOID
  62. PaintBitmap(
  63. HDC hdcDestination,
  64. const RECT* prcDestination,
  65. HBITMAP hbmSource,
  66. const RECT *prcSource
  67. );
  68. protected:
  69. CUI* _pUi;
  70. HWND _hwnd;
  71. HWND _hwndOwner;
  72. HINSTANCE _hInstance;
  73. //
  74. // GDI SetLayout call
  75. //
  76. PFNGDI_SETLAYOUT _pfnSetLayout;
  77. HMODULE _hGDI;
  78. };
  79. class CAutoReconnectDlg : public CAutoReconnectUI
  80. {
  81. public:
  82. CAutoReconnectDlg(HWND hwndOwner,
  83. HINSTANCE hInst,
  84. CUI* pUi);
  85. virtual ~CAutoReconnectDlg();
  86. virtual HWND
  87. StartModeless();
  88. virtual INT_PTR CALLBACK
  89. DialogBoxProc(
  90. HWND hwndDlg,
  91. UINT uMsg,
  92. WPARAM wParam,
  93. LPARAM lParam
  94. );
  95. static INT_PTR CALLBACK
  96. StaticDialogBoxProc(
  97. HWND hwndDlg,
  98. UINT uMsg,
  99. WPARAM wParam,
  100. LPARAM lParam
  101. );
  102. #ifndef OS_WINCE
  103. static LRESULT CALLBACK
  104. CancelBtnSubclassProc(
  105. HWND hwnd,
  106. UINT uMsg,
  107. WPARAM wParam,
  108. LPARAM lParam,
  109. UINT_PTR uiID,
  110. DWORD_PTR dwRefData
  111. );
  112. #else
  113. static LRESULT CALLBACK
  114. CancelBtnSubclassProc(
  115. HWND hwnd,
  116. UINT uMsg,
  117. WPARAM wParam,
  118. LPARAM lParam
  119. );
  120. #endif
  121. //
  122. // Notifications
  123. //
  124. virtual VOID
  125. OnParentSizePosChange();
  126. virtual VOID
  127. OnNotifyAutoReconnecting(
  128. UINT discReason,
  129. ULONG attemptCount,
  130. ULONG maxAttemptCount,
  131. BOOL* pfContinueArc
  132. );
  133. virtual VOID
  134. OnNotifyConnected();
  135. virtual BOOL
  136. ShowTopMost();
  137. virtual BOOL
  138. Destroy();
  139. private:
  140. VOID
  141. UpdateConnectionAttempts(
  142. ULONG conAttempts,
  143. ULONG maxConAttempts
  144. );
  145. //
  146. // Message handlers
  147. //
  148. VOID
  149. OnEraseBkgnd(HWND hwnd, HDC hdc);
  150. VOID
  151. OnPrintClient(HWND hwnd, HDC hdcPrint, DWORD dwOptions);
  152. VOID
  153. OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT *pDIS);
  154. private:
  155. TCHAR _szConnectAttemptStringTmpl[DISPLAY_STRING_LEN];
  156. ULONG _connectionAttempts;
  157. INT _nArcTimerID;
  158. ULONG _elapsedArcTime;
  159. //
  160. // Flag indicating dialog was properly initialized
  161. //
  162. BOOL _fInitialized;
  163. //
  164. // TRUE while we are continuing to arc
  165. //
  166. BOOL _fContinueReconAttempts;
  167. //
  168. // Bitmaps
  169. //
  170. HBITMAP _hbmBackground;
  171. HBITMAP _hbmFlag;
  172. #ifndef OS_WINCE
  173. HBITMAP _hbmDisconImg;
  174. #endif
  175. //
  176. // Palette
  177. //
  178. HPALETTE _hPalette;
  179. RECT _rcBackground;
  180. RECT _rcFlag;
  181. RECT _rcDisconImg;
  182. //
  183. // Fonts
  184. //
  185. HFONT _hfntTitle;
  186. //
  187. // Progress band
  188. //
  189. CProgressBand* _pProgBand;
  190. //
  191. // Last disconnection reason
  192. //
  193. UINT _lastDiscReason;
  194. #ifdef OS_WINCE
  195. //
  196. // To subclass the "Cancel" button on CE
  197. //
  198. WNDPROC _lOldCancelProc;
  199. //
  200. // Brushes to paint the static ctls
  201. //
  202. HBRUSH _hbrTopBand;
  203. HBRUSH _hbrMidBand;
  204. #endif
  205. };
  206. //
  207. // Minimal UI - just a flashing icon
  208. //
  209. class CAutoReconnectPlainUI : public CAutoReconnectUI
  210. {
  211. public:
  212. CAutoReconnectPlainUI(HWND hwndOwner,
  213. HINSTANCE hInst,
  214. CUI* pUi);
  215. virtual ~CAutoReconnectPlainUI();
  216. virtual HWND
  217. StartModeless();
  218. virtual LRESULT CALLBACK
  219. WndProc(
  220. HWND hwnd,
  221. UINT uMsg,
  222. WPARAM wParam,
  223. LPARAM lParam
  224. );
  225. static LRESULT CALLBACK
  226. StaticPlainArcWndProc(
  227. HWND hwnd,
  228. UINT uMsg,
  229. WPARAM wParam,
  230. LPARAM lParam
  231. );
  232. //
  233. // Notifications
  234. //
  235. virtual VOID
  236. OnParentSizePosChange();
  237. virtual VOID
  238. OnNotifyAutoReconnecting(
  239. UINT discReason,
  240. ULONG attemptCount,
  241. ULONG maxAttemptCount,
  242. BOOL* pfContinueArc
  243. );
  244. virtual VOID
  245. OnNotifyConnected();
  246. virtual BOOL
  247. ShowTopMost();
  248. virtual BOOL
  249. Destroy();
  250. private:
  251. //
  252. // Private member functions
  253. //
  254. //
  255. // Message handlers
  256. //
  257. VOID
  258. OnEraseBkgnd(HWND hwnd, HDC hdc);
  259. VOID
  260. OnPrintClient(HWND hwnd, HDC hdcPrint, DWORD dwOptions);
  261. VOID
  262. OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT *pDIS);
  263. private:
  264. VOID MoveToParentTopRight();
  265. VOID OnAnimFlashTimer();
  266. HBITMAP
  267. LoadImageFromMemory(
  268. HDC hdc,
  269. LPBYTE pbBitmapBits,
  270. ULONG cbLen
  271. );
  272. HRESULT
  273. LoadImageBits(
  274. LPBYTE pbBitmapBits, ULONG cbLen,
  275. LPBITMAPINFO* ppBitmapInfo, PULONG pcbBitmapInfo,
  276. LPBYTE* ppBits, PULONG pcbBits
  277. );
  278. INT _nFlashingTimer;
  279. //
  280. // Flag indicating UI was properly initialized
  281. //
  282. BOOL _fInitialized;
  283. //
  284. // TRUE while we are continuing to arc
  285. //
  286. BOOL _fContinueReconAttempts;
  287. //
  288. // Bitmaps
  289. //
  290. HBITMAP _hbmDisconImg;
  291. //
  292. // Palette
  293. //
  294. HPALETTE _hPalette;
  295. RECT _rcDisconImg;
  296. //
  297. // Last disconnection reason
  298. //
  299. UINT _lastDiscReason;
  300. //
  301. // Last hide state
  302. //
  303. BOOL _fIsUiVisible;
  304. };
  305. #endif // _arcdlg_h_