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

压缩解压

开发平台:

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. /****************************************************************************
  13.     FUNCTION: ZipPreferencesProc(HWND, unsigned, WPARAM, LPARAM)
  14.     PURPOSE:  Processes messages for "Get Preferences" dialog box
  15.     MESSAGES:
  16.     WM_INITDIALOG - initialize dialog box
  17.     WM_COMMAND    - Input received
  18. ****************************************************************************/
  19. #ifdef __BORLANDC__
  20. #pragma warn -par
  21. #pragma warn -aus
  22. #endif
  23. DWORD WINAPI
  24. ZipPreferencesProc(HWND hwndDlg, UINT wMessage, WPARAM wParam, LPARAM lParam)
  25. {
  26. int i;
  27. #ifndef WIN32
  28. FARPROC lpfnDate;
  29. #endif
  30.    switch (wMessage) {
  31.    case WM_INITDIALOG:
  32.       {
  33.       char digits[2];
  34.       ZPOPT zo;
  35.       /* Check to see if encryption is supported in the zip dll */
  36.       zo = ZipGetOptions();
  37.       if (!zo.fEncryption)
  38.          ShowWindow(GetDlgItem(hwndDlg, IDC_ENCRYPT), SW_HIDE);
  39. #ifndef WIN32
  40.       ShowWindow(GetDlgItem(hwndDlg, IDC_MAKE_W32_SFX), SW_HIDE);
  41.       ShowWindow(GetDlgItem(hwndDlg, IDC_ACL), SW_HIDE);
  42.       ShowWindow(GetDlgItem(hwndDlg, IDC_PRIVILEGE), SW_HIDE);
  43. #endif
  44.       CenterDialog(GetParent(hwndDlg), hwndDlg); /* center on parent */
  45.       for (i = 0; i < 10; i++)
  46.          {
  47.          char str[10];
  48.          itoa(i, digits, 10);
  49.          switch (i)
  50.             {
  51.             case 0:
  52.                lstrcpy(str, "0 store");
  53.                break;
  54.             case 1:
  55.                lstrcpy(str, "1 minimum");
  56.                break;
  57.             case 6:
  58.                lstrcpy(str, "6 default");
  59.                break;
  60.             case 9:
  61.                lstrcpy(str, "9 maximum");
  62.                break;
  63.             default:
  64.                lstrcpy(str, digits);
  65.             }
  66.          SendMessage(GetDlgItem(hwndDlg, IDC_COMPRESSION), LB_ADDSTRING,
  67.             0, (LPARAM)(LPCSTR)str);
  68.          }
  69.       digits[0] = ZpOpt.fLevel;
  70.       digits[1] = '';
  71.       SendMessage(GetDlgItem(hwndDlg, IDC_COMPRESSION), LB_SELECTSTRING,
  72.          0, (LPARAM)(LPCSTR)digits);
  73.       CheckDlgButton(hwndDlg, IDC_VERBOSE, ZpOpt.fVerbose);
  74.       CheckDlgButton(hwndDlg, IDC_MSDOS, ZpOpt.fForce);
  75.       CheckDlgButton(hwndDlg, IDC_SYS_FILES, ZpOpt.fSystem);
  76.       CheckDlgButton(hwndDlg, IDC_VOL_LABEL, ZpOpt.fVolume);
  77.       CheckDlgButton(hwndDlg, IDC_NO_DIR_ENTRY, ZpOpt.fNoDirEntries);
  78.       CheckDlgButton(hwndDlg, IDC_IGNORE_DIR, ZpOpt.fJunkDir);
  79.       CheckDlgButton(hwndDlg, IDC_CRLFLF, ZpOpt.fCRLF_LF);
  80.       CheckDlgButton(hwndDlg, IDC_LFCRLF, ZpOpt.fLF_CRLF);
  81.       CheckDlgButton(hwndDlg, IDC_ENCRYPT, ZpOpt.fEncrypt);
  82.       CheckDlgButton(hwndDlg, IDC_RECURSE, ZpOpt.fRecurse);
  83.       CheckDlgButton(hwndDlg, IDC_MOVE, ZpOpt.fMove);
  84.       CheckDlgButton(hwndDlg, IDC_FILETIME, ZpOpt.fLatestTime);
  85.       CheckDlgButton(hwndDlg, IDC_UPDATE, ZpOpt.fUpdate);
  86.       CheckDlgButton(hwndDlg, IDC_FRESHEN, ZpOpt.fFreshen);
  87.       CheckDlgButton(hwndDlg, IDC_COMMENT, ZpOpt.fComment);
  88.       CheckDlgButton(hwndDlg, IDC_QUIET, ZpOpt.fQuiet);
  89. #ifdef WIN32
  90.       CheckDlgButton(hwndDlg, IDC_MAKE_DOS_SFX, (fMakeSFX & fMakeDosSFX));
  91.       CheckDlgButton(hwndDlg, IDC_MAKE_W32_SFX, (fMakeSFX & !fMakeDosSFX));
  92.       CheckDlgButton(hwndDlg, IDC_ACL, ZpOpt.fExtra);
  93. #else
  94.       CheckDlgButton(hwndDlg, IDC_MAKE_DOS_SFX, fMakeSFX);
  95. #endif
  96.       if (ZpOpt.fRepair == 1)
  97.          CheckDlgButton(hwndDlg, IDC_REPAIR, TRUE);
  98.       else
  99.          CheckDlgButton(hwndDlg, IDC_REPAIR, FALSE);
  100.       if (ZpOpt.fRepair ==2)
  101.          CheckDlgButton(hwndDlg, IDC_REPAIR_MORE, TRUE);
  102.       else
  103.          CheckDlgButton(hwndDlg, IDC_REPAIR_MORE, FALSE);
  104. #ifdef WIN32
  105.       CheckDlgButton(hwndDlg, IDC_PRIVILEGE, ZpOpt.fPrivilege);
  106. #endif
  107.       }
  108.       break;
  109.     /*
  110.      * NOTE: WM_CTLCOLOR is not a supported code under Win 32
  111.      */
  112. #ifdef WIN32
  113.     case WM_CTLCOLORSTATIC:
  114.     case WM_CTLCOLORBTN:
  115.     case WM_CTLCOLORDLG:
  116. #else
  117.     case WM_CTLCOLOR: /* color background of buttons and statics */
  118.         if ((HIWORD(lParam) == CTLCOLOR_STATIC) ||
  119.            (HIWORD(lParam) == CTLCOLOR_BTN) ||
  120.            (HIWORD(lParam) == CTLCOLOR_DLG))
  121. #endif
  122.            {
  123.            POINT point;
  124.            SetBkMode((HDC)wParam, OPAQUE);
  125.            SetBkColor((HDC)wParam, GetSysColor(COLOR_MENU));
  126.            SetTextColor((HDC)wParam, GetSysColor(COLOR_MENUTEXT));
  127.            UnrealizeObject(hBrush);
  128.            point.x = point.y = 0;
  129.            ClientToScreen(hwndDlg, &point);
  130. #ifndef WIN32
  131.            SetBrushOrg((HDC)wParam, point.x, point.y);
  132. #else
  133.            SetBrushOrgEx((HDC)wParam, point.x, point.y, NULL);
  134. #endif
  135.            hBrush = CreateSolidBrush(GetSysColor(COLOR_MENU));
  136.            return ((DWORD)hBrush);
  137.            }
  138.    case WM_COMMAND:
  139.       switch (LOWORD(wParam)) {
  140.          case IDCANCEL:
  141.             EndDialog(hwndDlg, wParam);
  142.             break;
  143.          case IDOK:
  144.             /* Zip Options */
  145.             {
  146.             ZpOpt.fLevel = (char)(SendMessage(GetDlgItem(hwndDlg, IDC_COMPRESSION),
  147.                LB_GETCURSEL, 0, 0) + '0');
  148.             EndDialog(hwndDlg, wParam);
  149.             break;
  150.             }
  151.          /* Zip Options */
  152.          case IDC_ZIP_EXCLUDE_DATE:
  153.                ZpOpt.fExcludeDate = !ZpOpt.fExcludeDate;
  154.                if (ZpOpt.fExcludeDate)
  155.                   {
  156.                   ZpOpt.fIncludeDate = FALSE;
  157. #ifndef WIN32
  158.                   lpfnDate = MakeProcInstance(GetDateProc, hInst);
  159.                   DialogBox(hInst, "GETDATE", hwndDlg, lpfnDate);
  160.                   FreeProcInstance(lpfnDate);
  161. #else
  162.                   DialogBox(hInst, "GETDATE", hwndDlg, GetDateProc);
  163. #endif
  164.                   }
  165.                if (ZpOpt.Date[0] == '')
  166.                   ZpOpt.fExcludeDate = FALSE;
  167.                CheckDlgButton(hwndDlg, IDC_ZIP_EXCLUDE_DATE, ZpOpt.fExcludeDate);
  168.                CheckDlgButton(hwndDlg, IDC_ZIP_INCLUDE_DATE, ZpOpt.fIncludeDate);
  169.                break;
  170.          case IDC_ZIP_INCLUDE_DATE:
  171.                ZpOpt.fIncludeDate = !ZpOpt.fIncludeDate;
  172.                if (ZpOpt.fIncludeDate)
  173.                   {
  174.                   ZpOpt.fExcludeDate = FALSE;
  175. #ifndef WIN32
  176.                   lpfnDate = MakeProcInstance(GetDateProc, hInst);
  177.                   DialogBox(hInst, "GETDATE", hwndDlg, lpfnDate);
  178.                   FreeProcInstance(lpfnDate);
  179. #else
  180.                   DialogBox(hInst, "GETDATE", hwndDlg, GetDateProc);
  181. #endif
  182.                   }
  183.                if (ZpOpt.Date[0] == '')
  184.                   ZpOpt.fIncludeDate = FALSE;
  185.                CheckDlgButton(hwndDlg, IDC_ZIP_EXCLUDE_DATE, ZpOpt.fExcludeDate);
  186.                CheckDlgButton(hwndDlg, IDC_ZIP_INCLUDE_DATE, ZpOpt.fIncludeDate);
  187.                break;
  188.          case IDC_REPAIR:
  189.             i = IsDlgButtonChecked(hwndDlg, IDC_REPAIR);
  190.             if (i)
  191.                {
  192.                ZpOpt.fRepair = 0;
  193.                CheckDlgButton(hwndDlg, IDC_REPAIR, FALSE);
  194.                CheckDlgButton(hwndDlg, IDC_REPAIR_MORE, FALSE);
  195.                }
  196.             else
  197.                {
  198.                ZpOpt.fRepair = 1;
  199.                CheckDlgButton(hwndDlg, IDC_REPAIR, TRUE);
  200.                CheckDlgButton(hwndDlg, IDC_REPAIR_MORE, FALSE);
  201.                }
  202.             break;
  203.          case IDC_REPAIR_MORE:
  204.             i = IsDlgButtonChecked(hwndDlg, IDC_REPAIR_MORE);
  205.             if (i)
  206.                {
  207.                ZpOpt.fRepair = 0;
  208.                CheckDlgButton(hwndDlg, IDC_REPAIR, FALSE);
  209.                CheckDlgButton(hwndDlg, IDC_REPAIR_MORE, FALSE);
  210.                }
  211.             else
  212.                {
  213.                ZpOpt.fRepair = 2;
  214.                CheckDlgButton(hwndDlg, IDC_REPAIR, FALSE);
  215.                CheckDlgButton(hwndDlg, IDC_REPAIR_MORE, TRUE);
  216.                }
  217.             break;
  218.          case IDC_ACL:
  219.             ZpOpt.fExtra = !ZpOpt.fExtra;
  220.             CheckDlgButton(hwndDlg, IDC_ACL, ZpOpt.fExtra);
  221.             if (ZpOpt.fExtra)
  222.                {
  223.                ZpOpt.fPrivilege = FALSE;
  224.                CheckDlgButton(hwndDlg, IDC_PRIVILEGE, FALSE);
  225.                }
  226.             break;
  227. #ifdef WIN32
  228.          case IDC_PRIVILEGE:
  229.             if (dwPlatformId)
  230.                {
  231.                ZpOpt.fPrivilege = !ZpOpt.fPrivilege;
  232.                CheckDlgButton(hwndDlg, IDC_PRIVILEGE, ZpOpt.fPrivilege);
  233.                ZpOpt.fExtra = FALSE;
  234.                CheckDlgButton(hwndDlg, IDC_ACL, ZpOpt.fExtra);
  235.                }
  236.             break;
  237. #endif
  238.          case IDC_MAKE_DOS_SFX:
  239. #ifdef WIN32
  240.             fMakeDosSFX = TRUE;
  241.             if (IsDlgButtonChecked(hwndDlg, IDC_MAKE_W32_SFX))
  242.                fMakeSFX = TRUE;
  243.             else
  244.                fMakeSFX = !fMakeSFX;
  245.             CheckDlgButton(hwndDlg, IDC_MAKE_W32_SFX, FALSE);
  246. #else
  247.             fMakeSFX = !fMakeSFX;
  248. #endif
  249.             CheckDlgButton(hwndDlg, IDC_MAKE_DOS_SFX, fMakeSFX);
  250.             break;
  251. #ifdef WIN32
  252.          case IDC_MAKE_W32_SFX:
  253.             fMakeDosSFX = FALSE;
  254.             if (IsDlgButtonChecked(hwndDlg, IDC_MAKE_DOS_SFX))
  255.                fMakeSFX = TRUE;
  256.             else
  257.                fMakeSFX = !fMakeSFX;
  258.             CheckDlgButton(hwndDlg, IDC_MAKE_DOS_SFX, FALSE);
  259.             CheckDlgButton(hwndDlg, IDC_MAKE_W32_SFX, fMakeSFX);
  260.             break;
  261. #endif
  262.          case IDC_MSDOS:
  263.             ZpOpt.fForce = !ZpOpt.fForce;
  264.             CheckDlgButton(hwndDlg, IDC_MSDOS, ZpOpt.fForce);
  265.             break;
  266.          case IDC_SYS_FILES:
  267.             ZpOpt.fSystem = !ZpOpt.fSystem;
  268.             CheckDlgButton(hwndDlg, IDC_SYS_FILES, ZpOpt.fSystem);
  269.             break;
  270.          case IDC_VOL_LABEL:
  271.             ZpOpt.fVolume = !ZpOpt.fVolume;
  272.             CheckDlgButton(hwndDlg, IDC_VOL_LABEL, ZpOpt.fVolume);
  273.             break;
  274.          case IDC_NO_DIR_ENTRY:
  275.             ZpOpt.fNoDirEntries = !ZpOpt.fNoDirEntries;
  276.             CheckDlgButton(hwndDlg, IDC_NO_DIR_ENTRY, ZpOpt.fNoDirEntries);
  277.             break;
  278.          case IDC_IGNORE_DIR:
  279.             ZpOpt.fJunkDir = !ZpOpt.fJunkDir;
  280.             CheckDlgButton(hwndDlg, IDC_IGNORE_DIR, ZpOpt.fJunkDir);
  281.             break;
  282.          case IDC_CRLFLF:
  283.             ZpOpt.fCRLF_LF = !ZpOpt.fCRLF_LF;
  284.             if (ZpOpt.fCRLF_LF)
  285.                {
  286.                ZpOpt.fLF_CRLF = FALSE;
  287.                CheckDlgButton(hwndDlg, IDC_LFCRLF, ZpOpt.fLF_CRLF);
  288.                }
  289.             CheckDlgButton(hwndDlg, IDC_CRLFLF, ZpOpt.fCRLF_LF);
  290.             break;
  291.          case IDC_LFCRLF:
  292.             ZpOpt.fLF_CRLF = !ZpOpt.fLF_CRLF;
  293.             if (ZpOpt.fLF_CRLF)
  294.                {
  295.                ZpOpt.fCRLF_LF = FALSE;
  296.                CheckDlgButton(hwndDlg, IDC_CRLFLF, ZpOpt.fCRLF_LF);
  297.                }
  298.             CheckDlgButton(hwndDlg, IDC_LFCRLF, ZpOpt.fLF_CRLF);
  299.             break;
  300.          case IDC_ENCRYPT:
  301.             ZpOpt.fEncrypt = !ZpOpt.fEncrypt;
  302.             CheckDlgButton(hwndDlg, IDC_ENCRYPT, ZpOpt.fEncrypt);
  303.             break;
  304.          case IDC_RECURSE:
  305.             ZpOpt.fRecurse = !ZpOpt.fRecurse;
  306.             CheckDlgButton(hwndDlg, IDC_RECURSE, ZpOpt.fRecurse);
  307.             break;
  308.          case IDC_MOVE:
  309.             ZpOpt.fMove = !ZpOpt.fMove;
  310.             CheckDlgButton(hwndDlg, IDC_MOVE, ZpOpt.fMove);
  311.             break;
  312.          case IDC_FILETIME:
  313.             ZpOpt.fLatestTime = !ZpOpt.fLatestTime;
  314.             CheckDlgButton(hwndDlg, IDC_FILETIME, ZpOpt.fLatestTime);
  315.             break;
  316.          case IDC_UPDATE:
  317.             ZpOpt.fUpdate = !ZpOpt.fUpdate;
  318.             CheckDlgButton(hwndDlg, IDC_UPDATE, ZpOpt.fUpdate);
  319.             break;
  320.          case IDC_FRESHEN:
  321.             ZpOpt.fFreshen = !ZpOpt.fFreshen;
  322.             CheckDlgButton(hwndDlg, IDC_FRESHEN, ZpOpt.fFreshen);
  323.             break;
  324.          case IDC_COMMENT:
  325.             ZpOpt.fComment = !ZpOpt.fComment;
  326.             CheckDlgButton(hwndDlg, IDC_COMMENT, ZpOpt.fComment);
  327.             break;
  328.          case IDC_QUIET:
  329.             ZpOpt.fQuiet = !ZpOpt.fQuiet;
  330.             CheckDlgButton(hwndDlg, IDC_QUIET, ZpOpt.fQuiet);
  331.             break;
  332.          case IDC_VERBOSE:
  333.             ZpOpt.fVerbose = !ZpOpt.fVerbose;
  334.             CheckDlgButton(hwndDlg, IDC_VERBOSE, ZpOpt.fVerbose);
  335.             break;
  336.          case IDC_OFFSETS:
  337.             ZpOpt.fOffsets = !ZpOpt.fOffsets;
  338.             CheckDlgButton(hwndDlg, IDC_OFFSETS, ZpOpt.fOffsets);
  339.             break;
  340.          case ID_HELP:
  341.             WinHelp(hwndDlg,szHelpFileName,HELP_CONTEXT, (DWORD)(HELPID_ZIP_OPTIONS));
  342.             break;
  343.          }
  344.       default:
  345.          break;
  346.    }
  347.    return FALSE;
  348. }
  349. #ifdef __BORLANDC__
  350. #pragma warn .par
  351. #pragma warn .aus
  352. #endif