⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wndproc.c

📁 有关zip的一个开发实例。主要包括图片和程序源代码。
💻 C
📖 第 1 页 / 共 5 页
字号:
                   if (szUnzipToDirName[1] == ':')                      {                      drive = szUnzipToDirName[0];                      if (lstrlen(szUnzipToDirName) == 2)                         { /* We only have a drive letter and a colon */                         lstrcat(szUnzipToDirName, "\\");                         }                      }                   else                      drive = '\0';                   if (uf.fSaveUnZipToDir &&                      (toupper(drive) != 'A') &&                      (toupper(drive) != 'B'))                       {                  /* Always save last directory written to */                       WritePrivateProfileString(szAppName, szDefaultUnzipToDir,                          szUnzipToDirName, szWiZIniFile);                       }                   SetCaption(hWnd);                   }                else /* either real error or canceled */                   {                   DWORD dwExtdError = CommDlgExtendedError(); /* debugging */                   if (dwExtdError != 0L) /* if not canceled then real error */                      {                      wsprintf (lpumb->szBuffer, szCantChDir, dwExtdError);                      MessageBox (hWnd, lpumb->szBuffer, szAppName, MB_ICONINFORMATION | MB_OK);                      }                   }#ifndef WIN32                FreeProcInstance(lpfnSelectDir);#endif                if ( uf.fCanDragDrop )                    DragAcceptFiles( hWnd, TRUE );                break;            case IDM_DELETE_ARCHIVE:                {                char szStr[PATH_MAX];                if ( uf.fCanDragDrop )                    DragAcceptFiles( hWnd, FALSE );                sprintf(szStr, "Are you sure you want to delete\n%s", lpumb->szFileName);                if (MessageBox(hWnd, szStr, "Deleting File", MB_ICONSTOP | MB_OKCANCEL) == IDOK)                   {                   remove(lpumb->szFileName);                   BufferOut("Deleting %s\n", lpumb->szFileName);#ifndef WIN32                   SendMessage(hWndList, LB_RESETCONTENT, 0, 0);#else                   ListView_DeleteAllItems(hWndList);#endif                   lpumb->szFileName[0] = '\0';                   SetCaption(hWnd);                   UpdateButtons(); /* update state of buttons */                   }                if ( uf.fCanDragDrop )                  DragAcceptFiles( hWnd, TRUE );                break;                }            case IDM_MOVE_ARCHIVE:                /*                 * Yes - this can be done under Win32 differently, but                 * you have to go through some hoops, and this just makes                 * it easier.                 */                move_flag = TRUE;                dwCommDlgHelpId = HELPID_MOVE_ARCHIVE; /* in case user hits "help" button */            case IDM_RENAME_ARCHIVE:                if (!move_flag)                   {                   rename_flag = TRUE;                   dwCommDlgHelpId = HELPID_RENAME_ARCHIVE; /* in case user hits "help" button */                   }            case IDM_COPY_ARCHIVE:                if ( uf.fCanDragDrop )                    DragAcceptFiles( hWnd, FALSE );                if ((!move_flag) && (!rename_flag))                   dwCommDlgHelpId = HELPID_COPY_ARCHIVE; /* in case user hits "help" button */                CopyArchive(hWnd, move_flag, rename_flag);                if ( uf.fCanDragDrop )                    DragAcceptFiles( hWnd, TRUE );                move_flag = FALSE;                rename_flag = FALSE;                break;            case IDM_EXIT:                WriteZipOptionsProfile();                SendMessage(hWnd, WM_CLOSE, 0, 0L);                break;            case IDM_HELP:  /* Display Help */#ifndef WIN32                WinHelp(hWnd,szHelpFileName,HELP_INDEX,0L);#else                WinHelp(hWnd,szHelpFileName,HELP_FINDER,0L);#endif                break;            case IDM_SHIFT_HELP:                uf.fHelp = TRUE;                SetCursor(hHelpCursor);                break;            case IDM_ESCAPE:                if (uf.fHelp)                    {                   uf.fHelp = FALSE;#ifndef WIN32                   SetCursor((HCURSOR)GetClassWord(hWndMain,GCW_HCURSOR));#else                   SetCursor((HCURSOR)GetClassLong(hWndMain,GCL_HCURSOR));#endif                   dwHelpContextId = (DWORD) 0L;                   return 0;                   }                break;            case IDM_HELP_HELP:                WinHelp(hWnd,"WINHELP.HLP",HELP_INDEX,0L);                break;            case IDM_ABOUT:                if ( uf.fCanDragDrop )                    DragAcceptFiles( hWnd, FALSE );#ifndef WIN32                lpfnAbout = MakeProcInstance(AboutProc, hInst);                DialogBox(hInst, "About", hWnd, lpfnAbout);                FreeProcInstance(lpfnAbout);#else                DialogBox(hInst, "About", hWnd, AboutProc);#endif                if ( uf.fCanDragDrop )                    DragAcceptFiles( hWnd, TRUE );                break;#ifndef WIN32            case IDM_LISTBOX:       /* command from listbox     */                if (cZippedFiles)                {                    switch (GET_WM_COMMAND_CMD(wParam, lParam))                    {                    case LBN_SELCHANGE:                        UpdateButtons();                        break;                    case LBN_DBLCLK:                        UpdateButtons();                        if ( uf.fCanDragDrop )                            DragAcceptFiles( hWnd, FALSE );                        Action(hWnd, (WPARAM)(wLBSelection - IDM_LB_EXTRACT));                        if ( uf.fCanDragDrop )                            DragAcceptFiles( hWnd, TRUE );                        break;                    }                }                break;            case IDM_LONG:            case IDM_SHORT:                /* If format change, uncheck old, check new. */                if ((LOWORD(wParam) - IDM_SHORT) != (signed int)uf.fFormatLong)                {                    WPARAM wFormatTmp = (WPARAM)(LOWORD(wParam)  - IDM_SHORT);                    int __far *pnSelItems; /* pointer to list of selected items */                    HANDLE  hnd = 0;                    int cSelLBItems ; /* no. selected items in listbox */                    RECT    rClient;                    cSelLBItems = CLBItemsGet(hWndList, &pnSelItems, &hnd);                    CheckMenuItem(hMenu, (IDM_SHORT+uf.fFormatLong), MF_BYCOMMAND|MF_UNCHECKED);                    CheckMenuItem(hMenu, (IDM_SHORT+wFormatTmp), MF_BYCOMMAND|MF_CHECKED);                    uf.fFormatLong = wFormatTmp;                    UpdateListBox();                    WriteZipOptionsProfile();                    /* anything previously selected ? */                    if (cSelLBItems > 0)                       {                       ReselectLB(hWndList, cSelLBItems, pnSelItems);                       GlobalUnlock(hnd);                       GlobalFree(hnd);                       }                    /* make sure labels & Zip archive totals get updated */                    WinAssert(hWnd);                    GetClientRect( hWnd, &rClient );                    /* Drop down two lines for button row */                    rClient.top = (2*dyChar);                    rClient.bottom = rClient.top + (2*dyChar);                    /* Okay, now we selected only the "header" for                     * repainting, invalidate it.                     */                    InvalidateRect( hWnd, &rClient, TRUE);                    WinAssert(hWndList);                    GetClientRect( hWndList, &rClient );                    rClient.top = rClient.bottom;                    /* Now allow for two lines for button row,                     * two lines for the "header" and two lines                     * for the trailer. Then invalidate it.                     */                    rClient.bottom = rClient.top + (6*dyChar);                    InvalidateRect( hWnd, &rClient, TRUE);                }                break;#endif            case IDM_SAVE_UNZIP_TO_DIR:                /* Toggle value of fSaveUnzipToDir flag. */                uf.fSaveUnZipToDir = !uf.fSaveUnZipToDir;                CheckMenuItem(hMenu,IDM_SAVE_UNZIP_TO_DIR,MF_BYCOMMAND|                                (WORD)(uf.fSaveUnZipToDir ? MF_CHECKED: MF_UNCHECKED));                WriteZipOptionsProfile();                if (uf.fSaveUnZipToDir)                   WritePrivateProfileString(szAppName, szDefaultUnzipToDir,                         "", szWiZIniFile);                break;            case IDM_SAVE_UNZIP_FROM_DIR:                /* Toggle value of fSaveUnzipToDir flag. */                uf.fSaveUnZipFromDir = !uf.fSaveUnZipFromDir;                CheckMenuItem(hMenu,IDM_SAVE_UNZIP_FROM_DIR,MF_BYCOMMAND|                                (WORD)(uf.fSaveUnZipFromDir ? MF_CHECKED: MF_UNCHECKED));                WriteZipOptionsProfile();                if (uf.fSaveUnZipFromDir)                   WritePrivateProfileString(szAppName, szDefaultUnzipFromDir,                         "", szWiZIniFile);                break;            case IDM_UNZIP_TO_ZIP_DIR:                /* toggle value of Unzip to .ZIP  */                uf.fUnzipToZipDir = !uf.fUnzipToZipDir;                CheckMenuItem(hMenu,IDM_UNZIP_TO_ZIP_DIR,MF_BYCOMMAND|                                    (WORD)(uf.fUnzipToZipDir ? MF_CHECKED:MF_UNCHECKED));                EnableMenuItem(hMenu,IDM_CHDIR,MF_BYCOMMAND|                                    (WORD)(uf.fUnzipToZipDir ? MF_GRAYED:MF_ENABLED));                WriteZipOptionsProfile();                if (uf.fUnzipToZipDir && lpumb->szDirName[0])                   {                   lstrcpy(szUnzipToDirName, lpumb->szDirName); /* get new dirname */                   SetCaption(hWnd);                   }                break;            case IDM_SAVE_ZIP_TO_DIR:               fSaveZipToDir = !fSaveZipToDir;               CheckMenuItem(hMenu, IDM_SAVE_ZIP_TO_DIR,                  MF_BYCOMMAND | (fSaveZipToDir ? MF_CHECKED : MF_UNCHECKED));               if (!fSaveZipToDir)                  szTargetZipDir[0] = '\0';               WriteZipOptionsProfile();               break;            case IDM_MAKE_DIR:               {               FARPROC lpfnMakeDir;               dwCommDlgHelpId = HELPID_MAKEDIR_HELP; /* if someone hits help */               lpfnMakeDir = MakeProcInstance(MakeDirProc, hInst);               DialogBox(hInst, "MAKEDIR", hWnd, lpfnMakeDir);#ifndef WIN32               FreeProcInstance(lpfnMakeDir);#endif               }               break;            case IDM_SOUND_OPTIONS: /* launch Sound Options dialog box   */             {            FARPROC lpfnSoundOptions;            dwCommDlgHelpId = HELPID_SOUND_OPTIONS; /* if someone hits "help" */                lpfnSoundOptions = MakeProcInstance(SoundProc, hInst);                DialogBox(hInst, "SOUND", hWnd, lpfnSoundOptions);#ifndef WIN32                FreeProcInstance(lpfnSoundOptions);#endif            }                break;            case IDM_SHOW_COMMENT:                /* display the archive comment in mesg window */                if ( uf.fCanDragDrop )                    DragAcceptFiles( hWnd, FALSE );                DisplayComment(hWnd);                if ( uf.fCanDragDrop )                    DragAcceptFiles( hWnd, TRUE );                break;            case IDM_SHOW_BUBBLE_HELP:                /* Show toolbar help */                uf.fShowBubbleHelp = !uf.fShowBubbleHelp;                CheckMenuItem(hMenu, IDM_SHOW_BUBBLE_HELP,                 MF_BYCOMMAND | (uf.fShowBubbleHelp ? MF_CHECKED : MF_UNCHECKED));                WriteZipOptionsProfile();                break;            case IDM_GET_ZIPINFO:            case IDM_UPDATE_ZIP:            case IDM_DISPLAY:            case IDM_TEST:            case IDM_EXTRACT:            case IDM_ZIP_DELETE_ENTRIES:                if ( uf.fCanDragDrop )                    DragAcceptFiles( hWnd, FALSE );                fUpdateEntries = TRUE;                Action(hWnd, (WPARAM)(LOWORD(wParam) - IDM_EXTRACT));                if (ZpOpt.fOffsets)                   {#ifndef WIN32                   DWORD i;                   i = SendMessage(hWndList , LB_GETCOUNT, 0, 0);                   SendMessage(hWndList , LB_SELITEMRANGE,                          (WPARAM) FALSE, MAKELONG(0, i));#else                   DWORD i, j;                   i = ListView_GetItemCount(hWndList);                   for (j = 0; j < i; j++)                        ListViewSetSel(j, TRUE);#endif                   }                if ( uf.fCanDragDrop )                    DragAcceptFiles( hWnd, TRUE );                break;            case IDM_SELECT_ALL:            case IDM_DESELECT_ALL:                if (cZippedFiles)                   {#ifndef WIN32                   SendMessage(hWndList , LB_SELITEMRANGE,                          (WPARAM)(LOWORD(wParam) == IDM_DESELECT_ALL ? FALSE : TRUE),                          MAKELONG(0, (cZippedFiles-1)));#else                   int i;                   int iItems = ListView_GetItemCount(hWndList);                   if (LOWORD(wParam) == IDM_DESELECT_ALL)                       for (i = 0; i < iItems; i++)                           ListViewSetSel(i, FALSE);                   else                       for (i = 0; i < iItems; i++)                           ListViewSetSel(i, TRUE);#endif                   UpdateButtons();                   }                break;         case IDM_SELECT_BY_PATTERN:            if (!hPatternSelectDlg)               {               DLGPROC lpfnPatternSelect;               dwCommDlgHelpId = HELPID_SELECT_BY_PATTERN;               lpfnPatternSelect = (DLGPROC)MakeProcInstance(PatternSelectProc, hInst);               WinAssert(lpfnPatternSelect)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -