Archive-Unzip-Burst
view release on metacpan or search on metacpan
unzip-6.0/wince/winmain.cpp view on Meta::CPAN
/*
Copyright (c) 1990-2003 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
//******************************************************************************
//
// File: WINMAIN.CPP
//
// Description: This module contains all the Windows specific code for Pocket
// UnZip. It contains the entire user interface. This code knows
// almost nothing about the Info-ZIP code. All Info-ZIP related
// functions are wrapped by helper functions in INTRFACE.CPP. The
// code in this module only calls those wrapper functions and
// INTRFACE.CPP handles all the details and callbacks of the
// Info-ZIP code.
//
// Copyright: All the source files for Pocket UnZip, except for components
// written by the Info-ZIP group, are copyrighted 1997 by Steve P.
// Miller. The product "Pocket UnZip" itself is property of the
// author and cannot be altered in any way without written consent
// from Steve P. Miller.
//
// Disclaimer: All project files are provided "as is" with no guarantee of
// their correctness. The authors are not liable for any outcome
// that is the result of using this source. The source for Pocket
// UnZip has been placed in the public domain to help provide an
// understanding of its implementation. You are hereby granted
// full permission to use this source in any way you wish, except
// to alter Pocket UnZip itself. For comments, suggestions, and
// bug reports, please write to stevemil@pobox.com.
//
// Functions: WinMain
// InitializeApplication
// ShutdownApplication
// RegisterUnzip
// BuildImageList
// WndProc
// OnCreate
// OnFileOpen
// OnActionView
// OnActionSelectAll
// OnViewExpandedView
// OnHelp
// OnGetDispInfo
// OnDeleteItem
// OnItemChanged
// Sort
// CompareFunc
// SetCaptionText
// DrawBanner
// AddDeleteColumns
// ResizeColumns
// GetZipErrorString
// AddFileToListView
// EnableAllMenuItems
// CheckAllMenuItems
// CenterWindow
// AddTextToEdit
// FormatValue
// BuildAttributesString
// BuildTypeString
// GetFileFromPath
// ForwardSlashesToBackSlashesA
// ForwardSlashesToBackSlashesW
// DeleteDirectory(LPTSTR szPath);
// RegWriteKey
// RegReadKey
// WriteOptionString
// WriteOptionInt
// GetOptionString
// GetOptionInt
// DisableEditing
// EditSubclassProc
// GetMenuString
unzip-6.0/wince/winmain.cpp view on Meta::CPAN
szMRU[i]);
// Increment our actual MRU count.
j++;
}
}
}
}
//******************************************************************************
void ActivateMRU(UINT uIDItem) {
TCHAR szFile[_MAX_PATH + 4];
// Get our menu handle.
#ifdef _WIN32_WCE
HMENU hMenu = GetSubMenu(CommandBar_GetMenu(g_hWndCmdBar, 0), 0);
#else
HMENU hMenu = GetSubMenu(GetMenu(g_hWndMain), 0);
#endif
// Query our menu for the selected MRU.
if (GetMenuString(hMenu, uIDItem, szFile, countof(szFile), MF_BYCOMMAND)) {
// Move past 3 character accelerator prefix and open the file.
ReadZipFileList(&szFile[3]);
}
}
//******************************************************************************
//***** Open Zip File Functions
//******************************************************************************
void ReadZipFileList(LPCTSTR wszPath) {
// Show wait cursor.
HCURSOR hCur = SetCursor(LoadCursor(NULL, IDC_WAIT));
TSTRTOMBS(g_szZipFile, wszPath, countof(g_szZipFile));
// Update our banner to show that we are loading.
g_fLoading = TRUE;
DrawBanner(NULL);
// Update our caption to show that we are loading.
SetCaptionText(TEXT("Loading"));
// Clear our list view.
ListView_DeleteAllItems(g_hWndList);
// Ghost all our Unzip related menu items.
EnableAllMenuItems(IDM_FILE_PROPERTIES, FALSE);
EnableAllMenuItems(IDM_ACTION_EXTRACT, FALSE);
EnableAllMenuItems(IDM_ACTION_EXTRACT_ALL, FALSE);
EnableAllMenuItems(IDM_ACTION_TEST, FALSE);
EnableAllMenuItems(IDM_ACTION_TEST_ALL, FALSE);
EnableAllMenuItems(IDM_ACTION_VIEW, FALSE);
EnableAllMenuItems(IDM_ACTION_SELECT_ALL, FALSE);
EnableAllMenuItems(IDM_VIEW_COMMENT, FALSE);
// Let Info-ZIP and our callbacks do the work.
SendMessage(g_hWndList, WM_SETREDRAW, FALSE, 0);
int result = DoListFiles(g_szZipFile);
SendMessage(g_hWndList, WM_SETREDRAW, TRUE, 0);
// Restore/remove cursor.
SetCursor(hCur);
// Update our column widths
ResizeColumns();
if ((result == PK_OK) || (result == PK_WARN)) {
// Sort the items by name.
Sort(0, TRUE);
// Update this file to our MRU list and menu.
AddFileToMRU(g_szZipFile);
// Enabled the comment button if the zip file has a comment.
if (lpUserFunctions->cchComment) {
EnableAllMenuItems(IDM_VIEW_COMMENT, TRUE);
}
// Update other items that are related to having a Zip file loaded.
EnableAllMenuItems(IDM_ACTION_EXTRACT_ALL, TRUE);
EnableAllMenuItems(IDM_ACTION_TEST_ALL, TRUE);
EnableAllMenuItems(IDM_ACTION_SELECT_ALL, TRUE);
} else {
// Make sure we didn't partially load and added a few files.
ListView_DeleteAllItems(g_hWndList);
// If the file itself is bad or missing, then remove it from our MRU.
if ((result == PK_ERR) || (result == PK_BADERR) || (result == PK_NOZIP) ||
(result == PK_FIND) || (result == PK_EOF))
{
RemoveFileFromMRU(wszPath);
}
// Display an error.
TCHAR szError[_MAX_PATH + 128];
_stprintf(szError, TEXT("Failure loading \"%s\".\n\n"), wszPath);
_tcscat(szError, GetZipErrorString(result));
MessageBox(g_hWndMain, szError, g_szAppName, MB_OK | MB_ICONERROR);
// Clear our file status.
*g_szZipFile = '\0';
}
// Update our caption to show that we are done loading.
SetCaptionText(NULL);
// Update our banner to show that we are done loading.
g_fLoading = FALSE;
DrawBanner(NULL);
}
//******************************************************************************
unzip-6.0/wince/winmain.cpp view on Meta::CPAN
ofn.lpstrFilter = TEXT("Programs (*.exe)\0*.exe\0All Files (*.*)\0*.*\0");
ofn.nFilterIndex = 1;
ofn.lpstrFile = szApp;
ofn.nMaxFile = _MAX_PATH;
ofn.lpstrInitialDir = szInitialDir;
ofn.lpstrTitle = TEXT("Open With...");
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST;
ofn.lpstrDefExt = TEXT("exe");
// Display the browse dialog and update our path edit box if neccessary.
if (GetOpenFileName(&ofn)) {
SetDlgItemText(hDlg, IDC_PATH, szApp);
}
break;
}
return FALSE;
}
return FALSE;
}
//******************************************************************************
//***** Comment Dialog Functions
//******************************************************************************
BOOL CALLBACK DlgProcComment(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
RECT rc;
HCURSOR hCur;
int result;
switch (uMsg) {
case WM_INITDIALOG:
// Get the handle to our edit box and store it globally.
g_hWndEdit = GetDlgItem(hDlg, IDC_COMMENT);
// Disable our edit box from being edited.
DisableEditing(g_hWndEdit);
#ifdef _WIN32_WCE
// Add "Ok" button to caption bar and make window No-Drag.
SetWindowLong(hDlg, GWL_EXSTYLE, WS_EX_CAPTIONOKBTN | WS_EX_NODRAG |
GetWindowLong(hDlg, GWL_EXSTYLE));
// On CE, we resize our dialog to be full screen (same size as parent).
GetWindowRect(g_hWndMain, &rc);
MoveWindow(hDlg, rc.left, rc.top, rc.right - rc.left,
rc.bottom - rc.top + 1, FALSE);
#else
// On NT we just center the dialog.
CenterWindow(hDlg);
#endif
// Set our edit control to be the full size of our dialog.
GetClientRect(hDlg, &rc);
MoveWindow(g_hWndEdit, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, FALSE);
// Show hour glass cursor while processing comment.
hCur = SetCursor(LoadCursor(NULL, IDC_WAIT));
// Let Info-ZIP and our callbacks do the work.
result = DoGetComment(g_szZipFile);
// Restore/remove our cursor.
SetCursor(hCur);
// Display an error dialog if an error occurred.
if ((result != PK_OK) && (result != PK_WARN)) {
MessageBox(g_hWndMain, GetZipErrorString(result), g_szAppName,
MB_ICONERROR | MB_OK);
}
// Clear our global edit box handle as we are done with it.
g_hWndEdit = NULL;
// Return FALSE to prevent edit box from gaining focus and showing highlight.
return FALSE;
case WM_COMMAND:
if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL)) {
EndDialog(hDlg, LOWORD(wParam));
}
return FALSE;
}
return FALSE;
}
//******************************************************************************
//***** About Dialog Functions
//******************************************************************************
BOOL CALLBACK DlgProcAbout(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WM_INITDIALOG:
#ifdef _WIN32_WCE
// Add "Ok" button to caption bar.
SetWindowLong(hDlg, GWL_EXSTYLE, WS_EX_CAPTIONOKBTN |
GetWindowLong(hDlg, GWL_EXSTYLE));
#endif
// Fill in a few static members.
// (For VER_FULLVERSION_STR and VER_COMMENT_STR, the TEXT() macro is
// not applicable, because they are defined as a set of concatenated
// string constants. These strings need to be converted to UNICODE
// at runtime, sigh.)
TCHAR szBuffer[128];
SetDlgItemText(hDlg, IDC_PRODUCT, TEXT(VER_PRODUCT_STR));
#ifdef UNICODE
_stprintf(szBuffer, TEXT("Freeware Version %S"), VER_FULLVERSION_STR);
#else
_stprintf(szBuffer, TEXT("Freeware Version %s"), VER_FULLVERSION_STR);
#endif
SetDlgItemText(hDlg, IDC_VERSION, szBuffer);
_stprintf(szBuffer, TEXT("Developed by %s"), TEXT(VER_DEVELOPER_STR));
SetDlgItemText(hDlg, IDC_DEVELOPER, szBuffer);
SetDlgItemText(hDlg, IDC_COPYRIGHT, TEXT(VER_COPYRIGHT_STR));
#ifdef UNICODE
( run in 0.646 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )