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.

468 lines
14 KiB

  1. /*************************************************
  2. * prop.c *
  3. * *
  4. * Copyright (C) 1995-1999 Microsoft Inc. *
  5. * *
  6. *************************************************/
  7. #include "prop.h"
  8. #ifdef UNICODE
  9. TCHAR szPropCrtIME[]={0x521B, 0x5EFA, 0x8F93, 0x5165, 0x6CD5, 0x0000};
  10. TCHAR szPropReconv[]={0x9006, 0x8F6C, 0x6362, 0x0000};
  11. TCHAR szPropSort[]={0x8BCD, 0x6761, 0x6392, 0x5E8F, 0x0000};
  12. TCHAR szPropCrtWord[]={0x6279, 0x91CF, 0x9020, 0x8BCD, 0x0000};
  13. TCHAR szPropAbout[]={0x7248, 0x672C, 0x4FE1, 0x606F, 0x0000};
  14. #else
  15. BYTE szPropCrtIME[]="�������뷨";
  16. BYTE szPropReconv[]="��ת��";
  17. BYTE szPropSort[]="��������";
  18. BYTE szPropCrtWord[]="��������";
  19. BYTE szPropAbout[]="�汾��Ϣ";
  20. #endif
  21. #ifdef UNICODE
  22. extern TCHAR szCaption[];
  23. #else
  24. extern BYTE szCaption[];
  25. #endif
  26. /****************************************************************************
  27. FUNCTION: DoPropertySheet(HWND)
  28. PURPOSE: Fills out the property sheet data structures and displays
  29. the dialog with the property sheets.
  30. PARAMETERS:
  31. hwndOwner - Parent window handle of the property sheets
  32. RETURN VALUE:
  33. Returns value from PropertySheet()
  34. History:
  35. 04-17-95 Yehfew Tie (л) Created.
  36. COMMENTS:
  37. ****************************************************************************/
  38. int DoPropertySheet(HWND hwndOwner)
  39. {
  40. PROPSHEETPAGE psp[NUMPROPSHEET];
  41. PROPSHEETHEADER psh;
  42. //Fill out the PROPSHEETPAGE data structure for the MB Conv Sheet
  43. psp[PROP_CRTIME].dwSize = sizeof(PROPSHEETPAGE);
  44. psp[PROP_CRTIME].dwFlags = PSP_USETITLE;
  45. psp[PROP_CRTIME].hInstance = hInst;
  46. psp[PROP_CRTIME].pszTemplate = MAKEINTRESOURCE(IDD_CONV);
  47. psp[PROP_CRTIME].pszIcon = NULL;
  48. psp[PROP_CRTIME].pfnDlgProc = ConvDialogProc;
  49. psp[PROP_CRTIME].pszTitle = szPropCrtIME;
  50. psp[PROP_CRTIME].lParam = 0;
  51. //Fill out the PROPSHEETPAGE data structure for the MB ReConv Sheet
  52. psp[PROP_RECONV].dwSize = sizeof(PROPSHEETPAGE);
  53. psp[PROP_RECONV].dwFlags = PSP_USETITLE;
  54. psp[PROP_RECONV].hInstance = hInst;
  55. psp[PROP_RECONV].pszTemplate = MAKEINTRESOURCE(IDD_RECONV);
  56. psp[PROP_RECONV].pszIcon = NULL;
  57. psp[PROP_RECONV].pfnDlgProc = ReConvDialogProc;
  58. psp[PROP_RECONV].pszTitle = szPropReconv;
  59. psp[PROP_RECONV].lParam = 0;
  60. //Fill out the PROPSHEETPAGE data structure for the MB Sort Sheet
  61. psp[PROP_SORT].dwSize = sizeof(PROPSHEETPAGE);
  62. psp[PROP_SORT].dwFlags = PSP_USETITLE;
  63. psp[PROP_SORT].hInstance = hInst;
  64. psp[PROP_SORT].pszTemplate = MAKEINTRESOURCE(IDD_SORT);
  65. psp[PROP_SORT].pszIcon = NULL;
  66. psp[PROP_SORT].pfnDlgProc = SortDialogProc;
  67. psp[PROP_SORT].pszTitle = szPropSort;
  68. psp[PROP_SORT].lParam = 0;
  69. //Fill out the PROPSHEETPAGE data structure for the MB CrtWord Sheet
  70. psp[PROP_CRTWORD].dwSize = sizeof(PROPSHEETPAGE);
  71. psp[PROP_CRTWORD].dwFlags = PSP_USETITLE;
  72. psp[PROP_CRTWORD].hInstance = hInst;
  73. psp[PROP_CRTWORD].pszTemplate = MAKEINTRESOURCE(IDD_USERDIC);
  74. psp[PROP_CRTWORD].pszIcon = NULL;
  75. psp[PROP_CRTWORD].pfnDlgProc = UserDicDialogProc;
  76. psp[PROP_CRTWORD].pszTitle = szPropCrtWord;
  77. psp[PROP_CRTWORD].lParam = 0;
  78. //Fill out the PROPSHEETPAGE data structure for the MB Register Sheet
  79. psp[PROP_ABOUT].dwSize = sizeof(PROPSHEETPAGE);
  80. psp[PROP_ABOUT].dwFlags = PSP_USEICONID | PSP_USETITLE;
  81. psp[PROP_ABOUT].hInstance = hInst;
  82. psp[PROP_ABOUT].pszTemplate = MAKEINTRESOURCE(IDD_COPYRIGHT);
  83. psp[PROP_ABOUT].pszIcon = MAKEINTRESOURCE(IDI_IMEGEN);
  84. psp[PROP_ABOUT].pfnDlgProc = About;
  85. psp[PROP_ABOUT].pszTitle = szPropAbout;
  86. psp[PROP_ABOUT].lParam = 0;
  87. //Fill out the PROPSHEETHEADER
  88. psh.dwSize = sizeof(PROPSHEETHEADER);
  89. psh.dwFlags = PSH_USEICONID|PSH_PROPTITLE| PSH_PROPSHEETPAGE ;
  90. psh.hwndParent = hwndOwner;
  91. psh.hInstance = hInst;
  92. psh.pszIcon = MAKEINTRESOURCE(IDI_IMEGEN);
  93. psh.pszCaption = szCaption;
  94. psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
  95. psh.ppsp = (LPCPROPSHEETPAGE) psp;
  96. //And finally display the dialog with the two property sheets.
  97. return (PropertySheet (&psh) != -1);
  98. }
  99. /****************************************************************************
  100. FUNCTION: About(HWND, unsigned, WORD, LONG)
  101. PURPOSE: Processes messages for "About" dialog box
  102. MESSAGES:
  103. WM_INITDIALOG - initialize dialog box
  104. WM_COMMAND - Input received
  105. ****************************************************************************/
  106. INT_PTR APIENTRY About(
  107. HWND hDlg,
  108. UINT message,
  109. WPARAM wParam,
  110. LPARAM lParam)
  111. {
  112. switch (message) {
  113. case WM_INITDIALOG:
  114. return (TRUE);
  115. case WM_COMMAND:
  116. if (LOWORD(wParam) == IDOK) {
  117. EndDialog(hDlg, TRUE);
  118. return (TRUE);
  119. }
  120. break;
  121. }
  122. return (FALSE);
  123. UNREFERENCED_PARAMETER(lParam);
  124. }
  125. /****************************************************************************
  126. FUNCTION: Info_box(HWND, unsigned, WORD, LONG)
  127. PURPOSE: Processes messages for "InfoDlg" dialog box
  128. MESSAGES:
  129. WM_INITDIALOG - initialize dialog box
  130. WM_COMMAND - Input received
  131. ****************************************************************************/
  132. INT_PTR APIENTRY InfoDlg(
  133. HWND hDlg,
  134. UINT message,
  135. WPARAM wParam,
  136. LPARAM lParam)
  137. {
  138. static HANDLE hThread;
  139. DWORD dwThreadId;
  140. HWND HwndThrdParam;
  141. #ifdef UNICODE
  142. static TCHAR UniTmp[] = {0x662F, 0x5426, 0x53D6, 0x6D88, 0xFF1F, 0x0000};
  143. #endif
  144. switch (message) {
  145. case WM_INITDIALOG:
  146. hDlgless=hDlg;
  147. HwndThrdParam=hDlg;
  148. hThread = CreateThread(NULL,
  149. 0,
  150. (LPTHREAD_START_ROUTINE)pfnmsg,
  151. &HwndThrdParam,
  152. 0,
  153. &dwThreadId);
  154. if(hThread == NULL)
  155. EndDialog(hDlg,TRUE);
  156. break;
  157. case WM_COMMAND:
  158. switch(LOWORD(wParam)) {
  159. case IDCANCEL:
  160. SuspendThread(hThread);
  161. #ifdef UNICODE
  162. if(MessageBox(hDlg,
  163. UniTmp,
  164. szCaption,
  165. MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2) != IDYES){
  166. #else
  167. if(MessageBox(hDlg,
  168. "�Ƿ�ȡ����",
  169. szCaption,
  170. MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2) != IDYES){
  171. #endif
  172. ResumeThread(hThread);
  173. break;
  174. }
  175. {BY_HANDLE_FILE_INFORMATION FileInfo;
  176. if(hMBFile){
  177. GetFileInformationByHandle(hMBFile, &FileInfo);
  178. CloseHandle(hMBFile);
  179. //to be done DeleteFile(FileInfo);
  180. }
  181. if(hSRCFile){
  182. GetFileInformationByHandle(hSRCFile, &FileInfo);
  183. CloseHandle(hSRCFile);
  184. //to be done DeleteFile(FileInfo);
  185. }
  186. if(hCmbFile){
  187. GetFileInformationByHandle(hCmbFile, &FileInfo);
  188. CloseHandle(hCmbFile);
  189. //to be done DeleteFile(FileInfo);
  190. }
  191. }
  192. TerminateThread(hThread,0);
  193. CloseHandle(hThread);
  194. EndDialog(hDlg,TRUE);
  195. hDlgless=0;
  196. bEndProp=TRUE;
  197. return 0;
  198. }
  199. break;
  200. case WM_CLOSE:
  201. CloseHandle(hThread);
  202. EndDialog(hDlg,TRUE);
  203. hDlgless=0;
  204. return 0;
  205. }
  206. return (FALSE);
  207. UNREFERENCED_PARAMETER(lParam);
  208. }
  209. /*
  210. INT_PTR CALLBACK DispProp(
  211. HWND hDlg,
  212. UINT message,
  213. WPARAM wParam,
  214. LPARAM lParam)
  215. {
  216. #ifdef UNICODE
  217. static TCHAR MbName[]={0x7801, 0x8868, 0x6587, 0x4EF6, 0x540D, 0x0000};
  218. static TCHAR Slope[]=TEXT("\\");
  219. static TCHAR SubKey[]={0x0053, 0x006F, 0x0066, 0x0074, 0x0057, 0x0061, 0x0072, 0x0065, 0x005C, 0x004D, 0x0069, 0x0063, 0x0072, 0x006F, 0x0073, 0x006F, 0x0066, 0x0074, 0x005C, 0x0057, 0x0069, 0x006E, 0x0064, 0x006F, 0x0077, 0x0073, 0x005C, 0x0043, 0x0075, 0x0072, 0x0072, 0x0065, 0x006E, 0x0074, 0x0056, 0x0065, 0x0072, 0x0073, 0x0069, 0x006F, 0x006E, 0x005C, 0x901A, 0x7528, 0x7801, 0x8868, 0x8F93, 0x5165, 0x6CD5, 0x0000};
  220. #else
  221. static TCHAR MbName[]=TEXT("�����ļ���");
  222. static TCHAR Slope[]=TEXT("\\");
  223. static TCHAR SubKey[]=TEXT("SoftWare\\Microsoft\\Windows\\CurrentVersion\\ͨ���������뷨");
  224. #endif
  225. char szStr[MAX_PATH],SysPath[MAX_PATH];
  226. DESCRIPTION Descript;
  227. HKEY hKey,hSubKey;
  228. LPRULE lpRule;
  229. HANDLE hRule0;
  230. int nSelect;
  231. switch (message) {
  232. case WM_INITDIALOG:
  233. SendMessage(GetParent(hDlg),WM_COMMAND,IDC_GETMBFILE,(LPARAM)szStr);
  234. if(RegOpenKey(HKEY_CURRENT_USER,SubKey,&hKey))
  235. break;
  236. RegOpenKey(hKey,szStr,&hSubKey);
  237. QueryKey(hDlg,hSubKey);
  238. nSelect=sizeof(szStr);
  239. if(RegQueryValueEx(hSubKey,TEXT(MbName),NULL,NULL,szStr,&nSelect))
  240. break;
  241. RegCloseKey(hSubKey);
  242. GetSystemDirectory(SysPath,MAX_PATH);
  243. lstrcat(SysPath,TEXT(Slope));
  244. lstrcat(SysPath,szStr);
  245. if(ReadDescript(SysPath,&Descript,FILE_SHARE_READ)!=TRUE) {
  246. ProcessError(ERR_IMEUSE,hDlg,ERR);
  247. SendMessage(hDlg,WM_COMMAND,WM_CLOSE,0L);
  248. break;
  249. }
  250. SetReconvDlgDes(hDlg,&Descript);
  251. hRule0= GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,
  252. sizeof(RULE)*12);
  253. if(!(lpRule = GlobalLock(hRule0)) ) {
  254. ProcessError(ERR_GLOBALLOCK,hDlg,ERR);
  255. if(!hRule0)
  256. GlobalFree(hRule0);
  257. break;
  258. }
  259. if(ReadRule(hDlg,SysPath,Descript.wNumRules,lpRule))
  260. {
  261. SetDlgRuleStr(hDlg,Descript.wNumRules,lpRule);
  262. GlobalFree(hRule0);
  263. break;
  264. }
  265. GlobalFree(hRule0);
  266. break;
  267. case WM_COMMAND:
  268. switch(LOWORD(wParam)) {
  269. case IDOK:
  270. EndDialog(hDlg, TRUE);
  271. return (TRUE);
  272. case IDCANCEL:
  273. case WM_CLOSE:
  274. EndDialog(hDlg, TRUE);
  275. return (TRUE);
  276. default:
  277. break;
  278. }
  279. break;
  280. }
  281. return (FALSE);
  282. UNREFERENCED_PARAMETER(lParam);
  283. }*/
  284. void Init_OpenFile(HWND hWnd,LPOPENFILENAME ofn)
  285. {
  286. ofn->hwndOwner = hWnd;
  287. ofn->lStructSize = sizeof(OPENFILENAME);
  288. ofn->lpstrCustomFilter = NULL;
  289. ofn->nMaxCustFilter = 0;
  290. ofn->nFilterIndex = 1;
  291. ofn->nMaxFile = 256;
  292. ofn->nMaxFileTitle = 256;
  293. ofn->lpstrInitialDir = NULL;
  294. ofn->lpstrTitle = NULL;
  295. ofn->Flags = OFN_ALLOWMULTISELECT;//PATHMUSTEXIST;
  296. ofn->nFileOffset = 0;
  297. ofn->nFileExtension = 0;
  298. ofn->lCustData = 0L;
  299. ofn->lpfnHook = NULL;
  300. ofn->lpTemplateName = NULL;
  301. }
  302. BOOL TxtFileOpenDlg(HWND hWnd, LPTSTR lpFileName, LPTSTR lpTitleName)
  303. {
  304. OPENFILENAME ofn;
  305. #ifdef UNICODE
  306. static TCHAR szFilter[]={
  307. 0x7801, 0x8868, 0x539F, 0x6587, 0x4EF6, 0x005B, 0x002A, 0x002E, 0x0074, 0x0078, 0x0074, 0x005D, 0x0000, 0x002A, 0x002E, 0x0074, 0x0078, 0x0074, 0x0000, 0x6240, 0x6709, 0x6587, 0x4EF6, 0x005B, 0x002A, 0x002E, 0x002A, 0x005D, 0x0000, 0x002A, 0x002E, 0x002A, 0x0000, 0x0000};
  308. #else
  309. static TCHAR szFilter[]="����ԭ�ļ�[*.txt]\0*.txt\0�����ļ�[*.*]\0*.*\0\0";
  310. #endif
  311. Init_OpenFile(hWnd,&ofn);
  312. lstrcpy(lpFileName,TEXT("*.txt"));
  313. ofn.lpstrInitialDir = NULL;
  314. ofn.lpstrFile =lpFileName;
  315. ofn.lpstrFileTitle = NULL;//lpTitleName;
  316. ofn.lpstrTitle = lpTitleName;
  317. ofn.lpstrCustomFilter = NULL;
  318. ofn.lpstrFilter = szFilter;
  319. ofn.lpstrDefExt = TEXT("txt");
  320. ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
  321. ofn.nFilterIndex = 1;
  322. ofn.lpTemplateName = NULL;
  323. ofn.lpfnHook = NULL;
  324. if (!GetOpenFileName(&ofn))
  325. return 0L;
  326. return TRUE;
  327. }
  328. BOOL MBFileOpenDlg(HWND hWnd, LPTSTR lpFileName, LPTSTR lpTitleName)
  329. {
  330. OPENFILENAME ofn;
  331. #ifdef UNICODE
  332. static TCHAR szFilter[] = {
  333. 0x7801, 0x8868, 0x6587, 0x4EF6, 0x005B, 0x002A, 0x002E, 0x006D, 0x0062, 0x005D, 0x0000, 0x002A, 0x002E, 0x006D, 0x0062, 0x0000, 0x6240, 0x6709, 0x6587, 0x4EF6, 0x005B, 0x002A, 0x002E, 0x002A, 0x005D, 0x0000, 0x002A, 0x002E, 0x002A, 0x0000, 0x0000};
  334. #else
  335. static BYTE szFilter[]="�����ļ�[*.mb]\0*.mb\0�����ļ�[*.*]\0*.*\0\0";
  336. #endif
  337. Init_OpenFile(hWnd,&ofn);
  338. lstrcpy(lpFileName,TEXT("*.mb"));
  339. ofn.lpstrFile = lpFileName;
  340. ofn.lpstrFileTitle = NULL;
  341. ofn.lpstrFilter = szFilter;
  342. ofn.lpstrDefExt = TEXT("mb");
  343. ofn.lpstrTitle = NULL;//lpTitleName;
  344. ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
  345. ofn.nFilterIndex = 1;
  346. ofn.lpTemplateName = NULL;
  347. ofn.lpfnHook = NULL;
  348. if (!GetOpenFileName(&ofn))
  349. return 0L;
  350. return TRUE;
  351. }
  352. BOOL RcFileOpenDlg(HWND hWnd, LPTSTR lpFileName, LPTSTR lpTitleName)
  353. {
  354. OPENFILENAME ofn;
  355. #ifdef UNICODE
  356. static TCHAR szFilter[]={
  357. 0x8D44, 0x6E90, 0x6587, 0x4EF6, 0x005B, 0x002A, 0x002E, 0x0069, 0x0063, 0x006F, 0x002C, 0x002A, 0x002E, 0x0062, 0x006D, 0x0070, 0x003B, 0x002A, 0x002E, 0x0068, 0x006C, 0x0070, 0x005D, 0x0000, 0x002A, 0x002E, 0x0062, 0x006D, 0x0070, 0x003B, 0x002A, 0x002E, 0x0069, 0x0063, 0x006F, 0x003B, 0x002A, 0x002E, 0x0068, 0x006C, 0x0070, 0x0000, 0x0000};
  358. #else
  359. static BYTE szFilter[]="��Դ�ļ�[*.ico,*.bmp;*.hlp]\0*.bmp;*.ico;*.hlp\0\0";
  360. #endif
  361. Init_OpenFile(hWnd,&ofn);
  362. lstrcpy(lpFileName,TEXT("*.ico;*.bmp;*.hlp"));
  363. ofn.lpstrFile = lpFileName;
  364. ofn.lpstrFileTitle = NULL;//lpTitleName;
  365. ofn.lpstrFilter = szFilter;
  366. ofn.lpstrDefExt = TEXT("ico");
  367. ofn.lpstrTitle = lpTitleName;
  368. ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
  369. ofn.nFilterIndex = 1;
  370. ofn.lpTemplateName = NULL;
  371. ofn.lpfnHook = NULL;
  372. if (!GetOpenFileName(&ofn))
  373. return 0L;
  374. return TRUE;
  375. }
  376. BOOL SaveTxtFileAs(HWND hwnd, LPTSTR szFilename) {
  377. OPENFILENAME ofn;
  378. TCHAR szFile[256], szFileTitle[256];
  379. #ifdef UNICODE
  380. static TCHAR szFilter[] = {
  381. 0x7801, 0x8868, 0x539F, 0x6587, 0x4EF6, 0x0028, 0x002A, 0x002E, 0x0074, 0x0078, 0x0074, 0x0029, 0x0000, 0x002A, 0x002E, 0x0074, 0x0078, 0x0074, 0x0000, 0x0000};
  382. TCHAR UniTmp[] = {0x53E6, 0x5B58, 0x4E3A, 0x0000};
  383. #else
  384. static BYTE szFilter[] = TEXT("����ԭ�ļ�(*.txt)\0*.txt\0\0");
  385. #endif
  386. lstrcpy(szFile, TEXT("*.txt\0"));
  387. Init_OpenFile(hwnd,&ofn);
  388. ofn.lStructSize = sizeof(OPENFILENAME);
  389. ofn.lpstrFilter = szFilter;
  390. ofn.lpstrFile = szFilename;
  391. ofn.lpstrFileTitle = szFileTitle;
  392. #ifdef UNICODE
  393. ofn.lpstrTitle = UniTmp;
  394. #else
  395. ofn.lpstrTitle = "����Ϊ";
  396. #endif
  397. ofn.lpstrDefExt = NULL;
  398. if (!GetSaveFileName(&ofn))
  399. return 0L;
  400. return (SaveTxtFile(hwnd,szFilename));
  401. }