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

📄 dialog2.c

📁 NASA 开发使用的一个专家系统
💻 C
📖 第 1 页 / 共 4 页
字号:
   /*******************************************************/   /*      "C" Language Integrated Production System      */	/*                                                     */   /*                  A Product Of The                   */   /*             Software Technology Branch              */   /*             NASA - Johnson Space Center             */   /*                                                     */   /*               CLIPS Version 6.00  10/01/92          */   /*                                                     */   /*                   DIALOG2 MODULE                    */   /*******************************************************//**************************************************************//* Purpose: Contains the callback functions for all the       *//*       list manager dialog items.                           *//*                                                            *//* Principal Programmer(s):                                   *//*      Christopher J. Ortiz                                  *//*                                                            *//* Contributing Programmer(s):                                *//*                                                            *//* Revision History:                                          *//*                                                            *//**************************************************************//*-------------------------------+| Windows & System Include Files |+-------------------------------*/#include <windows.h>/*------------------------+| CLIPS 6.0 Include Files |+------------------------*/#include "setup.h"#include "dffctdef.h"#include "commline.h"#include "rulecom.h"#include "rulebsc.h"#include "dffctbsc.h"#include "router.h"#include "tmpltdef.h"#include "tmpltbsc.h"#include "dffnxfun.h"#include "defins.h"#include "genrccom.h"#include "classcom.h"#include "classexm.h"#include "classinf.h"#include "msgcom.h"#include "engine.h"#include "globldef.h"#include "globlbsc.h"/*------------------------+| Interface Include Files |+------------------------*/#include "ids.h"#include "dialog.h"#include "main.h"struct symbolMatch *matches;char DialogName[80];BOOL FAR PASCAL _export DefMethodsManager( HWND, unsigned, WORD, LONG );BOOL FAR PASCAL _export DefMessageManager( HWND, unsigned, WORD, LONG );VOID ShowButtons ( HWND, int, int, int, int, int, int, int, int, int );VOID HandleButton (HWND, int, int );VOID HandleCkBox  (HWND, int, int );/************************************************************************* HandleCkBox: procedure will update the state of a check box*   in the list manager************************************************************************/VOID HandleCkBox ( hDlg, State, Ident )	HWND hDlg; /* Pointer to the Window */	int State; /* HIDE, CHECK, UNCHECK OR GRAY */	int Ident; /* Checkbox ID */{ switch (State)   {  case HIDE:	 ShowWindow(GetDlgItem(hDlg, Ident), SW_HIDE);	 break;      case CHECK:      case UNCHECK:	 ShowWindow(GetDlgItem(hDlg, Ident), SW_SHOW);	 EnableWindow(GetDlgItem(hDlg, Ident), TRUE);	 CheckDlgButton ( hDlg, Ident, State );	 break;      case GRAY:	 ShowWindow(GetDlgItem(hDlg, Ident), SW_SHOW);	 EnableWindow(GetDlgItem(hDlg, Ident), FALSE);	 CheckDlgButton ( hDlg, Ident, DISABLE );	 break;   }}/************************************************************************* HandleButton: procedure will update the state of a button*   in the list manager************************************************************************/VOID HandleButton ( hDlg, State, Ident )   HWND hDlg;  /* Window Pointer */   int State;  /* HIDE, ENABLE, DISABLE */   int Ident;  /* Button ID */{  switch (State)   {  case HIDE:	 ShowWindow(GetDlgItem(hDlg, Ident), SW_HIDE); break;		case ENABLE:      case DISABLE:	 EnableWindow(GetDlgItem(hDlg, Ident), State);   }}/******************************************************************** ShowButtons: Common procedure to Activate, Deactivate, Hide, and*   Gray controls within the list manager dialog.*******************************************************************/VOID ShowButtons ( hDlg, PB1, PB2, PB3, PB4, PB5, CB1, CB2, CB3, PB6)   HWND hDlg;   int PB1, PB2, PB3, PB4, PB5, PB6;   int CB1, CB2, CB3;{  HandleButton ( hDlg, PB1, IDC_PBUTTON1 );   HandleButton ( hDlg, PB2, IDC_PBUTTON2 );	HandleButton ( hDlg, PB3, IDC_PBUTTON3 );   HandleButton ( hDlg, PB4, IDC_PBUTTON4 );   HandleButton ( hDlg, PB5, IDC_PBUTTON5 );   HandleButton ( hDlg, PB6, IDC_PBUTTON6 );	HandleCkBox  ( hDlg, CB1, IDC_CBOX1 );   HandleCkBox  ( hDlg, CB2, IDC_CBOX2 );   HandleCkBox  ( hDlg, CB3, IDC_CBOX3 );}/********************************************************************** DefFactManager: Callback Function for the DefFact*   List Box Manager.*********************************************************************/#if IBM_TBC#pragma argsused#endifBOOL FAR PASCAL _export DefFactManager (hDlg, message, wParam, lParam)   HWND       hDlg;	unsigned   message;   WORD       wParam;	LONG       lParam;  {#if DEFFACTS_CONSTRUCT	HWND hListBox;                         	hListBox = GetDlgItem ( hDlg, IDC_LISTBOX);   switch (message)	  {		case WM_INITDIALOG:      {  VOID *deffactPtr = NULL;	 int count=0;	 StartWaitCursor();	 while ((deffactPtr = GetNextDeffacts ( deffactPtr )) != NULL)	 {  count ++;	    SendMessage ( hListBox, LB_ADDSTRING, 0,(LPARAM)(LPCSTR) GetDeffactsName (deffactPtr));	    WinRunEvent();	 }	 StopWaitCursor();	 SendMessage ( hListBox, LB_SETCURSEL, 0, 0L);	 sprintf ( DialogName,"Deffacts Manager - %4d Items",count);	 SetWindowText ( hDlg, (LPSTR)DialogName );	 ShowButtons ( hDlg, DISABLE, HIDE, HIDE, DISABLE, HIDE,	    HIDE, HIDE, HIDE, ENABLE);	 return (TRUE);      }      case WM_COMMAND:      {  switch (wParam)	 {  case IDC_PBUTTON6:		 {  EndDialog( hDlg, IDOK);	       return (TRUE);	    }			       /*--------*/		 case IDC_PBUTTON1: /* Remove */	    case IDC_PBUTTON4: /* PPrint */	    case IDC_LISTBOX:  /*--------*/		 {  int index;			 int stringsize;			 VOID *deffactPtr;			 HANDLE hString;#if WIN_32			 char *string;#else			 char far *string;#endif			 extern SCREEN WinDialog;			 index = (int) SendMessage ( hListBox, LB_GETCURSEL, 0, 0L );			 stringsize = (int) SendMessage(hListBox, LB_GETTEXTLEN, index, 0);			 if (stringsize == LB_ERR)		  break;			  /* hString = GlobalAlloc(GMEM_FIXED, (WORD) stringsize);				*/			hString = GlobalAlloc(GMEM_FIXED, (WORD) stringsize + 1);			 if ( hString == NULL)			 {  EndDialog( hDlg, IDOK);		  ExitToShell();			 }			 string = GlobalLock ( hString );			 /* OK to here */			 if (string == NULL)    /* Added by GDR */				{				 EndDialog( hDlg, IDOK);				 ExitToShell();				}								 SendMessage(hListBox, LB_GETTEXT, index,(LPARAM)((LPSTR) string) );			 deffactPtr = FindDeffacts ( string );	       /*----------------+	       | Remove Deffacts |	       +----------------*/	       if ( wParam == IDC_PBUTTON1 )			 {   int count;		  Undeffacts ( deffactPtr );		  SendMessage (hListBox, LB_DELETESTRING, index, 0L );		  count = (int)  SendMessage (hListBox, LB_GETCOUNT, 0, 0);		  sprintf ( DialogName,"Deffacts Manager - %4d Items",count);		  SetWindowText ( hDlg, (LPSTR)DialogName );		  PrintCLIPS ("wclips", "(undeffacts ");		  PrintCLIPS ("wclips", string );		  PrintCLIPS ("wclips", ")\n");		  PrintPrompt ();		  SetFocus(hListBox);		  InvalidateRect (WinDialog.hWnd, NULL, TRUE );		  GlobalUnlock ( hString );		  GlobalFree ( hString );		  break;	       }	       /*----------------+	       | PPrint Deffacts |	       +----------------*/	       if ( wParam == IDC_PBUTTON4 )	       {  PrintCLIPS ("wclips", "(ppdeffacts ");		  PrintCLIPS ("wclips", string );		  PrintCLIPS ("wclips", ")\n");		  PrintCLIPS ("wclips", GetDeffactsPPForm ( deffactPtr ));		  PrintPrompt ();		  InvalidateRect (WinDialog.hWnd, NULL, TRUE );		  SetFocus(hListBox);	       }	       ShowButtons ( hDlg,		  IsDeffactsDeletable(deffactPtr), HIDE, HIDE,		  ( GetDeffactsPPForm(deffactPtr) != NULL),		   HIDE, HIDE, HIDE, HIDE, ENABLE );	       GlobalUnlock ( hString );	       GlobalFree ( hString );	       return (TRUE);	    }	 }	 break;      }   }#endif   return (FALSE);}/************************************************************* DefTemplateManager: Callback Function for the*   DefTemplate List Box Manager.************************************************************/#if IBM_TBC#pragma argsused#endifBOOL FAR PASCAL _export DefTemplateManager (hDlg, message, wParam, lParam)   HWND       hDlg;   unsigned   message;   WORD       wParam;   LONG       lParam;{#if DEFTEMPLATE_CONSTRUCT   HWND hListBox = GetDlgItem ( hDlg, IDC_LISTBOX);   switch (message)   {  case WM_INITDIALOG:      {  VOID *deftemplatePtr = NULL;	 int count=0;	 StartWaitCursor();	 while ((deftemplatePtr = GetNextDeftemplate ( deftemplatePtr )) != NULL)	 {  count ++;	    SendMessage ( hListBox, LB_ADDSTRING, 0,(LPARAM)(LPCSTR) GetDeftemplateName (deftemplatePtr));	    WinRunEvent();	 }	 StopWaitCursor();	 SendMessage ( hListBox, LB_SETCURSEL, 0, 0L);	 sprintf ( DialogName,"Deftemplate Manager - %4d Items",count);	 SetWindowText ( hDlg, (LPSTR)DialogName );	 ShowButtons ( hDlg, DISABLE, HIDE, HIDE, DISABLE, HIDE,	    GRAY, HIDE, HIDE, ENABLE);	 return (TRUE);      }		case WM_COMMAND:      {  switch (wParam)	 {  case IDC_PBUTTON6:	    {  EndDialog( hDlg, IDOK);	       return (TRUE);	    }			       /*--------*/	    case IDC_PBUTTON1: /* Remove */	    case IDC_PBUTTON4: /* PPrint */	    case IDC_CBOX1:    /* Trace  */	    case IDC_LISTBOX:  /*--------*/	    {  int index = (int) SendMessage ( hListBox, LB_GETCURSEL, 0, 0L );	       int stringsize = (int) SendMessage(hListBox, LB_GETTEXTLEN, index, 0);	       VOID *deftemplatePtr;			 HANDLE hString;#if WIN_32			 char *string;#else			 char far *string;#endif			 if (stringsize == LB_ERR)		  break;	       hString = GlobalAlloc(GMEM_FIXED, (WORD) stringsize+1);	       if (hString == NULL)	       {  EndDialog( hDlg, IDOK);		  ExitToShell();	       }	       string = GlobalLock ( hString );	       SendMessage( hListBox, LB_GETTEXT, index,(LPARAM)((LPSTR) string) );	       deftemplatePtr = FindDeftemplate ( string );	       /*-------------------+	       | Remove Deftemplate |	       +-------------------*/	       if ( wParam == IDC_PBUTTON1 )			 {  extern SCREEN WinDialog;			 int count;		  Undeftemplate ( deftemplatePtr );		  SendMessage (hListBox, LB_DELETESTRING, index, 0L );		  count = (int) SendMessage (hListBox, LB_GETCOUNT, 0, 0);		  sprintf ( DialogName,"Deftemplate Manager - %4d Items",count);		  SetWindowText ( hDlg, (LPSTR)DialogName );		  PrintCLIPS ("wclips", "(undeftemplate ");		  PrintCLIPS ("wclips", string );		  PrintCLIPS ("wclips", ")\n");		  PrintPrompt ();		  InvalidateRect ( WinDialog.hWnd, NULL, TRUE );		  SetFocus(hListBox);		  GlobalUnlock ( hString );		  GlobalFree ( hString );		  break;	       }	       /*-------------------+	       | PPrint Deftemplate |	       +-------------------*/	       if ( wParam == IDC_PBUTTON4 )	       {  extern SCREEN WinDialog;		  PrintCLIPS ("wclips", "(ppdeftemplate ");		  PrintCLIPS ("wclips", string );		  PrintCLIPS ("wclips", ")\n");		  PrintCLIPS ("wclips", GetDeftemplatePPForm(deftemplatePtr));		  PrintPrompt ();		  InvalidateRect ( WinDialog.hWnd, NULL, TRUE );		  SetFocus(hListBox);	       }	       /*-----------------+	       | Set-Remove Trace |	       +-----------------*/	       if ( wParam == IDC_CBOX1 )	       {  SetDeftemplateWatch (!GetDeftemplateWatch(deftemplatePtr), deftemplatePtr);		  SetFocus (hListBox);	       }	       /*-------------------+	       | Toggle Check Boxes |	       +-------------------*/	       GlobalUnlock ( hString );	       GlobalFree ( hString );	       ShowButtons ( hDlg,		  IsDeftemplateDeletable (deftemplatePtr), HIDE, HIDE,		  (GetDeftemplatePPForm ( deftemplatePtr ) != NULL), HIDE,		  GetDeftemplateWatch(deftemplatePtr), HIDE, HIDE, ENABLE);	       return (TRUE);	    }	 }	 break;      }   }#endif   return (FALSE);}/************************************************************* DefFunctionManager: Callback Function for the*   DefFunction List Box Manager.************************************************************/#if IBM_TBC#pragma argsused#endifBOOL FAR PASCAL _export DefFunctionManager (hDlg, message, wParam, lParam)   HWND       hDlg;   unsigned   message;   WORD       wParam;   LONG       lParam;{#if DEFFUNCTION_CONSTRUCT   HWND hListBox = GetDlgItem ( hDlg, IDC_LISTBOX);   switch (message)   {  case WM_INITDIALOG:      {  VOID *DeffunctionPtr = NULL;	 int count=0;	 StartWaitCursor();	 while ((DeffunctionPtr = GetNextDeffunction ( DeffunctionPtr )) != NULL)	 {  count ++;	    WinRunEvent();	    SendMessage ( hListBox, LB_ADDSTRING, 0,(LPARAM)(LPCSTR) GetDeffunctionName (DeffunctionPtr));	 }	 StopWaitCursor();	 SendMessage ( hListBox, LB_SETCURSEL, 0, 0L);	 sprintf ( DialogName,"Deffunction Manager - %4d Items",count);	 SetWindowText ( hDlg, (LPSTR)DialogName );	 ShowButtons ( hDlg, DISABLE, HIDE, HIDE, DISABLE, HIDE,	    GRAY, HIDE, HIDE, ENABLE);	 return (TRUE);      }      case WM_COMMAND:      {  switch (wParam)	 {  case IDC_PBUTTON6:	    {  EndDialog( hDlg, IDOK);	       return (TRUE);	    }

⌨️ 快捷键说明

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