Пример #1
0
BOOL GetIniPath( LPSTR lpIniFile )
/************************************************************************/
{
FNAME szFileName;
BOOL bRet;

#ifdef _MAC
	// The macintosh ALWAYS uses the "Root:System:Preferences:" path when
	// acessing preferences - ALWAYS.
	// Do not use path information in the INI filename.
	return TRUE;
#else

if ( GetProfileString( "Micrografx", PRIVATE_INI, "",
	szFileName, sizeof(FNAME) ) > 2 )
	{
	FixPath( szFileName );
	lstrcat( szFileName, lpIniFile );
	if ( bRet = FileExists( szFileName ) )
		goto Found;
	}

#ifdef CDBUILD
if ( GetWindowsDirectory( szFileName, sizeof(FNAME) ) > 2 )
	{
	FixPath( szFileName );
	lstrcat( szFileName, lpIniFile );
	if ( bRet = FileExists( szFileName ) )
		goto Found;
	}
#endif

lstrcpy( szFileName, Control.ProgHome );
lstrcat( szFileName, lpIniFile );
if ( !(bRet = FileExists( szFileName )) )
	Message( IDS_INI_NOEXIST, Lowercase(lpIniFile) );

Found:
lstrcpy( lpIniFile, szFileName );

#ifndef CDBUILD
if ( bRet && !FilePermission( lpIniFile, 2 /*WRITE*/ ) )
	Message( IDS_INI_NOWRITE, Lowercase(lpIniFile) );
#endif

// Set the network variable if the INI and EXE are not in the same place
lstrcpy( szFileName, lpIniFile );
stripfile( szFileName );
FixPath( szFileName );
Control.bNetworkInstall = !StringsEqual( Control.ProgHome, szFileName );
return( bRet );
#endif // #ifdef _MAC
}
Пример #2
0
BOOL GetFileLocation(
/************************************************************************/
WORD 	idFileType,
LPSTR 	lpPath)
{
FNAME szExtension, szFileName, szTemp;

if ( !LookupExtension( idFileType, szExtension ) )
	return( NO );

/* Find out where the user was last, so we can change over to that directory */
lstrcpy( szTemp, szExtension );
lstrcat( szTemp, "temp" );
GetDefaultString( szTemp, szExtension, szFileName, sizeof(FNAME) );
stripfile( szFileName );
FixPath( szFileName );
lstrcat( szFileName, szExtension );
lstrcpy( lpPath, szFileName );
return( YES );
}
Пример #3
0
BOOL SetFileLocation(
/************************************************************************/
WORD 	idFileType,
LPSTR 	lpPath)
{
FNAME szFileName, szExtension;

if ( !LookupExtension( idFileType, szExtension ) )
	return( NO );

/* Whatever disk and directory the user changed to, */
/* store it away so we come back to the same place next time */
lstrcpy( szFileName, lpPath );
stripfile( szFileName );
FixPath( szFileName );
lstrcat( szFileName, szExtension );
if ( Save.OKtoSavePath )
	PutDefaultString( szExtension, szFileName );
lstrcat( szExtension, "temp" );
PutDefaultString( szExtension, szFileName );
return( TRUE );
}
Пример #4
0
void SetFileName(
/***********************************************************************/
HWND	hDlg,
int		idCtl,
LPSTR	lpFileSpec,
LPSTR	lpSaveName,
BOOL	bSaving)
{
FNAME szName, szSpec, szExt;

if (bSaving && !fUntitled)
	{
	lstrcpy( szName, stripdir(lpSaveName) );
	stripext( szName );
	lstrcpy( szExt, extension(lpFileSpec) );
	lstrcpy( szSpec, lpFileSpec );
	stripfile( szSpec );
	FixPath( szSpec );
	lstrcat( szSpec, szName );
	lstrcat( szSpec, szExt );
	SetDlgItemText( hDlg, idCtl, Lowercase(szSpec) );
	}
else	SetDlgItemText( hDlg, idCtl, Lowercase(lpFileSpec) );
}
Пример #5
0
/**************************************************************************
 *
 * FUNCTION: DCTransferImage
 *
 * ARGS:    hWnd
 *
 * RETURNS: none
 *
 * NOTES:   1 ). delete any bit maps laying around
 *          2 ). mention those who do not want Native need CAP nego. ICAP_XFERMECH
 *          3 ). get a little information about image, for form, I do not use it
 *          4 ). set up a for form loop to pull image( s ) from the Source
 *          5 ). call for GetCompleteImage from Source
 *          6 ). be sure to send a MSG_ENDXFER as a seperator between images
 *          7 ). after the images are transfered I like to shut down the Source
 *              DCTerminate
 *
 * COMMENTS: Setup for a transfer in the routine called as a response to
 * XFERREADY.  Then has a nested loop do/while on the routine which
 * actually pulls in the image or GetCompleteImage.  The GetCompleteImage
 * routine also deals with the cancel, xferdone, success messages from
 * Source.
 *
**************************************************************************/
VOID DCTransferImage( HWND hWnd )
{
	TW_PENDINGXFERS dcPendingXfer;

	int image_count = 0;
	int transfer_ok;

	// explicitly initialize the our flags
	dcPendingXfer.Count = 0;

	// Ask Source if more images are coming.  I only support one image per transfer
	// in this example but do/while loop is included to help? those who wish to
	// support more than one.

	do 
    {
		// Tell the Source what type of transfer you want.
		switch( twainTransferType ) 
        {
			case TWSX_NATIVE : 
				transfer_ok = GetCompleteNativeImage( hWnd ); 
    			break;

			case TWSX_FILE   : 
				TW_SETUPFILEXFER  dcFileSetup;
				char number[32];

				wsprintf( number, "%05d", image_count );
				dcFileSetup.Format = twainFileFormat;

				switch( twainFileFormat ) 
                {
					case TWFF_TIFF : 
						GetFileLocation( IDN_TIFF, dcFileSetup.FileName );
						stripfile( dcFileSetup.FileName );
						lstrcat( dcFileSetup.FileName, "TWN" );
						lstrcat( dcFileSetup.FileName, number );
						lstrcat( dcFileSetup.FileName, ".TIF" );
					    break;

					case TWFF_BMP  : 
						GetFileLocation( IDN_BMP, dcFileSetup.FileName );
						stripfile( dcFileSetup.FileName );
						lstrcat( dcFileSetup.FileName, "TWN" );
						lstrcat( dcFileSetup.FileName, number );
						lstrcat( dcFileSetup.FileName, ".BMP" );
					    break;

					default : 
						twainError( IDS_MEMXFERFAILED );
						DCTerminate();
						return;
					    break;
				}
				image_count++;

				if(( *lpDSM_Entry )( &appID, &dsID, DG_CONTROL, DAT_SETUPFILEXFER, 
                                    MSG_SET,( TW_MEMREF )&dcFileSetup ) != TWRC_SUCCESS )
                {
					twainError( IDS_MEMXFERFAILED );
					return;
				}
				transfer_ok = GetCompleteFileImage( hWnd, dcFileSetup ); 
			    break;

			case TWSX_MEMORY : 
				TW_SETUPMEMXFER dcMemSetup;

				if(( *lpDSM_Entry )( &appID, &dsID,DG_CONTROL, DAT_SETUPMEMXFER, 
                                    MSG_GET,( TW_MEMREF )&dcMemSetup ) != TWRC_SUCCESS )
                {
					twainError( IDS_MEMXFERFAILED );
					return;
				}

				// Since we will return a length of the preferred size,
				// make sure that it is within our limits.
				if( dcMemSetup.Preferred > 65536L ) 
                    dcMemSetup.Preferred = 65536L;

				transfer_ok = GetCompleteMemoryImage( hWnd, dcMemSetup ); 
			    break;
		}

		if( transfer_ok ) 
        {
			// Required for proper 6<->7 state transitions
			if(( *lpDSM_Entry )( &appID, &dsID, DG_CONTROL, DAT_PENDINGXFERS, 
                               MSG_ENDXFER,( TW_MEMREF )&dcPendingXfer ) != TWRC_SUCCESS )
            {
				dcPendingXfer.Count = 0;  // trash remaining images
			}
		}

	} while( transfer_ok && ( dcPendingXfer.Count != 0 ));

	if( lpTwainPalette != ( pTW_PALETTE8 )NULL )
	{
		FreeUp(( LPTR )lpTwainPalette );
		lpTwainPalette = ( pTW_PALETTE8 )NULL;
	}

    // source could be shut down here after each image, but dialog is left up
    // until shut down by the user or app is terminated
    // DCTerminate();

	return;
}
Пример #6
0
long DoOpenDlg(
/************************************************************************/
HWND 	hDlg,
int 	idDlg,
WORD 	idType,
LPSTR 	pFileNameOut,
BOOL 	fSavingIn)
{
int iReturn;
FNAME szExtension, szStartDir;
int iStartDrive;

fSaving = fSavingIn;

idDataType = NULL;
bImageOpen = idDlg == IDD_OPEN || idDlg == IDD_SAVEAS;
idFileType = idType;
if (bImageOpen)
	{
	idFileType = bound(idFileType, IDN_ART, IDN_BMP);
	if (fSaving)
		{
		if (!Readers[idFileType-IDN_ART].bSave[FrameDepth(ImgGetBaseEditFrame(lpImage))])
			idFileType = IDN_ART;
		}
	else
		{
		if (!Readers[idFileType-IDN_ART].bOpen)
			idFileType = IDN_ART;
		}
	}
fUntitled = lpImage && lpImage->fUntitled;

if (bImageOpen && fSaving && !fUntitled)
	{
	lstrcpy( szSaveName, pFileNameOut );
	lstrcpy( szFileSpec, pFileNameOut );
	stripfile( szFileSpec );
	FixPath( szFileSpec );
	LookupExtension( idFileType, szExtension );
	lstrcat( szFileSpec, szExtension );
	}
else
	{
	GetFileLocation( idFileType, szFileSpec );
	}

/* Initialize some values used in DlgOpenProc */
wFileAttr = 0;

iStartDrive = CURRENTDRIVE;
CURRENTDIR( szStartDir, sizeof(FNAME) );
idOpen = 0;
do
	{
	if (idOpen)
		idDlg = idOpen;
	else
		idOpen = idDlg;
	iReturn = AstralDlg( NO|2, hInstAstral, hDlg, idDlg, DlgOpenProc );
	}
while (idOpen != idDlg);
CHDRIVE( iStartDrive );
//CHDIR( szStartDir );

if ( !iReturn )
	{
	pFileNameOut[0] = '\0';
	return( NULL );
	}

lstrcpy( pFileNameOut, szFileSpec );
SetFileLocation( idFileType, szFileSpec );

return( MAKELONG( idFileType, idDataType ) );
}
Пример #7
0
BOOL WINPROC EXPORT DlgOpenProc(
/************************************************************************/
HWND 	hDlg,
UINT 	msg,
WPARAM 	wParam,
LPARAM 	lParam)
{
BOOL Bool;
ITEMID id;
WORD wMsg, wIndex;
int i, ii, l, fp, hi, lo;
FNAME szDriveNDir, szFileName, szExtension;
HMENU hMenu;
STRING szString;
char cChar;
BOOL bModifySaveName;
static BOOL bDisableCancel;

switch (msg)
    {
    case WM_INITDIALOG:
	SET_CLASS_HBRBACKGROUND(hDlg, ( HBRUSH )GetStockObject(LTGRAY_BRUSH));
	CenterPopup( hDlg );
	if ( !DlgDirList(hDlg, szFileSpec, IDC_FLIST, IDC_FPATH, wFileAttr) )
		{
		lstrcpy( szFileSpec, lstrchr( szFileSpec, '*' ) );
		DlgDirList(hDlg, szFileSpec, IDC_FLIST, IDC_FPATH, wFileAttr);
		}
	SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, fSaving);
	CheckComboItem( hDlg, IDC_FILETYPES, IDC_ART, IDC_BMP,
		IDC_ART + (idFileType-IDN_ART) );
	SendDlgItemMessage(hDlg, IDC_FNAME, EM_LIMITTEXT, MAX_FNAME_LEN-1, 0L);

	LoadComboWithDrives( hDlg, IDC_DRIVES );
	LoadComboWithDirectories( hDlg, IDC_DIRS, NO );
	CheckDlgButton( hDlg, IDC_SAVEPATH, Save.OKtoSavePath );
	CheckDlgButton( hDlg, IDC_SAVECOMPRESS, Save.Compressed );
	for (i = IDC_ART; bImageOpen && i <= IDC_BMP; ++i)
		{
		ii = i-IDC_ART;
		if (lstrlen(Readers[ii].szDLL))
			{
			lstrcpy(szString, Control.ProgHome);
			lstrcat(szString, Readers[ii].szDLL);
			if (!FileExists(szString))
				{
				if ( GetPrivateProfileString( "Micrografx", "Libraries", "",
					szString, sizeof(STRING), "MGX.INI" ) > 2 )
						FixPath( szString );
				lstrcat(szString, Readers[ii].szDLL);
				if (!FileExists(szString))
					{
					ControlEnable( hDlg, i, NO);
					continue;
					}
				}
			}
		if (fSaving)
			ControlEnable( hDlg, i, lpImage &&
				Readers[ii].bSave[FrameDepth(ImgGetBaseEditFrame(lpImage))] );
		else
			ControlEnable( hDlg, i, Readers[ii].bOpen );
		}
	if ( bImageOpen && lpImage )
		{
		idDataType = lpImage->DataType;
		for (i = IDC_SAVECT; i <= IDC_SAVE24BITCOLOR; ++i)
			ControlEnable( hDlg, i,
			Readers[idFileType-IDN_ART].bTypes[i-IDC_SAVECT]);
		CheckComboItem( hDlg, IDC_DATATYPES, IDC_SAVECT,
			IDC_SAVE24BITCOLOR, idDataType );
		ControlEnable( hDlg, IDC_SAVECOMPRESS,
			Readers[idFileType-IDN_ART].bCompressed );
		}

	SetFocus( GetDlgItem( hDlg, IDC_FNAME ) );
	SendDlgItemMessage(hDlg, IDC_FNAME, EM_SETSEL,
		NULL, MAKELONG(0, 0x7fff));
	bNavigated = NO;
	bDisableCancel = NO;
	return( FALSE );

    case WM_PALETTECHANGED:
	break;

    case WM_MENUSELECT:
	lo = LOWORD(lParam);
	hi = HIWORD(lParam);
	if (hi == 0)
		break;
	if (lo == -1)
		break;
	if (lo & MF_SYSMENU)
		break;
	if (lo & MF_POPUP)
		{
		hMenu = (HMENU)wParam;
		while (GetSubMenu(hMenu, 0))
			hMenu = GetSubMenu(hMenu, 0);
		id = GetMenuItemID(hMenu, 0);
		if (id <= 0)
			break;
		wParam = id - 1;
		}
	HintLine( wParam );
	break;

    case WM_SETCURSOR:
	return( SetupCursor( wParam, lParam, idOpen ) );

    case WM_CLOSE:
	AstralDlgEnd( hDlg, FALSE|2 );
	break;

    case WM_MEASUREITEM:
    case WM_DRAWITEM:
	id = ((LPDRAWITEMSTRUCT)lParam)->CtlID;
	Bool = ( id == IDC_DRIVES || id == IDC_DIRS );
	return( OwnerDraw( hDlg, msg, lParam, Bool ) );
//	break;

    case WM_CTLCOLOR:
	return( (BOOL)SetControlColors( (HDC)wParam, hDlg, (HWND)LOWORD(lParam),
		HIWORD(lParam) ) );

    case WM_COMMAND:
	if (wParam != IDCANCEL)
		bDisableCancel = NO;
	switch(wParam)
	    {
	    case IDC_FILETYPES:
//	    case IDC_ART:
//	    case IDC_TIFF:
//	    case IDC_BMP:
		if ( !(wParam = HandleCombo( hDlg, wParam, lParam )) )
			break;
		idFileType = IDN_ART + (wParam-IDC_ART);
		if (bNavigated)
			{
			LookupExtension( idFileType, szFileSpec );
			}
		else	GetFileLocation( idFileType, szFileSpec );
		for (i = IDC_SAVECT; i <= IDC_SAVE24BITCOLOR; ++i)
			ControlEnable( hDlg, i,
			Readers[idFileType-IDN_ART].bTypes[i-IDC_SAVECT]);
		ControlEnable( hDlg, IDC_SAVECOMPRESS,
			Readers[idFileType-IDN_ART].bCompressed );
		SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, NO );
		SendMessage( hDlg, WM_COMMAND, IDOK, 0L );
		break;

	    case IDC_DATATYPES:
//	    case IDC_SAVECT:
//	    case IDC_SAVELA:
//	    case IDC_SAVESP: // scatterprint
//	    case IDC_SAVE8BITCOLOR:
//	    case IDC_SAVE24BITCOLOR:
		if ( !(wParam = HandleCombo( hDlg, wParam, lParam )) )
			break;
		idDataType = wParam;
		break;

	    case IDC_SAVEPATH:
		Save.OKtoSavePath = (BOOL)SendDlgItemMessage (hDlg, IDC_SAVEPATH,
		  BM_GETCHECK, 0, 0L);
//		Save.OKtoSavePath = !Save.OKtoSavePath;
//		CheckDlgButton( hDlg, IDC_SAVEPATH, Save.OKtoSavePath );
		break;

	    case IDC_SAVECOMPRESS:
		Save.Compressed = (BOOL)SendDlgItemMessage (hDlg, IDC_SAVECOMPRESS,
		  BM_GETCHECK, 0, 0L);
//		Save.Compressed = !Save.Compressed;
//		CheckDlgButton( hDlg, IDC_SAVECOMPRESS, Save.Compressed );
		break;

	    case IDC_DRIVES:
		wMsg = HIWORD(lParam);
		if ( wMsg != CBN_SELCHANGE )
			break;
		wIndex = SendDlgItemMessage( hDlg, wParam, CB_GETCURSEL, 0, 0L);
		SendDlgItemMessage( hDlg, wParam, CB_GETLBTEXT, wIndex,
			(long)(LPSTR)szDriveNDir );
		id = ExtractStringID( szDriveNDir );
		if (CHDRIVE( *szDriveNDir - 'a' ))
			{
			LoadComboWithDrives(hDlg, IDC_DRIVES);
			break;
			}
		if (!CURRENTDIR(szString, sizeof(szString)))
			{
			GetDlgItemText(hDlg, IDC_FPATH, szString,
				 sizeof(szString));
			CHDRIVE(*szString - 'a');
			LoadComboWithDrives(hDlg, IDC_DRIVES);
			}
//12/15		SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, NO);
		DlgDirList( hDlg, szFileSpec, IDC_FLIST, IDC_FPATH, wFileAttr );
		LoadComboWithDirectories( hDlg, IDC_DIRS, YES );
		SetDlgItemText( hDlg, IDC_DISKSPACE,
			DriveSize( *szDriveNDir - 'a', szString ) );
		SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, fSaving );
		bNavigated = YES;
		break;

	    case IDC_DIRS:
		wMsg = HIWORD(lParam);
		if ( wMsg == LBN_DBLCLK )
			{
			SendMessage(hDlg, WM_COMMAND, IDOK, 1L);
			break;
			}
		if ( wMsg != LBN_SELCHANGE )
			break;
		wIndex = SendDlgItemMessage( hDlg, wParam, LB_GETCURSEL, 0, 0L);
		// Figure out how to build the path name based on the selection
		SendDlgItemMessage( hDlg, wParam, LB_GETTEXT, wIndex,
			(long)(LPSTR)szDriveNDir );
		id = ExtractStringID( szDriveNDir );
		if ( id == IDC_PATHICON_OPEN )
			i = 0; // Must start building the path from the root
		else
		if ( id == IDC_PATHICON_ACTIVE )
			i = 9999; // Don't build any path - we're there
		else	i = wIndex; // OK to build a relative path
		szFileName[0] = '\0';
		for ( ; i<=wIndex; i++ )
			{
			SendDlgItemMessage( hDlg, wParam, LB_GETTEXT, i,
				(long)(LPSTR)szDriveNDir );
			id = ExtractStringID( szDriveNDir );
			if ( id == IDC_PATHICON_CLOSED && i != wIndex )
				continue;
			lstrcat( szFileName, SkipSpaces(szDriveNDir) );
			if ( id != IDC_PATHICON_ROOT )
				lstrcat( szFileName, "\\" );
			}
		lstrcat( szFileName, szFileSpec );
		SetFileName(hDlg, IDC_FNAME, szFileName, szSaveName, NO );
		bNavigated = YES;
		break;

	    case IDC_FLIST:
		wMsg = HIWORD(lParam);
		if ( wMsg == LBN_DBLCLK )
			{
			SendMessage(hDlg, WM_COMMAND, IDOK, 1L);
			break;
			}
		if ( wMsg != LBN_SELCHANGE )
			break;
		/* If a directory is selected... */
		if (DlgDirSelectEx(hDlg, szFileName, sizeof(szFileName), wParam))
			lstrcat(szFileName, szFileSpec);
		// 1-2-92 - TMR - always use SetFileName for all FNAME sets
// 		SetDlgItemText(hDlg, IDC_FNAME, szFileName);
		SetFileName(hDlg, IDC_FNAME, szFileName, szSaveName, NO );
		SendDlgItemMessage(hDlg, IDC_FNAME, EM_SETSEL,
			NULL, MAKELONG(0, 0x7fff));
//		SendDlgItemMessage(hDlg, IDC_FNAME, CB_SETEDITSEL,
//			NULL, MAKELONG(0, 0x7fff));
		break;

	    case IDC_FNAME:
		/* If the name is changed, disable OK if its length goes 0 */
		if (HIWORD(lParam) != EN_CHANGE)
//		if (HIWORD(lParam) != CBN_EDITCHANGE)
			break;
		ControlEnable( hDlg, IDOK,
			(BOOL)SendDlgItemMessage( hDlg, wParam,
			WM_GETTEXTLENGTH, 0, 0L));
		
		// 1-2-92 - TMR - make sure Edit Box has focus to make sure
		// that szSaveName only gets overwritten from user input
		// 1-3-92 - TMR - move this after ControlEnable
		if (GetFocus() != GetDlgItem(hDlg, IDC_FNAME))
			break;
		if (fSaving)
			{
			GetDlgItemText(hDlg, IDC_FNAME, szSaveName,
				MAX_FNAME_LEN);
			fUntitled = NO;
			}
		break;

	    case IDC_FPATH:
		wMsg = HIWORD(lParam);
		if ( wMsg == BN_DOUBLECLICKED )
			{
			SendMessage(hDlg, WM_COMMAND, IDOK, 1L);
			break;
			}
		if ( wMsg != BN_CLICKED )
			break;
 		GetDlgItemText(hDlg, wParam, szFileName, sizeof(szFileName));
		if ( !szFileName[0] )
			break;
		FixPath( szFileName );
		lstrcat( szFileName, szFileSpec );
		SetFileName(hDlg, IDC_FNAME, szFileName, szSaveName, NO );
		bNavigated = YES;
		break;

	    case IDOK:
		GetDlgItemText(hDlg, IDC_FNAME, szFileName,sizeof(szFileName));
		bModifySaveName = fSaving && StringsEqual(szFileName,
			szSaveName);
		/* Strip off the drive and directory to make */
		/* a DlgDirlist() call to switch over to them */
		/* Loop backwards over the file name */
		l = lstrlen(szFileName);
		while( --l >= 0 )
		   {
		   cChar = szFileName[l];
		   /* If we find a wildcard, the next DlgDirList() takes */
		   /* care of drive and directory switching; so get out */
		   if ( cChar == '?' || cChar == '*' )
			break;
		   /* If we find a drive or directory, handle it and get out */
		   if ( cChar == '\\' || cChar == ':' )
			{
			lstrcpy(szDriveNDir, szFileName);
			l++;
			szDriveNDir[l] = '\0';
			lstrcat(szDriveNDir, szFileSpec);
			// 1-3-92 - TMR - Handle directory change error
			if (DlgDirList(hDlg, szDriveNDir,
					 IDC_FLIST, IDC_FPATH, wFileAttr))
				lstrcpy( szFileName, &szFileName[l] );
			else
				{
				szDriveNDir[l] = '\0';
				Message(IDS_EDIRECTORYCHANGE,
					 Lowercase(szDriveNDir));
				szFileName[0] = '\0';
				}
			break;
			}
		   }

		// 1-3-92 - TMR add extension if none present
		/* Check to see if the file has an extension... */
		if ( !lstrchr( szFileName, '.' ) ) // if no extension...
		    if ( LookupExtension( idFileType, szExtension ) )
			{
			if (lstrlen(szFileName))
			    lstrcat( szFileName, extension(szExtension) );
			else
			    lstrcat( szFileName, szExtension);
			}
		if (bModifySaveName)
			lstrcpy(szSaveName, szFileName);

		/* Try to display a new list box */
		if ( !szFileName[0] )
			lstrcat(szFileName, szFileSpec);
		if (DlgDirList(hDlg, szFileName, IDC_FLIST, IDC_FPATH,
		    wFileAttr))
			{ /* A wildcard was found and a new list displayed */
			lstrcpy(szFileSpec, szFileName);
			SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName,
				fSaving );
			LoadComboWithDrives( hDlg, IDC_DRIVES );
			LoadComboWithDirectories( hDlg, IDC_DIRS, YES );
			
			break;
			}

		// If there is still a path or wildcards in the name, the
		// file specification must be invalid
		if (lstrchr(szFileName, '\\') || lstrchr(szFileName, ':') ||
		    lstrchr(szFileName, '?') || lstrchr(szFileName, '*'))
			{
			lstrcpy(szString, szFileName);
			stripfile(szString);
			Message(IDS_EDIRECTORYCHANGE, Lowercase(szString));
			lstrcpy(szFileSpec, filename(szFileName));
			lstrcpy(szFileName, szFileSpec); // is this needed?
			SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName,
				fSaving );
			break;
			}

		/* No wildcards, and the drive and dir have been changed */
		LoadComboWithDrives( hDlg, IDC_DRIVES );
		LoadComboWithDirectories( hDlg, IDC_DIRS, YES );

		/* Check to see if the file has 8 characters or less... */
		if ( fSaving )
			RemoveWhiteSpace( szFileName );
		FixFileName( szFileName );

		/* Check to see if the file has an extension... */
		if ( !lstrchr( szFileName, '.' ) ) // if no extension...
			if ( LookupExtension( idFileType, szExtension ) )
				lstrcat( szFileName, extension(szExtension) );

		// Build the fully qualified path name
		GetDlgItemText( hDlg, IDC_FPATH, szString, sizeof(szString) );
		FixPath( szString );
		lstrcat( szString, szFileName );

		/* Check to see if the file exists... */
		if ( (fp = _lopen( szString, OF_READ ) ) < 0 )
			{ /* The file does not exist */
			if ( !fSaving )
				{
				Message(IDS_EOPEN, Lowercase(szString));
				break;
				}
			}
		else	{
			_lclose( fp );
			if ( fSaving )
				{
				if ( !AstralAffirm( IDS_OVERWRITEIMAGE,
					Lowercase(szString) ) )
					break;
				}
			}

		lstrcpy( szFileSpec, szString );
		AstralDlgEnd(hDlg, TRUE|2);
		break;

	    case IDC_CANCEL:
	    case IDCANCEL:
		if ( bDisableCancel && !LOWORD(lParam) )
			break;
		GetDlgItemText(hDlg, IDC_FPATH, szFileSpec,sizeof(szFileSpec));
		AstralDlgEnd(hDlg, FALSE|2);
		break;

	    default:
		return( FALSE );
	    }
	break;

    default:
	return( FALSE );
    }

return( TRUE );
}