wsdosdlg.c

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

C
560
字号
/*							!0 will show reboot ELSE exit to DOS message				*/
/*	RETURNS:																						*/
/*																									*/
/*-------------------------------------------------------------------------*/

void PUBLIC wsDosCopyError( char *szFile, WORD wErrorType, WORD WillExit )
{
   char   szText1[512];
   char   szText2[512];
   char   szCaption[50];

	if ( wErrorType > MAX_DOSCPYERR )
		wErrorType = MAX_DOSCPYERR;

   wsLoadSz(IDS_CPYERRPREFIX, szText1 , sizeof(szText1));
   wsLoadSz(IDS_DOSCPYERROR + wErrorType, szText2 , sizeof(szText2));

   lstrcat(szText1,szText2);
   wsprintf(szText2, szText1, (LPSTR)szFile);

   if ( wWillExit ) {
      wsLoadSz(IDS_DOSERROPT + 1, szText1 , sizeof(szText1));
      wsLoadSz(IDS_FATAL_CAPTION, szCaption , sizeof(szCaption));
   }
   else {
      wsLoadSz(IDS_DOSERROPT, szText1 , sizeof(szText1));
      wsLoadSz(IDS_NONFATAL_CAPTION, szCaption , sizeof(szCaption));
   }
   lstrcat(szText2,szText1);
   
   MessageBox(GetActiveWindow(),szText2,szCaption,MB_OK|MB_SYSTEMMODAL|
              MB_ICONEXCLAMATION);
}

/*-------------------------------------------------------------------------*/
/*	Displays a generic error dialog on the screen. The caller passes the		*/
/* resourse ID number of the dialog to be displayed.								*/
/*                 																			*/
/*	void PUBLIC wsNonFatalError( WORD wMsgID )         							*/
/*																									*/
/*	ARGUMENTS:																					*/
/*		wMsgID 	   Resource ID of the dialog box to be displayed.				*/
/*	RETURNS:																						*/
/*     void																						*/
/*-------------------------------------------------------------------------*/

void PUBLIC wsNonFatalError( WORD wMsgID )
{
   char   szText1[512];
   char   szCaption[50];

   wsLoadSz(wMsgID,szText1,sizeof(szText1));
   wsLoadSz(IDS_NONFATAL_CAPTION,szCaption,sizeof(szCaption));

   MessageBox(GetActiveWindow(),szText1,szCaption,MB_OK|MB_SYSTEMMODAL|
              MB_ICONEXCLAMATION);

}

/*-------------------------------------------------------------------------*/
/* Displays a fatal error message in a dialog box and tells the user the	*/
/* program will exit either by a return to DOS or a reboot.						*/
/* 																								*/
/*	WORD PUBLIC wsFatalError( WORD wType, WORD WillReboot )						*/
/*																									*/
/*	ARGUMENTS:	wType			- Enumerated error type.								*/
/*					WillReboot	- Signals which exit message should be displayed*/
/*									  !0 will show reboot ELSE exit to DOS message	*/
/*	RETURNS:		VOID                                                        */
/*-------------------------------------------------------------------------*/

void PUBLIC wsFatalError( WORD wType, WORD WillReboot )
{
   char   szText1[512];
   char   szText2[256];
   char   szCaption[50];
   WORD   wMBflags;

   wsLoadSz(IDS_FERROR+wType,szText1,sizeof(szText1));
   wsLoadSz(IDS_FATAL_CAPTION,szCaption,sizeof(szCaption));
   wMBflags = MB_OK | MB_SYSTEMMODAL;

   if ( WillReboot ) {
	   wsLoadSz(IDS_FERRORABORT,szText2,sizeof(szText2));
      wMBflags |= MB_ICONSTOP;
   }
   else {
	   wsLoadSz(IDS_FERROREXIT,szText2,sizeof(szText2));
      wMBflags |= MB_ICONEXCLAMATION;
   }

   lstrcat(szText1,"\n\n");
   lstrcat(szText1,szText2);

   MessageBox(GetActiveWindow(),szText1,szCaption,wMBflags);
}

/*----------------------------------------------------------------------------*\
|   wsQueryStartDlg( hDlg, uiMessage, wParam, lParam )                         |
|                                                                              |
|   Queries the user if they want Windows started at boot time.
|
|   Returns:                                                                   |
|       TRUE if message has been processed, else FALSE                         |
|                                                                              |
\*----------------------------------------------------------------------------*/

BOOL FAR PASCAL  wsQueryStartDlg( HWND hDlg, unsigned uiMessage, WORD wParam,
											 long lParam )
{
    WORD    fOptions;

	switch (uiMessage)
	{
		case WM_COMMAND:
			switch (wParam)
			{
				case ID_AUTOSTART:
					CheckDlgButton( hDlg, wParam, !IsDlgButtonChecked( hDlg, wParam ) );
					break;

				case ID_OK:
					fOptions = 0;
					if ( IsDlgButtonChecked( hDlg, ID_AUTOSTART ) )
						fOptions = F_AUTOSTART;
					EndDialog( hDlg, fOptions );
					return( TRUE );

				case ID_CANCEL:
					    // make this the same as pressing F3
					if ( QueryExit(NULL) )
					{
						EndDialog(hDlg, 0);
						AppQuit();
					}
					break;
			}
			return TRUE;

		case WM_INITDIALOG:
			wsDlgInit(hDlg, DLGINIT_REMOVE_CLOSE_MENU);
			CheckDlgButton( hDlg, ID_AUTOSTART, TRUE );
#ifdef NEED_FIX
			wsHelp( DLG_WINSETUP );
#endif
		return( TRUE );
	}
	return( FALSE );
}


/*-------------------------------------------------------------------------*/
/*	wsBadDosExitDlg( hDlg, uiMessage, wParam, lParam )                       */
/*	                                                                        */
/*	Arguments:                                                              */
/*	    hDlg            window handle of about dialog window                */
/*	    uiMessage       message number                                      */
/*	    wParam          message-dependent                                   */
/*	    lParam          message-dependent                                   */
/*	                                                                        */
/*	Returns:                                                                */
/*	    
/*	                                                                        */
/*-------------------------------------------------------------------------*/

BOOL FAR PASCAL wsBadDosExitDlg( HWND hDlg, unsigned uiMessage, WORD wParam, long lParam )
{

	switch (uiMessage)
	{
		case WM_COMMAND:
			switch (wParam )
			{
				case ID_EXITSETUP:
					EndDialog( hDlg, TRUE );
					AppQuit();
					break;

				case ID_OK:
					EndDialog( hDlg, FALSE );
					break;

				default:
					break;
			}
			return FALSE;

		case WM_INITDIALOG:
			wsDlgInit( hDlg, 0 );
			MessageBeep( 0 );
			return TRUE;

		default:
			return( FALSE );
	}
}

#if 0

/* BOOL PUBLIC dsWelcomeDlg(HWND hDlg, unsigned uiMessage, WORD wParam, long lParam);
 *
 * Dialog proc for welcome UI. Explane about the process, need for an
 * uninstall disk. Allow user access to help or quit. Pretty generic DlgProc
 * since help and exit are handled for this class.
 *
 * Used with template DLG_UNINSTALLINFO. Dialog is of CLS_MYDLGS.
 *
 * ENTRY:  hDlg            window handle for this dialog window.
 *         uiMessage       message for us.
 *         wParam          message-dependent                   
 *         lParam          message-dependent                   
 *
 * EXIT: BOOL as per message processing. TRUE to user if we processed.
 *                                       FALSE to user if we did not process.
 *
 *       EndDialog() return is not important.
 */
BOOL PUBLIC dsWelcomeDlg(HWND hDlg, unsigned uiMessage, WORD wParam, long lParam)
{
	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 );
			return TRUE;

		default:
			return( FALSE );
	}
}

#endif

/* void PUBLIC dsStartWait(void);
 *
 * Turn the DosSetup cursor to a hour glass
 *
 * ENTRY: None.
 * EXIT: None.
 *
 */
void PUBLIC dsStartWait()
{
   HCURSOR  hCur;
        
   if ( hCur = LoadCursor(NULL,IDC_WAIT) )
      hSavedCur = SetCursor(hCur);
}

/* void PUBLIC dsEndWait(void);
 *
 * Turn the DosSetup cursor to an arrow.
 *
 * ENTRY: None.
 * EXIT: None.
 *
 */
void PUBLIC dsEndWait()
{
   if ( hSavedCur )
      SetCursor(hSavedCur);
}








⌨️ 快捷键说明

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