wsdosdlg.c

来自「Dos6.0」· C语言 代码 · 共 560 行 · 第 1/2 页

C
560
字号
#include <winenv.h>
#include "ws.h"
#include "wsrc.h"
#include "pro.h"
#include "lib\\common\\sulib.h"

/*-------------------------------------------------------------------------*/
/* The following code was added to support the DOS/Windows merge				*/
/*-------------------------------------------------------------------------*/

#define	FMT_UPDATE			500

WORD		wFatalErrorType;		/* Used by wsFatalError()	*/
WORD  	wWillReboot;			/* Used by wsFatalError()	*/

HANDLE	hFmtWnd;					/* Handle to format status dialog		*/

FARPROC	fpxFmtProDlg;			/* Ptr to fmt status handler instance	*/
PSTR		szFmtStatus[ MAXSTR / 2 ];
PSTR		szPercent[ MAXSTR / 2 ];

WORD		wCpyErrorType;
WORD		wWillExit;
PSTR		szErrorStr[ MAXSTR / 2 ];
PSTR		szFileName[ MAXSTR / 2 ];

WORD     wPrepErrType;
HCURSOR  hSavedCur = NULL;

/*-------------------------------------------------------------------------*/
/*	Function which prompts the user to insert the disk they labeled			*/
/* Uninstall into drive A:.																*/
/* 																								*/
/* WORD PUBLIC wsInsertUninstalDisk( void )											*/
/*																									*/
/*	ARGUMENTS:	NONE																			*/
/*	RETURNS:																						*/
/*     OK (0) if user pressed OK key else												*/
/*-------------------------------------------------------------------------*/

WORD PUBLIC wsInsertUninstall(char *szUserLabel )
{
	return ( (WORD)fDialogWithlParam( DLG_UNINSTALL,GetActiveWindow(),
									          wsUninstallDlg, (LONG)((LPSTR)szUserLabel) ) );
}

/*-------------------------------------------------------------------------*/
/*	wsUninstallDlg( hDlg, uiMessage, wParam, lParam )                       */
/*	                                                                        */
/*	Arguments:                                                              */
/*	    hDlg            window handle of about dialog window                */
/*	    uiMessage       message number                                      */
/*	    wParam          message-dependent                                   */
/*	    lParam          message-dependent                                   */
/*	                                                                        */
/*	Returns:                                                                */
/*	    TRUE if message has been processed, else FALSE                      */
/*	                                                                        */
/*-------------------------------------------------------------------------*/

BOOL FAR PASCAL wsUninstallDlg(HWND hDlg,unsigned uiMessage,WORD wParam,long lParam)
{
   char    szTmp1[200];
   char    szTmp2[200];

	switch (uiMessage)
	{
		case WM_COMMAND:
			switch (wParam )
			{
				case ID_OK:
					EndDialog( hDlg, 0 );
					break;

				default:
					break;
			}
			return TRUE;

		case WM_INITDIALOG:
			wsDlgInit( hDlg, DLGINIT_REMOVE_CLOSE_MENU );
         GetDlgItemText(hDlg,ID_STATUS0,szTmp1,sizeof(szTmp1));
         wsprintf(szTmp2,szTmp1,(LPSTR)lParam);
         SetDlgItemText(hDlg,ID_STATUS0,szTmp2);
			MessageBeep( 0 );
			return TRUE;

		default:
			return( FALSE );
	}
}

/*-------------------------------------------------------------------------*/
/*	Function to display a dialog box to let the user select the proper		*/
/*	format for a 3.5" disk.                                                 */
/* 																								*/
/* WORD PUBLIC wsSelectDskFmt( void )                                      */
/*																									*/
/*	ARGUMENTS:	NONE																			*/
/*	RETURNS:                                                                */
/*    0 if 720K, 1 if 1.44 MB, 2 if CANCEL                                 */
/*-------------------------------------------------------------------------*/

WORD PUBLIC wsSelectDskFmt( int iDriveType )
{

   return( fDialogWithlParam(DLG_FMTTYPE,GetActiveWindow(),wsDskTypeDlg,
                             (DWORD)iDriveType) );

}

/*-------------------------------------------------------------------------*/
/* Process messages sent to the dialog box DLG_DISKFMT_TYPE which allows	*/
/*	the user to select the proper format for a 3.5" disk.							*/
/*	                                                                        */
/*	wsUninstallDlg( hDlg, uiMessage, wParam, lParam )                       */
/*																									*/
/*	Arguments:                                                              */
/*	    hDlg            window handle of about dialog window                */
/*	    uiMessage       message number                                      */
/*	    wParam          message-dependent                                   */
/*	    lParam          message-dependent                                   */
/*                     at WM_INIT time, lParam will be iDriveType where    */
/*                                                                         */
/*                     iDriveType = 2 = 1.2mb floppy drive.                */
/*                     iDriveType = 4 = 1.44mb floppy drive.               */
/*	                                                                        */
/*	Returns: Return value will indicate choice of disk capacity chosen:     */
/*                                                                         */
/*          Return of 0 indicates lower density choice was made.           */
/*          Return of 1 indicates high density choice was made.            */
/*	                                                                        */
/*-------------------------------------------------------------------------*/

BOOL FAR PASCAL wsDskTypeDlg( HWND hDlg, unsigned uiMessage, WORD wParam,
										  long lParam )
{
	WORD		  wSelection;
   static int iSavDrvType;
	
	switch (uiMessage)
	{
		case WM_COMMAND:
			switch (wParam )
			{
				case ID_OK:
					if ( ! SendDlgItemMessage( hDlg, ID_LOW_DENSITY, BM_GETCHECK, 0, 0L ) )
						wSelection = 1;
               else
						wSelection = 0;
					EndDialog( hDlg, wSelection );
					break;

			}
			return TRUE;

		case WM_INITDIALOG:

         iSavDrvType = (int)LOWORD(lParam);

         if ( iSavDrvType == 2 ) {
            SetDlgItemText(hDlg, ID_HIGH_DENSITY, wsLoadSz(IDS_KB1200,NULL,0));
            SetDlgItemText(hDlg, ID_LOW_DENSITY, wsLoadSz(IDS_KB360,NULL,0));
         }
			wsDlgInit( hDlg, DLGINIT_REMOVE_CLOSE_MENU );

			/* Send messge to hi-lite top radio button (high capacity choice)	*/

			SendDlgItemMessage( hDlg, ID_HIGH_DENSITY, BM_SETCHECK, 1, 0L );
			MessageBeep( 0 );
			return TRUE;

		default:
			return( FALSE );
	}
}

/*-------------------------------------------------------------------------*/
/*	Opens the disk formatting status box on the screen and then calls the	*/
/*	format status update function to set the initial state to 0%.				*/
/*																									*/
/*	void PUBLIC wsFmtDlgOpen( void )														*/
/*																									*/
/*	ARGUMENTS:	NONE																			*/
/*	RETURNS:		void																			*/
/*																									*/
/*-------------------------------------------------------------------------*/

void PUBLIC wsFmtDlgOpen( void )
{
	
	fpxFmtProDlg = MakeProcInstance( (FARPROC)wsFmtProDlg, hInstWS );
	hFmtWnd = CreateDialog( hInstWS, MAKEINTRESOURCE( DLG_FMTSTATUS ),
									GetActiveWindow(), fpxFmtProDlg );

	ShowWindow( hFmtWnd, SHOW_OPENWINDOW );
	UpdateWindow( hFmtWnd );
	wsFmtDlgUpdate( 0 );
}   

/*-------------------------------------------------------------------------*/
/* Removes the format status box from the screen.									*/
/*																									*/
/*	void PUBLIC wsFmtDlgClose( void )													*/
/*																									*/
/*	ARGUMENTS:	NONE																			*/
/*	RETURNS:		void																			*/
/*																									*/
/*-------------------------------------------------------------------------*/

void PUBLIC wsFmtDlgClose( void )
{
	DestroyWindow( hFmtWnd );
	FreeProcInstance( fpxFmtProDlg );
}

/*-------------------------------------------------------------------------*/
/* Updates the percentage complete line in the format status dialog by		*/
/* sending a message to the window with the new percentage value.				*/
/*																									*/
/*	void PUBLIC wsFmtDlgUpdate( WORD wPercent )										*/
/*																									*/
/*	ARGUMENTS:	wPercent	-	Percentage of format that is complete.				*/
/*	RETURNS:		void																			*/
/*																									*/
/*-------------------------------------------------------------------------*/

void PUBLIC wsFmtDlgUpdate( WORD wPercent )
{
	SendMessage( hFmtWnd, FMT_UPDATE, wPercent, 0L );
}

/*-------------------------------------------------------------------------*/
/* Updates the percentage complete line in the format status dialog by		*/
/* sending a message to the window with the new percentage value.				*/
/*																									*/
/*	void PUBLIC wsFmtDlgUpdate( WORD wPercent )										*/
/*																									*/
/*	Arguments:                                                              */
/*		hDlg			Handle for the format status window								*/
/*		uiMessage	message number FMT_UPDATE or WN_INITDIALOG					*/
/*		wParam		If uiMessage == FMT_UPDATE the percentage complete value	*/
/*		lParam		Not used.																*/
/*	                                                                        */
/*	Returns:			TRUE if message was handled else FALSE							*/
/*																									*/
/*-------------------------------------------------------------------------*/

BOOL FAR PASCAL wsFmtProDlg( HWND hDlg, unsigned uiMessage, WORD wParam,
									  long lParam )
{
	switch ( uiMessage )
	{
		case WM_INITDIALOG:
			wsDlgInit( hDlg, 0 );
			wsLoadSz( IDS_PERCENT, (PSTR)szPercent , MAXSTR*2);
			/* 	MessageBeep( 0 ); */
			return( TRUE );

		case FMT_UPDATE:
			wsprintf( (LPSTR)szFmtStatus, "%d%s", wParam, (LPSTR)szPercent );
			SetDlgItemText( hFmtWnd, ID_STATUS0, (LPSTR)szFmtStatus );
			return( TRUE );

		default:
			return( FALSE );
	}
}

/*-------------------------------------------------------------------------*/
/* Displays a file copy error message in a dialog box and tells the user	*/
/*	the program will either continue to exit to DOS depending of the value	*/
/* of the argument WillReboot.															*/
/* 																								*/
/*	WORD PUBLIC wsDosCopyError( char *szFile, WORD wType, WORD WillReboot ) */
/*																									*/
/*	ARGUMENTS:																					*/
/*		szFile			Ptr to a file name												*/
/*		wErrorType		Enumerated error type											*/
/*		WillExit			Signals which exit message should be displayed			*/

⌨️ 快捷键说明

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