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

📄 edrateq.c

📁 GESPI 2.0动态系统模拟工具  
💻 C
📖 第 1 页 / 共 2 页
字号:
   if( eqefl )
   {
    errfl = 0; 				/* no errors yet	*/
    p = point_error( buff );
    SendMessage( hEdit, WM_SETTEXT, 0, (DWORD) (LPSTR) buff );
    SendMessage( hEdit, EM_SETSEL, 0, MAKELONG( p, p ) );
    yyreset();
   }

   /* set the focus on the edit control								*/
   SetFocus( hEdit );

   return TRUE;

  case WM_COMMAND:
   switch( wParam )
   {
    case IDC_HELP:                        /* Help for this Dialog Box			 */
     WinHelp( hDlg, (LPSTR) szHelpFile, HELP_KEY, (DWORD) (LPSTR) "Rate equation editor" );
     SetFocus( hEdit );
     return TRUE;

    case IDOK:
     SendMessage( hEdit, WM_GETTEXT, (WORD) sizeof( buff ), (DWORD) (LPSTR) buff );
     if( lexic( buff ) )
     {
      MessageBeep( MB_OK );
      MessageBox( hDlg, errstr, (LPSTR) "Rate Equation Editor", MB_ICONINFORMATION );
      p = point_error( buff );
      SendMessage( hEdit, WM_SETTEXT, 0, (DWORD) (LPSTR) buff );
      SendMessage( hEdit, EM_SETSEL, 0, MAKELONG( p, p ) );
      yyreset();
     }
     else
      EndDialog( hDlg, IDOK );
     return TRUE;

    case IDCANCEL:
     /* close the dialog box and return			*/
     EndDialog( hDlg, IDCANCEL );
     return TRUE;
   }

  default: return FALSE;
 }
}

BOOL FAR PASCAL EdRDet( HWND hDlg, WORD message, WORD wParam, LONG lParam )
{
 static	HWND	hIdLst, hEdit;
 static int 	id_sel;
 int i;

 switch( message )
 {
  case WM_INITDIALOG:
   /* get the handles to the controls								*/
   hIdLst = GetDlgItem( hDlg, IDC_PARAMLST );
   hEdit  = GetDlgItem( hDlg, IDE_M0 );

   SendMessage( hEdit, WM_SETTEXT, 0, (DWORD) (LPSTR) tr.descr );
   if( tr.nid>0 )
   {
    /* insert the identifiers in the list box						*/
    for( i=0; i<tr.nid; i++ )
     SendMessage( hIdLst, LB_INSERTSTRING, i, (DWORD) (LPSTR) &tr.id[i][0] );

    /* select the first id on the list								*/
    SendMessage( hIdLst, LB_SETCURSEL, 0, 0 );
    id_sel = 0;
    SendDlgItemMessage( hDlg, IDRB_0E+(int)tr.id[id_sel][9], BM_SETCHECK, (WORD) 1, 0 );
    SendDlgItemMessage( hDlg, IDRB_9I, BM_SETCHECK, (WORD) tr.revers, 0 );

   /* set the focus on the list box									*/
   SetFocus( hIdLst );
   }
   else
   {
    EnableWindow( hIdLst, FALSE );
    for( i=IDRB_0E; i<=IDRB_1I; i++ )
     EnableWindow( GetDlgItem( hDlg, i ), FALSE );
   }

   /* set the reversibility status									*/
   SendMessage( GetDlgItem( hDlg, IDRB_9I ), BM_GETCHECK, (WORD) tr.revers, 0 );

   /* Limit the length of the title to 64 characters				*/
   SendMessage( hEdit, EM_LIMITTEXT, (WORD) 64, 0 );

   return TRUE;

  case WM_COMMAND:
   switch( wParam )
   {
    case IDC_PARAMLST:
     if( HIWORD( lParam ) == LBN_SELCHANGE )
     {
      id_sel = (int) SendMessage( hIdLst, LB_GETCURSEL, 0, 0 );
      for(i=IDRB_0E; i<=IDRB_1I; i++ )
       SendDlgItemMessage( hDlg, i, BM_SETCHECK, 0, 0 );
      SendDlgItemMessage( hDlg, IDRB_0E+(int)tr.id[id_sel][9], BM_SETCHECK, (WORD) 1, 0 );
      return TRUE;
     }
     else return FALSE;

    case IDRB_0E:
     tr.id[id_sel][9] = (char) 0;
     return TRUE;

    case IDRB_0I:
     tr.id[id_sel][9] = (char) 1;
     return TRUE;

    case IDRB_1E:
     tr.id[id_sel][9] = (char) 2;
     return TRUE;

    case IDRB_1I:
     tr.id[id_sel][9] = (char) 3;
     return TRUE;

    case IDRB_9I:
     if( SendMessage( GetDlgItem( hDlg, IDRB_9I ), BM_GETCHECK, 0, 0 ) )
      tr.revers = 1;
     else
      tr.revers = 0;
     return TRUE;

    case IDC_HELP:                        /* Help for this Dialog Box			 */
   	 WinHelp( hDlg, (LPSTR) szHelpFile, HELP_KEY, (DWORD) (LPSTR) "Rate equation details" );
     SetFocus( hEdit );
     return TRUE;

    case IDOK:
     SendMessage( hEdit, WM_GETTEXT, (WORD) sizeof( tr.descr ), (DWORD) (LPSTR) &tr.descr[0] );
     if( strlen( tr.descr ) == 0 )
     {
      LoadString( hInst, IDS_ERR_NO_NAME, szString, sizeof(szString) );
      MessageBeep( MB_OK );
      MessageBox(hDlg, szString, NULL, MB_ICONINFORMATION);
      return TRUE;
     }
     EndDialog( hDlg, IDOK );
     return TRUE;

    case IDCANCEL:
     /* close the dialog box and return			*/
     EndDialog( hDlg, IDCANCEL );
     return TRUE;
   }

  default: return FALSE;
 }
}

BOOL FAR PASCAL EdNSub( HWND hDlg, WORD message, WORD wParam, LONG lParam )
{
 static	HWND	hEdit, hEdit2;
 char auxstr[33];
 static int s, p;

 switch( message )
 {
  case WM_INITDIALOG:
   /* get the handles to the edit controls							*/
   hEdit = GetDlgItem( hDlg, IDE_M0 );
   hEdit2 = GetDlgItem( hDlg, IDE_M1 );
   /* Limit the length of the text to 32 characters					*/
   SendMessage( hEdit,  EM_LIMITTEXT, (WORD) 32, 0 );
   SendMessage( hEdit2, EM_LIMITTEXT, (WORD) 32, 0 );

   wsprintf( (LPSTR) auxstr, "%d", tr.nsub );
   SendMessage( hEdit,  WM_SETTEXT, 0, (DWORD) (LPSTR) auxstr );
   wsprintf( (LPSTR) auxstr, "%d", tr.npro );
   SendMessage( hEdit2,  WM_SETTEXT, 0, (DWORD) (LPSTR) auxstr );
   return TRUE;

  case WM_COMMAND:
   switch( wParam )
   {
    case IDC_HELP:                        /* Help for this Dialog Box			 */
   	 WinHelp( hDlg, (LPSTR) szHelpFile, HELP_KEY, (DWORD) (LPSTR) "Number of substrates" );
     SetFocus( hEdit );
     return TRUE;

    case IDOK:
     SendMessage( hEdit2, WM_GETTEXT, (WORD) sizeof( auxstr ), (DWORD) (LPSTR) auxstr );
     tr.npro = atoi( auxstr );
     SendMessage( hEdit, WM_GETTEXT, (WORD) sizeof( auxstr ), (DWORD) (LPSTR) auxstr );
     tr.nsub = atoi( auxstr );
     if( tr.nsub<0 )
     {
      LoadString( hInst, IDS_ERR_NEG, szString, sizeof(szString) );
      MessageBeep( MB_OK );
      MessageBox(hDlg, szString, NULL, MB_ICONINFORMATION);
      SetFocus( hEdit );
      return TRUE;
     }
     if( (tr.revers) && (tr.nsub==0) )
     {
      LoadString( hInst, IDS_ERR_NO_SUBS, szString, sizeof(szString) );
      MessageBeep( MB_OK );
      MessageBox(hDlg, szString, NULL, MB_ICONINFORMATION);
      SetFocus( hEdit );
      return TRUE;
     }
     if( tr.npro<0 )
     {
      LoadString( hInst, IDS_ERR_NEG, szString, sizeof(szString) );
      MessageBeep( MB_OK );
      MessageBox(hDlg, szString, NULL, MB_ICONINFORMATION);
      SetFocus( hEdit2 );
      return TRUE;
     }
     if( (tr.revers) && (tr.npro==0) )
     {
      LoadString( hInst, IDS_ERR_NO_PRODS, szString, sizeof(szString) );
      MessageBeep( MB_OK );
      MessageBox(hDlg, szString, NULL, MB_ICONINFORMATION);
      SetFocus( hEdit2 );
      return TRUE;
     }
     EndDialog( hDlg, IDOK );
     return TRUE;

    case IDCANCEL:
     /* close the dialog box and return			*/
     EndDialog( hDlg, IDCANCEL );
     return TRUE;
   }

  default: return FALSE;
 }
}

void AddKLst( HWND hControl, int idx )
{
 int i;
 WORD ElWidth;
 HANDLE hDC;

 hDC = GetDC( hControl );
 ElWidth = 5 + LOWORD( GetTextExtent( hDC, tree[idx].descr, _fstrlen(tree[idx].descr) ) );
 SetTextJustification( hDC, 0, 0 );
 ReleaseDC( hControl, hDC );
 if( ElWidth > (WORD) lbWidth )
 {
  lbWidth = ElWidth;
  SendMessage( hControl, LB_SETHORIZONTALEXTENT, lbWidth, 0 );
 }
 if( eqefl )
 {
  SendMessage( hControl, LB_DELETESTRING, idx, 0 );
  SendMessage( hControl, LB_INSERTSTRING, idx, (DWORD) tree[idx].descr );
 }
 else
 {
  SendMessage( hControl, LB_INSERTSTRING, -1, (DWORD) tree[idx].descr );
  SendMessage( hControl, WM_VSCROLL, SB_BOTTOM, 0 );
 }
}

BOOL FAR PASCAL EdUdkt(HWND hDlg, WORD Message, WORD wParam, LONG lParam)
{
 static HWND hSelect, hButt, hDel;
 static int eqidx;
 int i,j,nRc;
 FARPROC lpfnProc2;

 switch( Message )
 {
  case WM_INITDIALOG:
   /* get handles for controls						*/
   hSelect = GetDlgItem( hDlg, IDC_KINETLST );
   hButt = GetDlgItem( hDlg, IDC_CHANGE );
   hDel = GetDlgItem( hDlg, IDC_DEL );

   /* initialize hSelect: add all rate equations	*/
   for( i=0, lbWidth=0; i<nudf; i++ )
    AddKLst( hSelect, i );
   if( nudf==0 )
   {
    EnableWindow( hButt, FALSE );
    EnableWindow( hDel, FALSE );
   }
   else SendMessage( hSelect, LB_SETCURSEL, 0, 0 );
   return TRUE;

   case WM_USER+1:
    lpfnProc2 = MakeProcInstance((FARPROC) EdRateq, hInst);
    nRc = DialogBox(hInst, (LPSTR)"EDRATEQ", hDlg, lpfnProc2);
    FreeProcInstance(lpfnProc2);
    if( nRc == IDOK )
    {
     if( eqefl )
      for( i=0; i<tr.nid; i++ )
       for( j=0; j<tree[eqidx].nid; j++ )
        if( ! lstrcmp( &tr.id[i][0], &tree[eqidx].id[j][0] ) )
         tr.id[i][9] = tree[eqidx].id[j][9];
     lpfnProc2 = MakeProcInstance((FARPROC) EdRDet, hInst);
     nRc = DialogBox(hInst, (LPSTR)"ED_RDET", hDlg, lpfnProc2);
     FreeProcInstance(lpfnProc2);
     if( nRc == IDOK )
     {
      tidy_tree();
      if( (!tr.revers) ||
          ( (tr.revers) && (tr.nsub==0) ) ||
          ( (tr.revers) && (tr.npro==0) )
        )
      {
       lpfnProc2 = MakeProcInstance((FARPROC) EdNSub, hInst);
       nRc = DialogBox(hInst, (LPSTR)"ED_NSUB", hDlg, lpfnProc2);
       FreeProcInstance(lpfnProc2);
       if( nRc != IDOK ) return TRUE;
      }
      new_tree( eqidx );
      new_rateq( eqidx );
      AddKLst( hSelect, eqidx );
     }
    }
    return TRUE;

  case WM_COMMAND:
   switch(wParam)
   {
    case IDC_ADD:
     eqefl = 0; eqidx = nudf;
     _fmemset( (void __far*) &tr, 0, sizeof( struct treet ) );
     SendMessage( hDlg, WM_USER+1, 0, 0 );
     return TRUE;

    case IDC_CHANGE:
     /* get the index of the element selected					*/
     eqidx = (int) SendMessage( hSelect, LB_GETCURSEL, 0, 0 );
     if( eqidx != LB_ERR )
     {
      /* signal that it is a change, not a new one				*/
      eqefl = 1;
      /* copy it to the edit tree structure						*/
      _fmemcpy( (void __far*) &tr, (void __far*) &(tree[eqidx]), sizeof( struct treet ) );
      SendMessage( hDlg, WM_USER+1, 0, 0 );
     }
     return TRUE;

    case IDC_KINETLST:
     if( HIWORD( lParam ) == LBN_DBLCLK )
     {
      SendMessage( hDlg, WM_COMMAND, IDC_CHANGE, 0 );
      return TRUE;
     }
     else return FALSE;

    case IDC_HELP:            /* Help on this Dialog Box				*/
   	 WinHelp( hDlg, (LPSTR) szHelpFile, HELP_KEY, (DWORD) (LPSTR) "Kinetic types database" );
     return TRUE;

    case IDOK:
     EndDialog(hDlg, IDOK);
     return TRUE;

   }    /* End of WM_COMMAND                                 */
   return FALSE;

  default:
   return FALSE;
 }
} /* End of METABMsgProc                                      */

⌨️ 快捷键说明

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