unzopts.c
上传用户:jlteech
上传日期:2007-01-06
资源大小:349k
文件大小:9k
源码类别:

压缩解压

开发平台:

Visual C++

  1. /*
  2.  Copyright (C) 1996 Mike White
  3.  Permission is granted to any individual or institution to use, copy, or
  4.  redistribute this software so long as all of the original files are included,
  5.  that it is not sold for profit, and that this copyright notice is retained.
  6. */
  7. #include <windows.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include "wiz.h"
  11. #include "helpids.h"
  12. #define CRLF_WARNING "This option can cause corruption of files other than " 
  13.    "text files. This is particularly true of executables, word processing " 
  14.    "documents, or database files. The only "safe file" is an ASCII text " 
  15.    "file. Press OK to confirm, or CANCEL."
  16. extern char szFormatKeyword[2][6];
  17. /****************************************************************************
  18.     FUNCTION: UnZipPreferencesProc(HWND, unsigned, WPARAM, LPARAM)
  19.     PURPOSE:  Processes messages for "UnZip Preferences" dialog box
  20.     MESSAGES:
  21.     WM_INITDIALOG - initialize dialog box
  22.     WM_COMMAND    - Input received
  23. ****************************************************************************/
  24. BOOL  recreate_dir,overwrite,newer,prompt_overwrite,lf_crlf,
  25.       space_underscore, lbs_extract, lbs_display, lbs_test;
  26. #ifdef WIN32
  27. int fPrivilege;
  28. #endif
  29. #ifdef __BORLANDC__
  30. #pragma warn -par
  31. #pragma warn -aus
  32. #endif
  33. DWORD WINAPI
  34. UnZipPreferencesProc(HWND hwndDlg, WORD wMessage, WPARAM wParam, LPARAM lParam)
  35. {
  36. #ifdef WIN32
  37. int i;
  38. #endif
  39.    switch (wMessage) {
  40.    case WM_INITDIALOG:
  41.       {
  42.       CenterDialog(GetParent(hwndDlg), hwndDlg); /* center on parent */
  43.       /* UnZip Options */
  44.       recreate_dir = uf.fRecreateDirs;
  45.       CheckDlgButton(hwndDlg, IDC_RECREATE_DIR, recreate_dir);
  46.       overwrite = lpDCL->noflag;
  47.       if (overwrite)
  48.          CheckRadioButton(hwndDlg, IDC_OVERWRITE,
  49.             IDC_PROMPT_OVERWRITE, IDC_OVERWRITE);
  50.       newer = lpDCL->ExtractOnlyNewer;
  51.       if (newer)
  52.          CheckRadioButton(hwndDlg, IDC_OVERWRITE,
  53.             IDC_PROMPT_OVERWRITE, IDC_NEWER);
  54.       prompt_overwrite = lpDCL->PromptToOverwrite;
  55.       if (prompt_overwrite)
  56.          CheckRadioButton(hwndDlg, IDC_OVERWRITE,
  57.             IDC_PROMPT_OVERWRITE, IDC_PROMPT_OVERWRITE);
  58.       lf_crlf = uf.fTranslate;
  59.       CheckDlgButton(hwndDlg, IDC_LF_CRLF, lf_crlf);
  60.       space_underscore = lpDCL->SpaceToUnderscore;
  61.       CheckDlgButton(hwndDlg, IDC_SPACE_UNDERSCORE, space_underscore);
  62. #ifdef WIN32
  63.       fPrivilege = lpDCL->fPrivilege;
  64.       if (fPrivilege == 1)
  65.          CheckDlgButton(hwndDlg, IDC_ACL, TRUE);
  66.       if (fPrivilege == 2)
  67.          CheckDlgButton(hwndDlg, IDC_PRIVILEGE, TRUE);
  68. #endif
  69.       switch (fLB_Selection)
  70.          {
  71.          case 0:
  72.                  CheckRadioButton(hwndDlg, IDC_LBS_EXTRACT,
  73.                     IDC_LBS_TEST, IDC_LBS_EXTRACT);
  74.                  lbs_extract = TRUE;
  75.                  lbs_display = FALSE;
  76.                  lbs_test = FALSE;
  77.                  break;
  78.          case 1:
  79.                  CheckRadioButton(hwndDlg, IDC_LBS_EXTRACT,
  80.                     IDC_LBS_TEST, IDC_LBS_DISPLAY);
  81.                  lbs_display = TRUE;
  82.                  lbs_extract = FALSE;
  83.                  lbs_test = FALSE;
  84.                  break;
  85.          case 2:
  86.                  CheckRadioButton(hwndDlg, IDC_LBS_EXTRACT,
  87.                     IDC_LBS_TEST, IDC_LBS_TEST);
  88.                  lbs_test = TRUE;
  89.                  lbs_extract = FALSE;
  90.                  lbs_display = FALSE;
  91.                  break;
  92.          }
  93.       }
  94.       break;
  95.     /*
  96.      * NOTE: WM_CTLCOLOR is not a supported code under Win 32
  97.      */
  98. #ifdef WIN32
  99.     case WM_CTLCOLORSTATIC:
  100.     case WM_CTLCOLORBTN:
  101.     case WM_CTLCOLORDLG:
  102. #else
  103.     case WM_CTLCOLOR: /* color background of buttons and statics */
  104.         if ((HIWORD(lParam) == CTLCOLOR_STATIC) ||
  105.            (HIWORD(lParam) == CTLCOLOR_BTN) ||
  106.            (HIWORD(lParam) == CTLCOLOR_DLG))
  107. #endif
  108.            {
  109.            POINT point;
  110.            SetBkMode((HDC)wParam, OPAQUE);
  111.            SetBkColor((HDC)wParam, GetSysColor(COLOR_MENU));
  112.            SetTextColor((HDC)wParam, GetSysColor(COLOR_MENUTEXT));
  113.            UnrealizeObject(hBrush);
  114.            point.x = point.y = 0;
  115.            ClientToScreen(hwndDlg, &point);
  116. #ifndef WIN32
  117.            SetBrushOrg((HDC)wParam, point.x, point.y);
  118. #else
  119.            SetBrushOrgEx((HDC)wParam, point.x, point.y, NULL);
  120. #endif
  121.            hBrush = CreateSolidBrush(GetSysColor(COLOR_MENU));
  122.            return ((DWORD)hBrush);
  123.            }
  124.    case WM_COMMAND:
  125.       switch (LOWORD(wParam)) {
  126.          case IDCANCEL:
  127.             EndDialog(hwndDlg, wParam);
  128.             break;
  129.          case IDOK:
  130.             {
  131.             if (lbs_extract == TRUE)
  132.                {
  133.                fLB_Selection = 0;
  134.                wLBSelection = IDM_LB_EXTRACT;
  135.                }
  136.             if (lbs_display == TRUE)
  137.                {
  138.                fLB_Selection = 1;
  139.                wLBSelection = IDM_LB_DISPLAY;
  140.                }
  141.             if (lbs_test == TRUE)
  142.                {
  143.                fLB_Selection = 2;
  144.                wLBSelection = IDM_LB_TEST;
  145.                }
  146.             uf.fRecreateDirs = recreate_dir;
  147.             lpDCL->noflag = overwrite;
  148.             lpDCL->ExtractOnlyNewer = newer;
  149.             lpDCL->PromptToOverwrite = prompt_overwrite;
  150.             uf.fTranslate = lf_crlf;
  151.             lpDCL->SpaceToUnderscore = space_underscore;
  152. #ifdef WIN32
  153.             lpDCL->fPrivilege = fPrivilege;
  154. #endif
  155.             WriteZipOptionsProfile();
  156.             EndDialog(hwndDlg, wParam);
  157.             break;
  158.             }
  159.          case IDC_RECREATE_DIR:
  160.             recreate_dir = !recreate_dir;
  161.             CheckDlgButton(hwndDlg, IDC_RECREATE_DIR, recreate_dir);
  162.             break;
  163. #ifdef WIN32
  164.          case IDC_ACL:
  165.             if (!dwPlatformId)
  166.                break;
  167.             i = IsDlgButtonChecked(hwndDlg, IDC_ACL);
  168.             if (i)
  169.                {
  170.                fPrivilege = 0;
  171.                CheckDlgButton(hwndDlg, IDC_ACL, FALSE);
  172.                CheckDlgButton(hwndDlg, IDC_PRIVILEGE, FALSE);
  173.                }
  174.             else
  175.                {
  176.                fPrivilege = 1;
  177.                CheckDlgButton(hwndDlg, IDC_ACL, TRUE);
  178.                CheckDlgButton(hwndDlg, IDC_PRIVILEGE, FALSE);
  179.                }
  180.             break;
  181.          case IDC_PRIVILEGE:
  182.             if (!dwPlatformId)
  183.                break;
  184.             i = IsDlgButtonChecked(hwndDlg, IDC_PRIVILEGE);
  185.             if (i)
  186.                {
  187.                fPrivilege = 0;
  188.                CheckDlgButton(hwndDlg, IDC_ACL, FALSE);
  189.                CheckDlgButton(hwndDlg, IDC_PRIVILEGE, FALSE);
  190.                }
  191.             else
  192.                {
  193.                fPrivilege = 2;
  194.                CheckDlgButton(hwndDlg, IDC_ACL, FALSE);
  195.                CheckDlgButton(hwndDlg, IDC_PRIVILEGE, TRUE);
  196.                }
  197.             break;
  198. #endif
  199.          case IDC_OVERWRITE:
  200.             overwrite = TRUE;
  201.             newer = FALSE;
  202.             prompt_overwrite = FALSE;
  203.             CheckRadioButton(hwndDlg, IDC_OVERWRITE,
  204.                IDC_PROMPT_OVERWRITE, IDC_OVERWRITE);
  205.             break;
  206.          case IDC_NEWER:
  207.             newer = TRUE;
  208.             overwrite = FALSE;
  209.             prompt_overwrite = FALSE;
  210.             CheckRadioButton(hwndDlg, IDC_OVERWRITE,
  211.                IDC_PROMPT_OVERWRITE, IDC_NEWER);
  212.             break;
  213.          case IDC_PROMPT_OVERWRITE:
  214.             prompt_overwrite = TRUE;
  215.             overwrite = FALSE;
  216.             newer = FALSE;
  217.             CheckRadioButton(hwndDlg, IDC_OVERWRITE,
  218.                IDC_PROMPT_OVERWRITE, IDC_PROMPT_OVERWRITE);
  219.             break;
  220.          case IDC_LF_CRLF:
  221.             {
  222.             lf_crlf = !lf_crlf;
  223.             if (lf_crlf)
  224.                {
  225.                if (MessageBox(hwndDlg, CRLF_WARNING, "Warning About Conversions",
  226.                   MB_OKCANCEL | MB_ICONEXCLAMATION) != IDOK)
  227.                   lf_crlf = FALSE;
  228.                }
  229.             CheckDlgButton(hwndDlg, IDC_LF_CRLF, lf_crlf);
  230.             break;
  231.             }
  232.          case IDC_SPACE_UNDERSCORE:
  233.             space_underscore = !space_underscore;
  234.             CheckDlgButton(hwndDlg, IDC_SPACE_UNDERSCORE,
  235.                space_underscore);
  236.             break;
  237.          case IDC_LBS_EXTRACT:
  238.             lbs_extract = TRUE;
  239.             lbs_display = FALSE;
  240.             lbs_test = FALSE;
  241.             CheckRadioButton(hwndDlg, IDC_LBS_EXTRACT, IDC_LBS_TEST,
  242.                   IDC_LBS_EXTRACT);
  243.             break;
  244.          case IDC_LBS_DISPLAY:
  245.             lbs_display = TRUE;
  246.             lbs_extract = FALSE;
  247.             lbs_test = FALSE;
  248.             CheckRadioButton(hwndDlg, IDC_LBS_EXTRACT, IDC_LBS_TEST,
  249.                IDC_LBS_DISPLAY);
  250.             break;
  251.          case IDC_LBS_TEST:
  252.             lbs_test = TRUE;
  253.             lbs_display = FALSE;
  254.             lbs_extract = FALSE;
  255.             CheckRadioButton(hwndDlg, IDC_LBS_EXTRACT, IDC_LBS_TEST,
  256.                IDC_LBS_TEST);
  257.             break;
  258.          case ID_HELP:
  259.             WinHelp(hwndDlg,szHelpFileName,HELP_CONTEXT, (DWORD)(HELPID_UNZIP_OPTIONS));
  260.             break;
  261.          }
  262.       default:
  263.          break;
  264.    }
  265.    return FALSE;
  266. }
  267. #ifdef __BORLANDC__
  268. #pragma warn .par
  269. #pragma warn .aus
  270. #endif