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.

568 lines
19 KiB

  1. /*
  2. +-------------------------------------------------------------------------+
  3. | Status Dialog box routines - Used during Conversion |
  4. +-------------------------------------------------------------------------+
  5. | (c) Copyright 1993-1994 |
  6. | Microsoft Corp. |
  7. | All rights reserved |
  8. | |
  9. | Program : [StatBox.c] |
  10. | Programmer : Arthur Hanson |
  11. | Original Program Date : [Feb 08, 1994] |
  12. | Last Update : [Feb 08, 1994] |
  13. | |
  14. | Version: 1.00 |
  15. | |
  16. | Description: |
  17. | |
  18. | History: |
  19. | arth Feb 08, 1994 1.00 Original Version. |
  20. | |
  21. +-------------------------------------------------------------------------+
  22. */
  23. #include "globals.h"
  24. #include "convapi.h"
  25. static TCHAR tmpStr[1024];
  26. static TCHAR PanelTitle[80];
  27. static HANDLE hStatus = NULL;
  28. static HANDLE hPanel = NULL;
  29. static BOOL DoCancel = FALSE;
  30. /*+-------------------------------------------------------------------------+
  31. | Routines for status dialog put up during conversion. |
  32. +-------------------------------------------------------------------------+*/
  33. /*+-------------------------------------------------------------------------+
  34. | DrainPump()
  35. +-------------------------------------------------------------------------+*/
  36. void DrainPump() {
  37. MSG msg;
  38. while (PeekMessage(&msg, hStatus, 0, 0xfff, PM_REMOVE)) {
  39. if ((IsDialogMessage(hStatus, &msg) == FALSE) &&
  40. (IsDialogMessage(hPanel, &msg) == FALSE)) {
  41. TranslateMessage(&msg);
  42. DispatchMessage(&msg);
  43. }
  44. }
  45. } // DrainPump
  46. /*+-------------------------------------------------------------------------+
  47. | Status_CurConv()
  48. +-------------------------------------------------------------------------+*/
  49. // Current server pair being converted
  50. void Status_CurConv(UINT Num) {
  51. wsprintf(tmpStr, TEXT("%5u"), Num);
  52. SendDlgItemMessage(hStatus, IDC_S_CUR_CONV, WM_SETTEXT, 0, (LPARAM) tmpStr);
  53. SendMessage(hStatus, WM_PAINT, 0, 0L);
  54. DrainPump();
  55. } // Status_CurConv
  56. /*+-------------------------------------------------------------------------+
  57. | Status_TotConv()
  58. +-------------------------------------------------------------------------+*/
  59. // Total number of server pairs to convert
  60. void Status_TotConv(UINT Num) {
  61. wsprintf(tmpStr, TEXT("%5u"), Num);
  62. SendDlgItemMessage(hStatus, IDC_S_TOT_CONV, WM_SETTEXT, 0, (LPARAM) tmpStr);
  63. SendMessage(hStatus, WM_PAINT, 0, 0L);
  64. DrainPump();
  65. } // Status_TotConv
  66. /*+-------------------------------------------------------------------------+
  67. | Status_SrcServ()
  68. +-------------------------------------------------------------------------+*/
  69. // Current source server of server pair being converted
  70. void Status_SrcServ(LPTSTR Server) {
  71. wsprintf(tmpStr, TEXT("%-15s"), Server);
  72. SendDlgItemMessage(hStatus, IDC_S_SRCSERV, WM_SETTEXT, 0, (LPARAM) tmpStr);
  73. SendMessage(hStatus, WM_PAINT, 0, 0L);
  74. DrainPump();
  75. } // Status_SrcServ
  76. /*+-------------------------------------------------------------------------+
  77. | Status_DestServ()
  78. +-------------------------------------------------------------------------+*/
  79. // Current destination server of server pair being converted
  80. void Status_DestServ(LPTSTR Server) {
  81. wsprintf(tmpStr, TEXT("%-15s"), Server);
  82. SendDlgItemMessage(hStatus, IDC_S_DESTSERV, WM_SETTEXT, 0, (LPARAM) tmpStr);
  83. SendMessage(hStatus, WM_PAINT, 0, 0L);
  84. DrainPump();
  85. } // Status_DestServ
  86. /*+-------------------------------------------------------------------------+
  87. | Status_ConvTxt()
  88. +-------------------------------------------------------------------------+*/
  89. // Text describing what is being converted (Groups, Users Files)
  90. void Status_ConvTxt(LPTSTR Text) {
  91. wsprintf(tmpStr, TEXT("%-20s"), Text);
  92. SendDlgItemMessage(hStatus, IDC_S_CONVTXT, WM_SETTEXT, 0, (LPARAM) tmpStr);
  93. SendMessage(hStatus, WM_PAINT, 0, 0L);
  94. DrainPump();
  95. } // Status_ConvTxt
  96. /*+-------------------------------------------------------------------------+
  97. | Status_CurNum()
  98. +-------------------------------------------------------------------------+*/
  99. // Current item number being converted (current group # or User # or file #)...
  100. void Status_CurNum(UINT Num) {
  101. wsprintf(tmpStr, TEXT("%7s"), lToStr(Num));
  102. SendDlgItemMessage(hStatus, IDC_S_CUR_NUM, WM_SETTEXT, 0, (LPARAM) tmpStr);
  103. SendMessage(hStatus, WM_PAINT, 0, 0L);
  104. DrainPump();
  105. } // Status_CurNum
  106. /*+-------------------------------------------------------------------------+
  107. | Status_CurTot()
  108. +-------------------------------------------------------------------------+*/
  109. // Total items in set being converted (user, group, files...)
  110. void Status_CurTot(UINT Num) {
  111. wsprintf(tmpStr, TEXT("%7s"), lToStr(Num));
  112. SendDlgItemMessage(hStatus, IDC_S_CUR_TOT, WM_SETTEXT, 0, (LPARAM) tmpStr);
  113. SendMessage(hStatus, WM_PAINT, 0, 0L);
  114. DrainPump();
  115. } // Status_CurTot
  116. /*+-------------------------------------------------------------------------+
  117. | Status_ItemLabel()
  118. +-------------------------------------------------------------------------+*/
  119. // Label for set being converted ("Group:", "User:")
  120. void Status_ItemLabel(LPTSTR Text, ...) {
  121. va_list marker;
  122. va_start(marker, Text);
  123. wvsprintf(tmpStr, Text, marker);
  124. SendDlgItemMessage(hStatus, IDC_S_ITEMLABEL, WM_SETTEXT, 0, (LPARAM) tmpStr);
  125. SendMessage(hStatus, WM_PAINT, 0, 0L);
  126. DrainPump();
  127. va_end(marker);
  128. } // Status_ItemLabel
  129. /*+-------------------------------------------------------------------------+
  130. | Status_Item()
  131. +-------------------------------------------------------------------------+*/
  132. // Name of current thing being converted (actual user or group name)
  133. void Status_Item(LPTSTR Text) {
  134. wsprintf(tmpStr, TEXT("%-15s"), Text);
  135. SendDlgItemMessage(hStatus, IDC_S_STATUSITEM, WM_SETTEXT, 0, (LPARAM) tmpStr);
  136. SendMessage(hStatus, WM_PAINT, 0, 0L);
  137. DrainPump();
  138. } // Status_Item
  139. /*+-------------------------------------------------------------------------+
  140. | Status_TotComplete()
  141. +-------------------------------------------------------------------------+*/
  142. // Total #server pairs converted so far
  143. void Status_TotComplete(UINT Num) {
  144. wsprintf(tmpStr, TEXT("%7s"), lToStr(Num));
  145. SendDlgItemMessage(hStatus, IDC_S_TOT_COMP, WM_SETTEXT, 0, (LPARAM) tmpStr);
  146. SendMessage(hStatus, WM_PAINT, 0, 0L);
  147. DrainPump();
  148. } // Status_TotComplete
  149. /*+-------------------------------------------------------------------------+
  150. | Status_TotGroups()
  151. +-------------------------------------------------------------------------+*/
  152. void Status_TotGroups(UINT Num) {
  153. wsprintf(tmpStr, TEXT("%7s"), lToStr(Num));
  154. SendDlgItemMessage(hStatus, IDC_S_TOT_GROUPS, WM_SETTEXT, 0, (LPARAM) tmpStr);
  155. SendMessage(hStatus, WM_PAINT, 0, 0L);
  156. DrainPump();
  157. } // Status_TotGroup
  158. /*+-------------------------------------------------------------------------+
  159. | Status_TotUsers()
  160. +-------------------------------------------------------------------------+*/
  161. void Status_TotUsers(UINT Num) {
  162. wsprintf(tmpStr, TEXT("%7s"), lToStr(Num));
  163. SendDlgItemMessage(hStatus, IDC_S_TOT_USERS, WM_SETTEXT, 0, (LPARAM) tmpStr);
  164. SendMessage(hStatus, WM_PAINT, 0, 0L);
  165. DrainPump();
  166. } // Status_TotUsers
  167. /*+-------------------------------------------------------------------------+
  168. | Status_TotFiles()
  169. +-------------------------------------------------------------------------+*/
  170. void Status_TotFiles(UINT Num) {
  171. wsprintf(tmpStr, TEXT("%7s"), lToStr(Num));
  172. SendDlgItemMessage(hStatus, IDC_S_TOT_FILES, WM_SETTEXT, 0, (LPARAM) tmpStr);
  173. SendMessage(hStatus, WM_PAINT, 0, 0L);
  174. DrainPump();
  175. } // Status_TotFiles
  176. /*+-------------------------------------------------------------------------+
  177. | Status_TotErrors()
  178. +-------------------------------------------------------------------------+*/
  179. void Status_TotErrors(UINT Num) {
  180. wsprintf(tmpStr, TEXT("%7s"), lToStr(Num));
  181. SendDlgItemMessage(hStatus, IDC_S_TOT_ERRORS, WM_SETTEXT, 0, (LPARAM) tmpStr);
  182. SendMessage(hStatus, WM_PAINT, 0, 0L);
  183. DrainPump();
  184. } // Status_TotErrors
  185. /*+-------------------------------------------------------------------------+
  186. | Status_BytesTxt()
  187. +-------------------------------------------------------------------------+*/
  188. void Status_BytesTxt(LPTSTR Text) {
  189. wsprintf(tmpStr, TEXT("%-15s"), Text);
  190. SendDlgItemMessage(hStatus, IDC_PANEL1, WM_SETTEXT, 0, (LPARAM) tmpStr);
  191. SendMessage(hStatus, WM_PAINT, 0, 0L);
  192. DrainPump();
  193. } // Status_BytesTxt
  194. /*+-------------------------------------------------------------------------+
  195. | Status_Bytes()
  196. +-------------------------------------------------------------------------+*/
  197. void Status_Bytes(LPTSTR Text) {
  198. wsprintf(tmpStr, TEXT("%s"), Text);
  199. SendDlgItemMessage(hStatus, IDC_PANEL2, WM_SETTEXT, 0, (LPARAM) tmpStr);
  200. SendMessage(hStatus, WM_PAINT, 0, 0L);
  201. DrainPump();
  202. } // Status_Bytes
  203. /*+-------------------------------------------------------------------------+
  204. | Status_TotBytes()
  205. +-------------------------------------------------------------------------+*/
  206. void Status_TotBytes(LPTSTR Text) {
  207. wsprintf(tmpStr, TEXT("%s"), Text);
  208. SendDlgItemMessage(hStatus, IDC_PANEL3, WM_SETTEXT, 0, (LPARAM) tmpStr);
  209. SendMessage(hStatus, WM_PAINT, 0, 0L);
  210. DrainPump();
  211. } // Status_TotBytes
  212. /*+-------------------------------------------------------------------------+
  213. | Status_BytesSep()
  214. +-------------------------------------------------------------------------+*/
  215. void Status_BytesSep(LPTSTR Text) {
  216. wsprintf(tmpStr, TEXT("%s"), Text);
  217. SendDlgItemMessage(hStatus, IDC_PANEL4, WM_SETTEXT, 0, (LPARAM) tmpStr);
  218. SendMessage(hStatus, WM_PAINT, 0, 0L);
  219. DrainPump();
  220. } // Status_BytesSep
  221. /*+-------------------------------------------------------------------------+
  222. | DlgStatus()
  223. +-------------------------------------------------------------------------+*/
  224. LRESULT CALLBACK DlgStatus(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
  225. RECT rc;
  226. switch (message) {
  227. case WM_INITDIALOG:
  228. // Center the dialog over the application window
  229. CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
  230. return (TRUE);
  231. case WM_SETFOCUS:
  232. GetWindowRect(hDlg, &rc);
  233. InvalidateRect(hDlg, &rc, FALSE);
  234. SendMessage(hStatus, WM_PAINT, 0, 0L);
  235. break;
  236. }
  237. return (FALSE); // Didn't process the message
  238. lParam;
  239. } // DlgStatus
  240. /*+-------------------------------------------------------------------------+
  241. | DoStatusDlg()
  242. +-------------------------------------------------------------------------+*/
  243. void DoStatusDlg(HWND hDlg) {
  244. DLGPROC lpfnDlg;
  245. lpfnDlg = MakeProcInstance((DLGPROC)DlgStatus, hInst);
  246. hStatus = CreateDialog(hInst, TEXT("StatusDlg"), hDlg, lpfnDlg) ;
  247. FreeProcInstance(lpfnDlg);
  248. } // DoStatusDlg
  249. /*+-------------------------------------------------------------------------+
  250. | StatusDlgKill()
  251. +-------------------------------------------------------------------------+*/
  252. void StatusDlgKill() {
  253. DestroyWindow(hStatus);
  254. hStatus = NULL;
  255. } // StatusDlgKill
  256. /*+-------------------------------------------------------------------------+
  257. | Information (Panel) Dialog Routines |
  258. +-------------------------------------------------------------------------+*/
  259. /*+-------------------------------------------------------------------------+
  260. | Panel_Line()
  261. +-------------------------------------------------------------------------+*/
  262. void Panel_Line(int Line, LPTSTR szFormat, ...) {
  263. va_list marker;
  264. if (hPanel == NULL)
  265. return;
  266. va_start(marker, szFormat);
  267. wvsprintf(tmpStr, szFormat, marker);
  268. tmpStr[60] = TEXT('\0');
  269. SendDlgItemMessage(hPanel, IDC_PANEL1 - 1 + Line, WM_SETTEXT, 0, (LPARAM) tmpStr);
  270. SendMessage(hPanel, WM_PAINT, 0, 0L);
  271. DrainPump();
  272. va_end(marker);
  273. } // Panel_ConvTxt
  274. /*+-------------------------------------------------------------------------+
  275. | Panel_Cancel()
  276. +-------------------------------------------------------------------------+*/
  277. BOOL Panel_Cancel() {
  278. if ((hPanel == NULL) || !DoCancel)
  279. return FALSE;
  280. return TRUE;
  281. } // Panel_Cancel
  282. /*+-------------------------------------------------------------------------+
  283. | DlgPanel()
  284. +-------------------------------------------------------------------------+*/
  285. LRESULT CALLBACK DlgPanel(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
  286. int wmId, wmEvent;
  287. RECT rc;
  288. switch (message) {
  289. case WM_INITDIALOG:
  290. // Center the dialog over the application window
  291. DoCancel = FALSE;
  292. CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
  293. SendMessage(hDlg, WM_SETTEXT, (WPARAM) 0, (LPARAM) PanelTitle);
  294. return (TRUE);
  295. case WM_SETFOCUS:
  296. GetWindowRect(hDlg, &rc);
  297. InvalidateRect(hDlg, &rc, FALSE);
  298. SendMessage(hPanel, WM_PAINT, 0, 0L);
  299. break;
  300. case WM_COMMAND:
  301. wmId = LOWORD(wParam);
  302. wmEvent = HIWORD(wParam);
  303. switch (wmId) {
  304. case IDCANCEL:
  305. DoCancel = TRUE;
  306. return (TRUE);
  307. break;
  308. }
  309. break;
  310. }
  311. return (FALSE); // Didn't process the message
  312. lParam;
  313. } // DlgPanel
  314. /*+-------------------------------------------------------------------------+
  315. | PanelDlg_Do()
  316. +-------------------------------------------------------------------------+*/
  317. void PanelDlg_Do(HWND hDlg, LPTSTR Title) {
  318. DLGPROC lpfnDlg;
  319. lstrcpy(PanelTitle, Title);
  320. lpfnDlg = MakeProcInstance((DLGPROC)DlgPanel, hInst);
  321. hPanel = CreateDialog(hInst, TEXT("PanelDLG"), hDlg, lpfnDlg) ;
  322. FreeProcInstance(lpfnDlg);
  323. } // PanelDlg_Do
  324. /*+-------------------------------------------------------------------------+
  325. | PanelDlgKill()
  326. +-------------------------------------------------------------------------+*/
  327. void PanelDlgKill() {
  328. if (hPanel == NULL)
  329. return;
  330. DestroyWindow(hPanel);
  331. hPanel = NULL;
  332. DoCancel = FALSE;
  333. } // PanelDlgKill
  334. /*+-------------------------------------------------------------------------+
  335. | Name Error Dialog (User and Group) |
  336. +-------------------------------------------------------------------------+*/
  337. static TCHAR OldName[60];
  338. static TCHAR NewName[60];
  339. static LPTSTR DlgTitle;
  340. static LPTSTR NameErrorProblem;
  341. static ULONG RetType;
  342. static ULONG MaxNameLen;
  343. /*+-------------------------------------------------------------------------+
  344. | NameErrorDlg()
  345. |
  346. +-------------------------------------------------------------------------+*/
  347. LRESULT CALLBACK NameErrorDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
  348. int wmId, wmEvent;
  349. switch (message) {
  350. case WM_INITDIALOG:
  351. // Center the dialog over the application window
  352. CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
  353. // Init all the display fields
  354. SendMessage(hDlg, WM_SETTEXT, (WPARAM) 0, (LPARAM) DlgTitle);
  355. SendMessage(GetDlgItem(hDlg, IDC_OLDNAME), WM_SETTEXT, (WPARAM) 0, (LPARAM) OldName);
  356. SendMessage(GetDlgItem(hDlg, IDC_NEWNAME), WM_SETTEXT, (WPARAM) 0, (LPARAM) NewName);
  357. SendMessage(GetDlgItem(hDlg, IDC_PANEL1), WM_SETTEXT, (WPARAM) 0, (LPARAM) NameErrorProblem);
  358. // limit the name length
  359. PostMessage(GetDlgItem(hDlg, IDC_NEWNAME), EM_LIMITTEXT, (WPARAM) MaxNameLen, 0);
  360. return (TRUE);
  361. case WM_COMMAND:
  362. wmId = LOWORD(wParam);
  363. wmEvent = HIWORD(wParam);
  364. switch (wmId) {
  365. case IDABORT:
  366. // This will cancel the conversion - but need to check with the user
  367. // if this is what they really want to do
  368. if (MessageBox(hDlg, Lids(IDS_E_15), Lids(IDS_E_16), MB_YESNO) == IDYES) {
  369. RetType = (ULONG) IDABORT;
  370. EndDialog(hDlg, 0);
  371. }
  372. return (TRUE);
  373. break;
  374. case IDRETRY:
  375. * (WORD *)NewName = (WORD) MaxNameLen + 1;
  376. SendMessage(GetDlgItem(hDlg, IDC_NEWNAME), EM_GETLINE, 0, (LPARAM) NewName);
  377. RetType = (ULONG) IDRETRY;
  378. EndDialog(hDlg, 0);
  379. return (TRUE);
  380. break;
  381. case IDIGNORE:
  382. RetType = (ULONG) IDCANCEL;
  383. EndDialog(hDlg, 0);
  384. return (TRUE);
  385. break;
  386. }
  387. break;
  388. }
  389. return (FALSE); // Didn't process the message
  390. lParam;
  391. } // NameErrorDlg
  392. /*+-------------------------------------------------------------------------+
  393. | UserNameErrorDlg_Do()
  394. |
  395. +-------------------------------------------------------------------------+*/
  396. ULONG UserNameErrorDlg_Do(LPTSTR Title, LPTSTR Problem, USER_BUFFER *User) {
  397. DLGPROC lpfnDlg;
  398. lstrcpy(OldName, User->Name);
  399. lstrcpy(NewName, User->NewName);
  400. MaxNameLen = MAX_USER_NAME_LEN;
  401. DlgTitle = Title;
  402. NameErrorProblem = Problem;
  403. lpfnDlg = MakeProcInstance((DLGPROC) NameErrorDlg, hInst);
  404. CursorNormal();
  405. DialogBox(hInst, TEXT("NameError"), hStatus, lpfnDlg) ;
  406. CursorHourGlass();
  407. FreeProcInstance(lpfnDlg);
  408. if (RetType == IDRETRY) {
  409. User->err = 0;
  410. lstrcpy(User->NewName, NewName);
  411. // if the name is different then flag that it is a new name
  412. if (lstrcmpi(User->NewName, User->Name))
  413. User->IsNewName = TRUE;
  414. }
  415. return RetType;
  416. } // UserNameErrorDlg_Do
  417. /*+-------------------------------------------------------------------------+
  418. | GroupNameErrorDlg_Do()
  419. |
  420. +-------------------------------------------------------------------------+*/
  421. ULONG GroupNameErrorDlg_Do(LPTSTR Title, LPTSTR Problem, GROUP_BUFFER *Group) {
  422. DLGPROC lpfnDlg;
  423. lstrcpy(OldName, Group->Name);
  424. lstrcpy(NewName, Group->NewName);
  425. MaxNameLen = MAX_NT_GROUP_NAME_LEN;
  426. DlgTitle = Title;
  427. NameErrorProblem = Problem;
  428. lpfnDlg = MakeProcInstance((DLGPROC) NameErrorDlg, hInst);
  429. CursorNormal();
  430. DialogBox(hInst, TEXT("NameError"), hStatus, lpfnDlg) ;
  431. CursorHourGlass();
  432. FreeProcInstance(lpfnDlg);
  433. if (RetType == IDRETRY) {
  434. Group->err = 0;
  435. lstrcpy(Group->NewName, NewName);
  436. // if the name is different then flag that it is a new name
  437. if (lstrcmpi(Group->NewName, Group->Name))
  438. Group->IsNewName = TRUE;
  439. }
  440. return RetType;
  441. } // GroupNameErrorDlg_Do