⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ide_misc.c

📁 一套美国国家宇航局人工智能中心NASA的专家系统工具源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************* AbortProc: Processes messages for the Abort Dialog box*******************************************************************/#if IBM_BCC#pragma argsused#endifint FAR PASCAL _export AbortProc(hPr, Code)	HDC hPr;	int Code;{  MSG msg;    /*---------------------------------+    | If the abort dialog isn't up yet |    +---------------------------------*/   if (!hAbortDlgWnd)             		return(TRUE);   /*---------------------------------------------------+   | Process messages intended for the abort dialog box |   +---------------------------------------------------*/	while (!bAbort && PeekMessage(&msg, NULL, NULL, NULL, TRUE))   {  if (!IsDialogMessage(hAbortDlgWnd, &msg))      {   TranslateMessage(&msg);          DispatchMessage(&msg);      }	}   return (!bAbort);}/******************************************************************* AbortDlg: Processes messages for printer abort dialog box*******************************************************************/#if IBM_BCC#pragma argsused#endifint FAR PASCAL _export AbortDlg(hDlg, msg, wParam, lParam)	HWND hDlg;	unsigned msg;	WORD wParam;   LONG lParam;{  switch(msg)   {  /*-------------------------------------+      | Watch for Cancel button, RETURN key, |      | ESCAPE key, or SPACE BAR             |		+-------------------------------------*/      case WM_COMMAND:         return (bAbort = TRUE);      case WM_INITDIALOG:      {  /*----------------------------------------------+	 | Set the focus to the Cancel box of the dialog |	 +----------------------------------------------*/         extern char szFileName[];			SetFocus(GetDlgItem(hDlg, IDCANCEL));         SetDlgItemText(hDlg, IDC_FILENAME, szFileName);	 return (TRUE);      }   }   return (FALSE);}/******************************************************************* About: Processes messages for "About" dialog box*******************************************************************/#if IBM_BCC#pragma argsused#endifBOOL FAR PASCAL _export About(hDlg, message, wParam, lParam)   HWND hDlg;     unsigned message;	WORD wParam;   LONG lParam;{  switch (message)   {  case WM_INITDIALOG:         return (TRUE);		case WM_COMMAND:      { if (wParam == IDOK || wParam == IDCANCEL)	 {  EndDialog(hDlg, TRUE);            return (TRUE);			}	 return (TRUE);      }   }   return (FALSE);}/******************************************************************* PrintFile: Procedure to send editor buffer out to a printer.*******************************************************************/BOOL PrintFile ( hWnd )   HWND hWnd;{  extern BOOL bAbort;   extern HWND hAbortDlgWnd;   extern HWND hEditWnd;   extern HANDLE hHourGlass;   extern HANDLE hInst;   extern char szTemp[];   int nPageSize;	   /* vert. resolution of printer device */	int LineSpace;          /* spacing between lines          */   int LinesPerPage;       /* lines per page                 */   int CurrentLine;        /* current line                   */   int LineLength;         /* line length                    */   WORD wLines;            /* number of lines to print       */   WORD wIndex;            /* index into lines to print      */   char szLine[128];       /* buffer to store lines before printing */   TEXTMETRIC TextMetric;  /* information about character size      */   FARPROC lpAbortDlg;   FARPROC lpAbortProc;   HANDLE hSaveCursor;	HDC hPr;   int Status;   hSaveCursor = SetCursor(hHourGlass);   hPr = GetPrinterDC();   if (!hPr)   {  extern char szFileName[];      sprintf(szTemp, "Cannot print %s", szFileName);      MessageBox(hWnd, szTemp, NULL, MB_OK | MB_ICONHAND);      return (NULL);	}	#if WIN_32	lpAbortDlg = AbortDlg;	lpAbortProc = AbortProc;#else	lpAbortDlg =  MakeProcInstance(AbortDlg, hInst);	lpAbortProc = MakeProcInstance(AbortProc, hInst);#endif	/*--------------------------+	| Define the abort function |	+--------------------------*/	Escape(hPr, SETABORTPROC, NULL, (LPSTR)  lpAbortProc, (LPSTR) NULL);	if (Escape(hPr, STARTDOC, 14, "PrntFile text", (LPSTR) NULL) < 0)	{  MessageBox(hWnd, "Unable to start print job", NULL, MB_OK | MB_ICONHAND);#if ! WIN_32		FreeProcInstance(lpAbortDlg);		FreeProcInstance(lpAbortProc);#endif		DeleteDC(hPr);	}   /*---------------------+   | Clear the abort flag |   +---------------------*/   bAbort = FALSE;	/*---------------------------------------+   | Create the Abort dialog box (modeless) |   +---------------------------------------*/   hAbortDlgWnd = CreateDialog(hInst, "AbortDlg", hWnd, lpAbortDlg);   if (!hAbortDlgWnd)   {  SetCursor(hSaveCursor);      MessageBox(hWnd, "NULL Abort window handle", NULL, MB_OK | MB_ICONHAND);      return (FALSE);   }   /*----------------------+   | Now show Abort dialog |   +----------------------*/   ShowWindow (hAbortDlgWnd, SW_NORMAL);   /*---------------------------+   | Disable the main window to |   | avoid reentrancy problems  |   +---------------------------*/	EnableWindow(hWnd, FALSE);   SetCursor(hSaveCursor);   /*---------------------------------------------------------+                                                             | Since you may have more than one line, you need to       |   | compute the spacing between lines.  You can do that by   |   | retrieving the height of the characters you are printing |   | and advancing their height plus the recommended external |   | leading height.                                          |   +---------------------------------------------------------*/	GetTextMetrics(hPr, &TextMetric);   LineSpace = TextMetric.tmHeight + TextMetric.tmExternalLeading;   /*------------------------------------------------------+   | Since you may have more lines than can fit on one     |   | page, you need to compute the number of lines you can |   | print per page.  You can do that by retrieving the    |   | dimensions of the page and dividing the height        |   | by the line spacing.                                  |   +------------------------------------------------------*/	nPageSize = GetDeviceCaps (hPr, VERTRES);   LinesPerPage = nPageSize / LineSpace - 1;   /*----------------------------------------------------------+   | You can output only one line at a time, so you need a     |   | count of the number of lines to print.  You can retrieve  |   | the count sending the EM_GETLINECOUNT message to the edit |   | control.                                                  |   +----------------------------------------------------------*/   wLines = (WORD)SendMessage(hEditWnd, EM_GETLINECOUNT, 0, 0L);   /*---------------------------------------------------+   | Keep track of the current line on the current page |   +---------------------------------------------------*/   CurrentLine = 1;   /*-------------------------------------------------------+   | One way to output one line at a time is to retrieve    |   | one line at a time from the edit control and write it  |   | using the TextOut function.  For each line you need to |	| advance one line space.  Also, you need to check for   |   | the end of the page and start a new page if necessary. |       +-------------------------------------------------------*/   Status = 0;   for (wIndex = 0; wIndex < wLines; wIndex++)   {  szLine[0] = 127;	       szLine[1] = 0;      LineLength = (int)SendMessage(hEditWnd, EM_GETLINE, wIndex, (DWORD)(LPSTR)szLine);      TextOut(hPr, 0, CurrentLine*LineSpace, (LPSTR)szLine, LineLength);      if (++CurrentLine > LinesPerPage )		{  CurrentLine = 1;			Status = Escape(hPr, NEWFRAME, 0, 0L, 0L);	 if (Status < 0 || bAbort) break;		}	}	if (Status >= 0 && !bAbort)	{  Escape(hPr, NEWFRAME, 0, 0L, 0L);		Escape(hPr, ENDDOC, 0, 0L, 0L);	}	EnableWindow(hWnd, TRUE);	/*-----------------------------+	| Destroy the Abort dialog box |	+-----------------------------*/	DestroyWindow(hAbortDlgWnd);#if ! WIN_32	FreeProcInstance(lpAbortDlg);	FreeProcInstance(lpAbortProc);#endif	DeleteDC(hPr);   return ( TRUE );}

⌨️ 快捷键说明

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