944 lines
26 KiB
C
944 lines
26 KiB
C
/***************************************************************************
|
|
*
|
|
* File Name: dsksheet.c
|
|
*
|
|
* Copyright (C) 1993-1996 Hewlett-Packard Company.
|
|
* All rights reserved.
|
|
*
|
|
* 11311 Chinden Blvd.
|
|
* Boise, Idaho 83714
|
|
*
|
|
* This is a part of the HP JetAdmin Printer Utility
|
|
*
|
|
* This source code is only intended as a supplement for support and
|
|
* localization of HP JetAdmin by 3rd party Operating System vendors.
|
|
* Modification of source code cannot be made without the express written
|
|
* consent of Hewlett-Packard.
|
|
*
|
|
*
|
|
* Description:
|
|
*
|
|
* Author: Name
|
|
*
|
|
*
|
|
* Modification history:
|
|
*
|
|
* date initials change description
|
|
*
|
|
* mm-dd-yy MJB
|
|
*
|
|
*
|
|
*
|
|
*
|
|
*
|
|
*
|
|
***************************************************************************/
|
|
|
|
#include <pch_c.h>
|
|
#include <macros.h>
|
|
|
|
#include <windowsx.h> // for ListBox_AddString and ItemData
|
|
|
|
|
|
#include ".\resource.h"
|
|
#include ".\dsksheet.h"
|
|
#include ".\traylevl.h"
|
|
#include ".\fontdtls.h"
|
|
#include <hptabs.h>
|
|
#include <nolocal.h>
|
|
#include "..\help\hpmstor.hh"
|
|
|
|
#ifndef WIN32
|
|
#include <string.h>
|
|
#endif
|
|
|
|
extern HINSTANCE hInstance;
|
|
|
|
HFONT hFontDialog;
|
|
|
|
//globals=======================================================
|
|
PeripheralFontInfo *lpPeriphFontInfo = NULL;
|
|
HWND hDisk = NULL;
|
|
HPERIPHERAL hPeripheral = NULL;
|
|
HCOMPONENT hComponent = NULL; // handle to disk
|
|
DWORD oldWriteProtect = WP_READ;
|
|
BOOL bSheetInitialized = FALSE;
|
|
BOOL bDiskInitialized = FALSE;
|
|
static long keywordIDListDisk[] =
|
|
{IDC_TIP_GROUP, IDH_RC_tips,
|
|
IDC_TIP_TEXT, IDH_RC_tips,
|
|
IDC_TIP_ICON, IDH_RC_tips,
|
|
IDC_DISK_DETAILS, IDH_RC_disk_details,
|
|
IDC_FS_INITIALIZED, IDH_RC_disk_initialized,
|
|
IDC_INITIALIZE, IDH_RC_disk_initialize_button,
|
|
IDC_WRITE_PROTECT, IDH_RC_disk_write_protect,
|
|
IDC_FREE_TITLE, IDH_RC_disk_free_space,
|
|
IDC_FREE_SPACE, IDH_RC_disk_free_space,
|
|
IDC_TOTAL_TITLE, IDH_RC_disk_size,
|
|
IDC_TOTAL_SIZE, IDH_RC_disk_size,
|
|
IDC_FONTHEADER, IDH_RC_fonts_list,
|
|
IDC_FONTLIST, IDH_RC_fonts_list,
|
|
IDC_FONT_DETAILS, IDH_RC_fonts_details_button,
|
|
IDC_FONT_DELETE, IDH_RC_fonts_delete_button,
|
|
0, 0};
|
|
|
|
//...................................................................
|
|
LRESULT OnContextHelpDisk(WPARAM wParam, LPARAM lParam)
|
|
{
|
|
#ifdef WIN32
|
|
WinHelp((HWND)wParam, MSTOR_HELP_FILE, HELP_CONTEXTMENU,
|
|
(DWORD)(LPSTR)keywordIDListDisk);
|
|
#endif
|
|
return(1);
|
|
}
|
|
|
|
//...................................................................
|
|
LRESULT OnF1HelpDisk(WPARAM wParam, LPARAM lParam)
|
|
{
|
|
#ifdef WIN32
|
|
WinHelp((HWND)((LPHELPINFO)lParam)->hItemHandle, MSTOR_HELP_FILE, HELP_WM_HELP,
|
|
(DWORD)(LPSTR)keywordIDListDisk);
|
|
#endif
|
|
return(1);
|
|
}
|
|
|
|
|
|
|
|
|
|
void GetFontListAndDisplay(HWND hwnd)
|
|
{
|
|
PeripheralFontList2 *lpFontList2;
|
|
DWORD dBufSize, dwResult;
|
|
int i;
|
|
int nIndex;
|
|
HWND fontListBox;
|
|
HCURSOR hOldCursor;
|
|
DWORD segNum;
|
|
BOOL bFoundOne;
|
|
|
|
|
|
if (fontListBox = GetDlgItem(hwnd, IDC_FONTLIST))
|
|
{
|
|
ListBox_ResetContent(fontListBox);
|
|
}
|
|
|
|
lpFontList2 = (PeripheralFontList2 *)
|
|
HP_GLOBAL_ALLOC_DLL(sizeof(PeripheralFontList2));
|
|
if(lpFontList2 IS NULL)
|
|
return;
|
|
|
|
|
|
/* turn hourglass on */
|
|
hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
|
|
|
|
segNum = 0;
|
|
bFoundOne = FALSE;
|
|
while(TRUE)
|
|
{
|
|
dBufSize = sizeof(PeripheralFontList2);
|
|
|
|
lpFontList2->numFonts = 0;
|
|
lpFontList2->dwSegNum = segNum;
|
|
|
|
|
|
dwResult = PALGetObject(hPeripheral,
|
|
OT_PERIPHERAL_FONT_LIST2,
|
|
0,
|
|
lpFontList2,
|
|
&dBufSize);
|
|
|
|
if(dwResult ISNT RC_SUCCESS)
|
|
break;
|
|
|
|
if(lpFontList2->numFonts IS 0)
|
|
break;
|
|
|
|
|
|
|
|
for (i = 0; i < (signed long) lpFontList2->numFonts; i++) {
|
|
// add the font name to the font list box
|
|
nIndex = ListBox_AddString(fontListBox,
|
|
lpFontList2->fonts[i].globalName);
|
|
|
|
// associate the font handle with this font name
|
|
ListBox_SetItemData(fontListBox, nIndex,
|
|
(DWORD)lpFontList2->fonts[i].fontHandle);
|
|
|
|
bFoundOne = TRUE;
|
|
} // for...
|
|
|
|
|
|
|
|
if(lpFontList2->numFonts ISNT MAX_FONTLIST2_CNT)
|
|
break;
|
|
|
|
++segNum;
|
|
}
|
|
|
|
if(bFoundOne)
|
|
{
|
|
ListBox_SetTopIndex(fontListBox, 0);
|
|
ListBox_SetCurSel(fontListBox, 0);
|
|
}
|
|
else {
|
|
// no fonts - disable the details and delete buttons
|
|
EnableWindow(GetDlgItem(hDisk, IDC_FONT_DELETE), FALSE);
|
|
EnableWindow(GetDlgItem(hDisk, IDC_FONT_DETAILS), FALSE);
|
|
}
|
|
|
|
/* restore the cursor */
|
|
SetCursor(hOldCursor);
|
|
|
|
/* free the used memory */
|
|
HP_GLOBAL_FREE(lpFontList2);
|
|
|
|
} // GetFontListAndDisplay
|
|
|
|
|
|
|
|
|
|
typedef enum RetryStati {RetrySuccess, RetryNotFound, RetryFailure};
|
|
/*
|
|
A font is currently selected at index.
|
|
Get the string associated with that index.
|
|
Enumerate the fonts again.
|
|
Find the same string in the newly enumerated list, if it exists.
|
|
If all goes well return the new index and font handle.
|
|
If the font disappeared return RetryNotFound and
|
|
the index and font handle are garbage.
|
|
If something else goes wrong, return RetryFailure and
|
|
the index and font handle are garbage.
|
|
|
|
*/
|
|
enum RetryStati RetryAndSelectString(HWND hwnd,
|
|
int *lpIndex,
|
|
HCOMPONENT *lphFontHandle)
|
|
{
|
|
LPTSTR lpszSelectedString;
|
|
int length;
|
|
|
|
// Save away the name of the selected
|
|
// font so we can find it in the new list.
|
|
// It is possible for the name to be good
|
|
// but the handle to be bad.
|
|
|
|
if ((length = ListBox_GetTextLen(hwnd, *lpIndex)) IS LB_ERR)
|
|
// length contains the length of the string in characters
|
|
{
|
|
return RetryFailure;
|
|
}
|
|
|
|
lpszSelectedString = (LPTSTR) HP_GLOBAL_ALLOC_DLL((length + 1) * sizeof(TCHAR));
|
|
if (lpszSelectedString IS NULL)
|
|
{
|
|
return RetryFailure;
|
|
}
|
|
|
|
if (LB_ERR IS ListBox_GetText(hwnd, *lpIndex, lpszSelectedString))
|
|
{
|
|
HP_GLOBAL_FREE(lpszSelectedString);
|
|
return RetryFailure;
|
|
}
|
|
|
|
// Enumerate again
|
|
|
|
GetFontListAndDisplay(hDisk);
|
|
|
|
// Try to find the previously selected string
|
|
// in the new enumeration.
|
|
|
|
*lpIndex = ListBox_FindStringExact(hwnd, 0, lpszSelectedString);
|
|
if (*lpIndex IS LB_ERR)
|
|
{
|
|
HP_GLOBAL_FREE(lpszSelectedString);
|
|
return RetryNotFound;
|
|
} // *lpIndex = ListBox_FindStringExact
|
|
|
|
// Select the new item
|
|
// and get the new handle for the selected item.
|
|
|
|
ListBox_SetCurSel(hwnd, *lpIndex);
|
|
if (!(*lphFontHandle =
|
|
(HCOMPONENT)ListBox_GetItemData(hwnd, *lpIndex)))
|
|
{
|
|
HP_GLOBAL_FREE(lpszSelectedString);
|
|
return RetryFailure;
|
|
}
|
|
|
|
HP_GLOBAL_FREE(lpszSelectedString);
|
|
return RetrySuccess;
|
|
|
|
} // RetryAndSelectString
|
|
|
|
|
|
|
|
|
|
/*
|
|
index is set where the original font was in the listbox.
|
|
Select the item at that index unless it is out of bounds
|
|
then select the last one.
|
|
If none exist in the new listbox then select nothing
|
|
and gray out the Details and Delete buttons.
|
|
*/
|
|
void SelectNextBest(HWND hwnd, int index)
|
|
{
|
|
int count;
|
|
|
|
count = ListBox_GetCount(hwnd);
|
|
if (count <= 0)
|
|
{
|
|
EnableWindow(GetDlgItem(hDisk, IDC_FONT_DETAILS), FALSE);
|
|
EnableWindow(GetDlgItem(hDisk, IDC_FONT_DELETE), FALSE);
|
|
}
|
|
else
|
|
{
|
|
if (index >= count)
|
|
{
|
|
index = count - 1;
|
|
}
|
|
ListBox_SetCurSel(hwnd, index);
|
|
} // count > 0
|
|
} // SelectNextBest
|
|
|
|
|
|
|
|
|
|
void DoFontDetails(HWND hwnd,
|
|
TCHAR *str, size_t SizeofStr,
|
|
TCHAR *title, size_t SizeofTitle)
|
|
{
|
|
int index;
|
|
HWND hwndChild;
|
|
HCOMPONENT hFontHandle;
|
|
DWORD dwSize, dwResult;
|
|
HCURSOR hOldCursor;
|
|
#ifndef WIN32
|
|
FARPROC lpfnDlgProc;
|
|
#endif
|
|
|
|
if (!(hwndChild = GetDlgItem(hwnd, IDC_FONTLIST)))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if ((index = ListBox_GetCurSel(hwndChild)) == LB_ERR)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (!(hFontHandle =
|
|
(HCOMPONENT)ListBox_GetItemData(hwndChild, index)))
|
|
{
|
|
return;
|
|
}
|
|
|
|
lpPeriphFontInfo = (PeripheralFontInfo *)
|
|
HP_GLOBAL_ALLOC_DLL(sizeof(PeripheralFontInfo));
|
|
if (lpPeriphFontInfo IS NULL)
|
|
{
|
|
return;
|
|
}
|
|
dwSize = sizeof(PeripheralFontInfo);
|
|
|
|
// From here on out we must dispose of lpPeriphFontInfo.
|
|
|
|
// Give 'em the hour glass
|
|
hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
|
|
dwResult = PALGetComponentObject(hPeripheral,
|
|
hFontHandle,
|
|
OT_PERIPHERAL_FONT_INFO, 0,
|
|
lpPeriphFontInfo,
|
|
&dwSize);
|
|
// Back to previous cursor
|
|
SetCursor(hOldCursor);
|
|
|
|
if (dwResult IS RC_BAD_HANDLE)
|
|
{
|
|
enum RetryStati RetryStatus;
|
|
int oldIndex = index;
|
|
|
|
// Bad handle...enumerate again.
|
|
|
|
RetryStatus = RetryAndSelectString(hwndChild,
|
|
&index,
|
|
&hFontHandle);
|
|
|
|
if (RetryStatus IS RetrySuccess)
|
|
{
|
|
|
|
// Give 'em the hour glass
|
|
hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
|
|
dwResult = PALGetComponentObject(hPeripheral,
|
|
hFontHandle,
|
|
OT_PERIPHERAL_FONT_INFO,
|
|
0,
|
|
lpPeriphFontInfo,
|
|
&dwSize);
|
|
// Back to previous cursor
|
|
SetCursor(hOldCursor);
|
|
}
|
|
else // not found or some other failure
|
|
{
|
|
index = oldIndex;
|
|
|
|
// if the listbox is now empty, disable both buttons
|
|
// index is set where the selected font was and
|
|
// WARNING WARNING it may be out of bounds!
|
|
|
|
SelectNextBest(hwndChild, index);
|
|
dwResult = RC_FAILURE;
|
|
// Don't put up the details sheet.
|
|
|
|
} // not found or some other failure
|
|
} // if (dwResult IS RC_BAD_HANDLE)
|
|
|
|
if (dwResult ISNT RC_SUCCESS)
|
|
{
|
|
HP_GLOBAL_FREE(lpPeriphFontInfo);
|
|
lpPeriphFontInfo = NULL;
|
|
LoadString(hInstance, IDS_FONT_INFO_FAILED, str, SizeofStr);
|
|
LoadString(hInstance, IDS_PRTR_TITLE, title, SizeofTitle);
|
|
MessageBox(GetParent(hDisk), str, title, MB_OK);
|
|
return;
|
|
}
|
|
|
|
#ifdef WIN32
|
|
DialogBox(hInstance, MAKEINTRESOURCE(IDD_FONT_DETAILS), hwnd,
|
|
(DLGPROC)FontDetailsProc);
|
|
#else
|
|
hFontDialog = GetWindowFont(GetFirstChild(hwnd));
|
|
lpfnDlgProc = MakeProcInstance((FARPROC)FontDetailsProc, hInstance);
|
|
EnableWindow(GetParent(hwnd), FALSE);
|
|
DialogBox(hInstance, MAKEINTRESOURCE(IDD_FONT_DETAILS), hwnd,
|
|
(DLGPROC)lpfnDlgProc);
|
|
EnableWindow(GetParent(hwnd), TRUE);
|
|
FreeProcInstance(lpfnDlgProc);
|
|
SetActiveWindow(GetParent(hwnd));
|
|
#endif
|
|
HP_GLOBAL_FREE(lpPeriphFontInfo);
|
|
lpPeriphFontInfo = NULL;
|
|
} // DoFontDetails
|
|
|
|
|
|
|
|
|
|
void DoFontDelete(HWND hwnd,
|
|
TCHAR *str, size_t SizeofStr,
|
|
TCHAR *title, size_t SizeofTitle)
|
|
{
|
|
int index;
|
|
HWND hwndChild;
|
|
HCOMPONENT hFontHandle;
|
|
PeripheralDeleteFont periphDeleteFont;
|
|
DWORD dwSize = sizeof(periphDeleteFont);
|
|
DWORD dwResult;
|
|
HCURSOR hOldCursor;
|
|
|
|
if (!(hwndChild = GetDlgItem(hwnd, IDC_FONTLIST)))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if ((index = ListBox_GetCurSel(hwndChild)) == LB_ERR)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (!(hFontHandle = (HCOMPONENT)ListBox_GetItemData(hwndChild, index)))
|
|
{
|
|
return;
|
|
}
|
|
|
|
LoadString(hInstance, IDS_DELETE_FONT, str, SizeofStr);
|
|
LoadString(hInstance, IDS_PRTR_TITLE, title, SizeofTitle);
|
|
if (MessageBox(GetParent(hDisk), str, title, MB_YESNO | MB_ICONQUESTION) != IDYES)
|
|
{
|
|
return;
|
|
}
|
|
|
|
// clicked yes for "really sure"
|
|
|
|
|
|
periphDeleteFont.fontHandle = hFontHandle;
|
|
_tcscpy(periphDeleteFont.username, TEXT(""));
|
|
|
|
// Give 'em the hour glass
|
|
hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
|
|
dwResult = PALSetObject(hPeripheral,
|
|
OT_PERIPHERAL_DELETE_FONT,
|
|
0,
|
|
&periphDeleteFont,
|
|
&dwSize);
|
|
// Back to previous cursor
|
|
SetCursor(hOldCursor);
|
|
if (dwResult IS RC_SUCCESS)
|
|
{
|
|
ListBox_DeleteString(hwndChild, index);
|
|
}
|
|
else if (dwResult IS RC_BAD_HANDLE)
|
|
{
|
|
enum RetryStati RetryStatus;
|
|
int oldIndex = index;
|
|
|
|
// Bad handle...enumerate again
|
|
|
|
RetryStatus = RetryAndSelectString(hwndChild,
|
|
&index,
|
|
&hFontHandle);
|
|
|
|
if (RetryStatus IS RetryNotFound)
|
|
{
|
|
// It got deleted for us
|
|
// by someone else.
|
|
|
|
dwResult = RC_SUCCESS;
|
|
index = oldIndex;
|
|
}
|
|
else if (RetryStatus IS RetrySuccess)
|
|
{
|
|
dwSize = sizeof(periphDeleteFont);
|
|
periphDeleteFont.fontHandle = hFontHandle;
|
|
// Give 'em the hour glass
|
|
hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
|
|
dwResult = PALSetObject(hPeripheral,
|
|
OT_PERIPHERAL_DELETE_FONT,
|
|
0,
|
|
&periphDeleteFont,
|
|
&dwSize);
|
|
// Back to previous cursor
|
|
SetCursor(hOldCursor);
|
|
if (dwResult IS RC_SUCCESS)
|
|
{
|
|
ListBox_DeleteString(hwndChild, index);
|
|
}
|
|
} // Retry IS RetrySuccess
|
|
else // failure
|
|
{
|
|
index = oldIndex;
|
|
dwResult = RC_FAILURE;
|
|
}
|
|
} // (dwResult IS RC_BAD_HANDLE)
|
|
|
|
/*
|
|
The font has been deleted from the listbox.
|
|
|
|
index is in the ballpark of where the deleted font was
|
|
and WARNING WARNING: it may be out of bounds!
|
|
|
|
dwResult is now set to RC_SUCCESS if the font no longer exists.
|
|
dwResult is now set to something else if the font deletion failed.
|
|
*/
|
|
|
|
if ( dwResult != RC_SUCCESS)
|
|
{
|
|
LoadString(hInstance, IDS_DELETE_FONT_FAILED, str, SizeofStr);
|
|
LoadString(hInstance, IDS_PRTR_TITLE, title, SizeofTitle);
|
|
MessageBox(GetParent(hDisk), str, title, MB_OK);
|
|
}
|
|
|
|
// if the listbox is now empty, disable both buttons
|
|
|
|
SelectNextBest(hwndChild, index);
|
|
} // DoFontDelete
|
|
|
|
|
|
|
|
|
|
//==============================================================
|
|
// Disk Sheet Dialog Proc
|
|
DLL_EXPORT(BOOL) APIENTRY DiskSheetProc(HWND hwnd, UINT msg, UINT wParam, LONG lParam)
|
|
{
|
|
|
|
BOOL *bChanged = (BOOL *)lParam,
|
|
bProcessed = FALSE;
|
|
|
|
switch (msg)
|
|
{
|
|
case WM_HELP:
|
|
return((BOOL)OnF1HelpDisk(wParam, lParam));
|
|
break;
|
|
|
|
case WM_CONTEXTMENU:
|
|
return((BOOL)OnContextHelpDisk(wParam, lParam));
|
|
break;
|
|
|
|
#ifdef WIN32
|
|
case WM_NOTIFY:
|
|
{
|
|
switch(((NMHDR FAR *)lParam)->code)
|
|
{
|
|
case PSN_HELP:
|
|
WinHelp(hwnd, MSTOR_HELP_FILE, HELP_CONTEXT, IDH_PP_disk);
|
|
break;
|
|
|
|
case PSN_SETACTIVE:
|
|
if ( !bSheetInitialized )
|
|
OnInitDiskDialog();
|
|
else
|
|
GetFontListAndDisplay(hDisk);
|
|
bSheetInitialized = TRUE;
|
|
bProcessed = TRUE;
|
|
SetWindowLong(hwnd, DWL_MSGRESULT, FALSE);
|
|
break;
|
|
|
|
case PSN_KILLACTIVE:
|
|
bProcessed = TRUE;
|
|
SetWindowLong(hwnd, DWL_MSGRESULT, FALSE);
|
|
break;
|
|
|
|
case PSN_APPLY:
|
|
bProcessed = TRUE;
|
|
SaveDiskValues();
|
|
SetWindowLong(hwnd, DWL_MSGRESULT, PSNRET_NOERROR);
|
|
break;
|
|
|
|
case PSN_RESET:
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
#else
|
|
|
|
// TabSheet Specific Messages
|
|
case TSN_ACTIVE:
|
|
if ( !bSheetInitialized )
|
|
OnInitDiskDialog();
|
|
else
|
|
GetFontListAndDisplay(hDisk);
|
|
bSheetInitialized = TRUE;
|
|
return(TRUE);
|
|
break;
|
|
|
|
case TSN_INACTIVE:
|
|
case TSN_OK:
|
|
case TSN_APPLY_NOW:
|
|
*bChanged = TRUE;
|
|
SaveDiskValues(); // added by gfs
|
|
return(TRUE);
|
|
break;
|
|
|
|
case TSN_CANCEL:
|
|
return(TRUE);
|
|
break;
|
|
|
|
case TSN_HELP:
|
|
WinHelp(hwnd, MSTOR_HELP_FILE, HELP_CONTEXT, IDH_PP_disk);
|
|
break;
|
|
#endif // WIN32
|
|
|
|
case WM_COMMAND:
|
|
HANDLE_WM_COMMAND(hwnd, wParam, lParam, Cls_OnDiskCommand);
|
|
break;
|
|
|
|
case WM_INITDIALOG:
|
|
bSheetInitialized = FALSE;
|
|
bProcessed = (BOOL)HANDLE_WM_INITDIALOG(hwnd, wParam, lParam, Cls_OnDiskInitDialog);
|
|
break;
|
|
|
|
case WM_DESTROY:
|
|
break;
|
|
}
|
|
return (bProcessed);
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------
|
|
// Message cracking functions
|
|
//.............................................................
|
|
void Cls_OnDiskCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
|
|
// handles WM_COMMAND
|
|
{
|
|
DWORD bufSize,
|
|
dwResult,
|
|
dwCapacity,
|
|
// dwCapBefore,
|
|
dwFree,
|
|
dwPercent;
|
|
int ccode;
|
|
TCHAR str[256];
|
|
TCHAR title[128];
|
|
TCHAR buffer[512];
|
|
PeripheralDisk periphDisk;
|
|
|
|
switch(codeNotify)
|
|
{
|
|
case LBN_DBLCLK:
|
|
switch (id)
|
|
{
|
|
case IDC_FONTLIST:
|
|
FORWARD_WM_COMMAND(hwnd, IDC_FONT_DETAILS, GetDlgItem(hwnd, IDC_FONT_DETAILS), BN_CLICKED, SendMessage);
|
|
break;
|
|
}
|
|
break;
|
|
|
|
case BN_CLICKED:
|
|
switch (id)
|
|
{
|
|
case IDC_INITIALIZE:
|
|
if ( oldWriteProtect IS WP_READ )
|
|
{
|
|
LoadString(hInstance, IDS_INIT_WRITE_PROTECT, str, SIZEOF_IN_CHAR(str));
|
|
LoadString(hInstance, IDS_PRTR_TITLE, title, SIZEOF_IN_CHAR(title));
|
|
ccode = MessageBox(GetParent(hDisk), str, title, MB_OK | MB_ICONEXCLAMATION);
|
|
ccode = IDNO;
|
|
}
|
|
else if ( bDiskInitialized )
|
|
{
|
|
LoadString(hInstance, IDS_INIT_WARNING, str, SIZEOF_IN_CHAR(str));
|
|
LoadString(hInstance, IDS_PRTR_TITLE, title, SIZEOF_IN_CHAR(title));
|
|
ccode = MessageBox(GetParent(hDisk), str, title, MB_YESNO | MB_ICONQUESTION);
|
|
}
|
|
else
|
|
{
|
|
LoadString(hInstance, IDS_INIT_WARNING2, str, SIZEOF_IN_CHAR(str));
|
|
LoadString(hInstance, IDS_PRTR_TITLE, title, SIZEOF_IN_CHAR(title));
|
|
ccode = MessageBox(GetParent(hDisk), str, title, MB_YESNO | MB_ICONQUESTION);
|
|
}
|
|
if ( ccode IS IDYES )
|
|
{ // initialize disk
|
|
HWND hwndChild;
|
|
periphDisk.flags = 0;
|
|
periphDisk.flags |= SET_INITIALIZE;
|
|
bufSize = sizeof(PeripheralDisk);
|
|
dwResult = PALSetComponentObject(hPeripheral, hComponent,
|
|
OT_PERIPHERAL_DISK, 0, &periphDisk, &bufSize);
|
|
if (dwResult IS RC_SUCCESS) {
|
|
|
|
LoadString(hInstance, IDS_DISK_INIT_SUCCESS, str, SIZEOF_IN_CHAR(str));
|
|
LoadString(hInstance, IDS_PRTR_TITLE, title, SIZEOF_IN_CHAR(title));
|
|
ccode = MessageBox(GetParent(hDisk), str, title, MB_OK);
|
|
|
|
if (hwndChild = GetDlgItem(hwnd, IDC_FONTLIST))
|
|
{
|
|
ListBox_ResetContent(hwndChild);
|
|
}
|
|
EnableWindow(GetDlgItem(hDisk, IDC_FONT_DETAILS), FALSE);
|
|
EnableWindow(GetDlgItem(hDisk, IDC_FONT_DELETE), FALSE);
|
|
|
|
bufSize = sizeof(PeripheralDisk);
|
|
memset(&periphDisk, 0, (size_t)bufSize);
|
|
dwResult = PALGetComponentObject(hPeripheral, hComponent,
|
|
OT_PERIPHERAL_DISK, 0, &periphDisk, &bufSize);
|
|
if (dwResult IS RC_SUCCESS) {
|
|
dwCapacity = (DWORD)(periphDisk.capacity / 1024L);
|
|
dwFree = (DWORD)(periphDisk.freeSpace / 1024L);
|
|
// the initialize may have been queued and the reported
|
|
// free space may be the old (pre initialize) size. If
|
|
// so, assume that the file system takes 157 K bytes.
|
|
if (dwFree < dwCapacity - 157)
|
|
dwFree = dwCapacity - 157;
|
|
dwPercent = dwFree * 100 / dwCapacity;
|
|
LoadString(hInstance, IDS_TOTAL_SIZE, str, SIZEOF_IN_CHAR(str));
|
|
wsprintf(buffer, str, dwCapacity);
|
|
SetDlgItemText(hDisk, IDC_TOTAL_SIZE, buffer);
|
|
LoadString(hInstance, IDS_FREE_SPACE, str, SIZEOF_IN_CHAR(str));
|
|
wsprintf(buffer, str, dwFree, dwPercent);
|
|
SetDlgItemText(hDisk, IDC_FREE_SPACE, buffer);
|
|
SetWindowWord(GetDlgItem(hDisk, IDC_FREE_SPACE), GWW_TRAYLEVEL, (WORD)dwPercent);
|
|
CheckDlgButton(hDisk, IDC_FS_INITIALIZED, TRUE);
|
|
// Set the init check box so that users cannot check/uncheck it
|
|
EnableWindow(GetDlgItem(hDisk, IDC_FS_INITIALIZED), FALSE);
|
|
bDiskInitialized = TRUE;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
// If Write Protected was checked and the disk is not write protected
|
|
// Disable or enable the initialize button
|
|
// If the disk was write protected leave button disabled until done.
|
|
case IDC_WRITE_PROTECT:
|
|
if ( oldWriteProtect == WP_READ_WRITE )
|
|
{
|
|
if ( IsDlgButtonChecked(hDisk, IDC_WRITE_PROTECT) )
|
|
EnableWindow(GetDlgItem(hDisk, IDC_INITIALIZE), FALSE);
|
|
else
|
|
EnableWindow(GetDlgItem(hDisk, IDC_INITIALIZE), TRUE);
|
|
}
|
|
break;
|
|
|
|
|
|
case IDC_FONT_DETAILS:
|
|
{
|
|
DoFontDetails(hwnd,
|
|
str, sizeof(str),
|
|
title, sizeof(title));
|
|
break;
|
|
} // case IDC_FONT_DETAILS:
|
|
|
|
case IDC_FONT_DELETE:
|
|
{
|
|
DoFontDelete(hwnd,
|
|
str, sizeof(str),
|
|
title, sizeof(title));
|
|
|
|
bufSize = sizeof(PeripheralDisk);
|
|
memset(&periphDisk, 0, (size_t)bufSize);
|
|
dwResult = PALGetComponentObject(hPeripheral, hComponent, OT_PERIPHERAL_DISK, 0, &periphDisk, &bufSize);
|
|
if (dwResult IS RC_SUCCESS) {
|
|
dwCapacity = (DWORD)(periphDisk.capacity / 1024L);
|
|
dwFree = (DWORD)(periphDisk.freeSpace / 1024L);
|
|
dwPercent = dwFree * 100 / dwCapacity;
|
|
LoadString(hInstance, IDS_FREE_SPACE, str, SIZEOF_IN_CHAR(str));
|
|
wsprintf(buffer, str, dwFree, dwPercent);
|
|
SetDlgItemText(hDisk, IDC_FREE_SPACE, buffer);
|
|
SetWindowWord(GetDlgItem(hDisk, IDC_FREE_SPACE), GWW_TRAYLEVEL, (WORD)dwPercent);
|
|
}
|
|
|
|
break;
|
|
} // case IDC_FONT_DELETE:
|
|
} // case BN_CLICKED: switch (id)
|
|
break;
|
|
} // switch(codeNotify)
|
|
}
|
|
|
|
//.............................................................
|
|
BOOL Cls_OnDiskInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
|
|
// handles WM_INITDIALOG
|
|
{
|
|
LPPROPSHEETPAGE psp = (LPPROPSHEETPAGE)GetWindowLong(hwnd, DWL_USER);
|
|
|
|
SetWindowLong(hwnd, DWL_USER, lParam);
|
|
psp = (LPPROPSHEETPAGE)lParam;
|
|
hPeripheral = (HPERIPHERAL)psp->lParam;
|
|
hDisk = hwnd;
|
|
return TRUE;
|
|
}
|
|
|
|
//...................................................................
|
|
BOOL OnInitDiskDialog(void)
|
|
{
|
|
DWORD dWord,
|
|
dwResult,
|
|
dwCapacity,
|
|
dwFree,
|
|
dwPercent;
|
|
int i;
|
|
PeripheralCaps periphCaps;
|
|
PeripheralMassStorage periphMS;
|
|
PeripheralDisk periphDisk;
|
|
TCHAR str[256],
|
|
buffer[512];
|
|
|
|
// Description
|
|
LoadString(hInstance, IDS_DISK_DESC1, buffer, SIZEOF_IN_CHAR(buffer));
|
|
_tcscat(buffer, TEXT(" "));
|
|
LoadString(hInstance, IDS_DISK_DESC2, &(buffer[_tcslen(buffer)]),
|
|
SIZEOF_IN_CHAR(buffer) - _tcslen(buffer));
|
|
SetDlgItemText(hDisk, IDC_TIP_TEXT, buffer);
|
|
|
|
dWord = sizeof(periphCaps);
|
|
dwResult = PALGetObject(hPeripheral, OT_PERIPHERAL_CAPABILITIES, 0, &periphCaps, &dWord);
|
|
if ( dwResult IS RC_SUCCESS )
|
|
{
|
|
if ( ( periphCaps.flags & CAPS_DISK ) AND
|
|
( periphCaps.bDisk ) ) {
|
|
// we have a disk, get mass storage object and use disk handle
|
|
dWord = sizeof(PeripheralMassStorage);
|
|
dwResult = PALGetObject(hPeripheral, OT_PERIPHERAL_MASS_STORAGE, 0, &periphMS, &dWord);
|
|
if ((dwResult IS RC_SUCCESS) AND (periphMS.MScount > 0)) {
|
|
// garth: get the disk handle; for eclipse there will only be one
|
|
// disk. Later, there will be more, so will need to make some
|
|
// changes for elkhorn
|
|
for (i = 0; i < (long int) periphMS.MScount; i++) {
|
|
if (periphMS.installed[i].MStype IS MS_DISK) {
|
|
hComponent = periphMS.installed[i].MShandle;
|
|
break;
|
|
}
|
|
}
|
|
dWord = sizeof(PeripheralDisk);
|
|
dwCapacity = 0;
|
|
dwFree = 0;
|
|
dwPercent = 0;
|
|
dwResult = PALGetComponentObject(hPeripheral, hComponent, OT_PERIPHERAL_DISK, 0, &periphDisk, &dWord);
|
|
if (dwResult IS RC_SUCCESS) {
|
|
if (periphDisk.bInitialized IS TRUE) {
|
|
dwCapacity = (DWORD)(periphDisk.capacity / 1024L);
|
|
dwFree = (DWORD)(periphDisk.freeSpace / 1024L); //use 1024 to mean KBytes on a disk or RAM
|
|
dwPercent = dwFree * 100 / dwCapacity;
|
|
}
|
|
}
|
|
LoadString(hInstance, IDS_TOTAL_SIZE, str, SIZEOF_IN_CHAR(str));
|
|
wsprintf(buffer, str, dwCapacity);
|
|
SetDlgItemText(hDisk, IDC_TOTAL_SIZE, buffer);
|
|
LoadString(hInstance, IDS_FREE_SPACE, str, SIZEOF_IN_CHAR(str));
|
|
wsprintf(buffer, str, dwFree, dwPercent);
|
|
SetDlgItemText(hDisk, IDC_FREE_SPACE, buffer);
|
|
SetWindowWord(GetDlgItem(hDisk, IDC_FREE_SPACE), GWW_TRAYLEVEL, (WORD)dwPercent);
|
|
CheckDlgButton(hDisk, IDC_WRITE_PROTECT, periphDisk.writeProtectStatus == WP_READ);
|
|
CheckDlgButton(hDisk, IDC_FS_INITIALIZED, (BOOL)periphDisk.bInitialized);
|
|
// Set the init check box so that users cannot check/uncheck it
|
|
EnableWindow(GetDlgItem(hDisk, IDC_FS_INITIALIZED), FALSE);
|
|
oldWriteProtect = periphDisk.writeProtectStatus;
|
|
bDiskInitialized = (BOOL)periphDisk.bInitialized;
|
|
|
|
// add all of the fonts to the font list box if it has
|
|
// been initialized
|
|
|
|
if (periphDisk.bInitialized IS TRUE) {
|
|
GetFontListAndDisplay(hDisk);
|
|
}
|
|
else {
|
|
// no fonts - disable the details and delete buttons
|
|
EnableWindow(GetDlgItem(hDisk, IDC_FONT_DELETE), FALSE);
|
|
EnableWindow(GetDlgItem(hDisk, IDC_FONT_DETAILS), FALSE);
|
|
}
|
|
//----------------get fonts end
|
|
|
|
// Depending on current write protect status, enable/disable buttons
|
|
// always allow the admin to modify write protect status
|
|
EnableWindow(GetDlgItem(hDisk, IDC_WRITE_PROTECT), TRUE);
|
|
if ( periphDisk.writeProtectStatus IS WP_READ) {
|
|
EnableWindow(GetDlgItem(hDisk, IDC_FONT_DELETE), FALSE);
|
|
EnableWindow(GetDlgItem(hDisk, IDC_INITIALIZE), FALSE);
|
|
}
|
|
|
|
// Currently the disk tab only comes up if you have
|
|
// supervisor access, so enable all buttons, etc
|
|
// If this is going to change, figure out who gets to delete
|
|
// fonts (admin and user -- how to identify which user you are?
|
|
|
|
//if ((dWord = PALModifyAccess(hPeripheral) & SUPERVISOR_ACCESS) {
|
|
// EnableWindow(GetDlgItem(hDisk, IDC_WRITE_PROTECT), TRUE);
|
|
// EnableWindow(GetDlgItem(hDisk, IDC_INITIALIZE), TRUE);
|
|
// EnableWindow(GetDlgItem(hDisk, IDC_FONT_DELETE), TRUE);
|
|
//}
|
|
//else {
|
|
// EnableWindow(GetDlgItem(hDisk, IDC_WRITE_PROTECT), FALSE);
|
|
// EnableWindow(GetDlgItem(hDisk, IDC_INITIALIZE), FALSE);
|
|
// EnableWindow(GetDlgItem(hDisk, IDC_FONT_DELETE), FALSE);
|
|
//}
|
|
} // if MScount > 0
|
|
|
|
} // if periphCaps.flags
|
|
}
|
|
return(TRUE);
|
|
}
|
|
|
|
//...................................................................
|
|
void SaveDiskValues(void)
|
|
{
|
|
DWORD newWriteProtect,
|
|
dWord,
|
|
dwResult;
|
|
PeripheralDisk periphDisk;
|
|
|
|
if ( IsDlgButtonChecked(hDisk, IDC_WRITE_PROTECT) )
|
|
newWriteProtect = WP_READ;
|
|
else
|
|
newWriteProtect = WP_READ_WRITE;
|
|
if ( newWriteProtect ISNT oldWriteProtect ) {
|
|
periphDisk.flags = 0;
|
|
periphDisk.flags |= SET_PROTECT;
|
|
periphDisk.writeProtectStatus = newWriteProtect;
|
|
dWord = sizeof(PeripheralDisk);
|
|
dwResult = PALSetComponentObject(hPeripheral, hComponent,
|
|
OT_PERIPHERAL_DISK, 0, &periphDisk, &dWord);
|
|
}
|
|
}
|