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

📄 gwtop.c

📁 GESPI 2.0动态系统模拟工具  
💻 C
📖 第 1 页 / 共 2 页
字号:
     else
      wsprintf( (LPSTR) szASTR, "GEPASI - Topology" );
     break;
    case SIZENORMAL:
    case SIZEFULLSCREEN:
     wsprintf( (LPSTR) szASTR, "GEPASI - Topology" );
    break;
   }
   SendMessage( hWnd, WM_SETTEXT, 0, (DWORD) (LPSTR) szASTR );
   break;       /* End of WM_SIZE                                 */

  case WM_PAINT:    /* code for the window's client area          */
   /* Obtain a handle to the device context                       */
   /* BeginPaint will sends WM_ERASEBKGND if appropriate          */
   memset( &ps, 0x00, sizeof( PAINTSTRUCT ) );
   hDC = BeginPaint(hWnd, &ps);
   /* Included in case the background is not a pure color         */
   SetBkMode( hDC, TRANSPARENT );
   i=0;
   if( FileName[0] != '\0' )
    wsprintf( szASTR, "filename: %s", (LPSTR) FileTitle );
   else
    wsprintf( szASTR, "undefined filename");
   TextOut( hDC, TxtX(0), TxtY(i++), szASTR, strlen( szASTR ) );
   wsprintf( szASTR, "%i metabolites", totmet );
   TextOut( hDC, TxtX(0), TxtY(i++), szASTR, strlen( szASTR ) );
   wsprintf( szASTR, "%i steps", nsteps );
   TextOut( hDC, TxtX(0), TxtY(i++), szASTR, strlen( szASTR ) );
   if( (nsteps > 0) && (kinass != nsteps) )
   {
    wsprintf( szASTR, "%i kinetics undefined", nsteps - kinass );
    TextOut( hDC, TxtX(0), TxtY(i++), szASTR, strlen( szASTR ) );
   }
   if( (nloops > 0) && (loopass != nloops) )
   {
    wsprintf( szASTR, "%i loops undefined", nloops - loopass );
    TextOut( hDC, TxtX(0), TxtY(i++), szASTR, strlen( szASTR ) );
   }
   EndPaint( hWnd, &ps );
   break;       /*  End of WM_PAINT                               */

  case WM_USER+1:
   if( !(nRc = ReadTop( FileName ) ) )
   {
    /* get the filename without the path						*/
    GetFileTitle( (LPSTR) FileName, (LPSTR) FileTitle, sizeof(FileTitle) );
    /* signal that it has not yet been changed				*/
    notsaved = 0;
    /* count the number of loops and assigned kinetic types	*/
    for( i=0, nloops=0, kinass=0, loopass=0; i<nsteps; i++ )
    {
     /* count the number of assigned kinetics				*/
     if( kinetu[i] != NOT ) kinass++;
     /* count the number of loops							*/
     if( ktype[kinetu[i]].nmodf > 0 ) nloops++;
     /* count the number of assigned modfs for each reaction	*/
     for( j=0, nmod[i]=0; j<totmet; j++ )
      if( (*loop)[i][j] != 0 ) nmod[i]++;
     /* count the number of assigned loops					*/
     if( (ktype[kinetu[i]].nmodf>0) &&
         (ktype[kinetu[i]].nmodf == nmod[i]) ) loopass++;
    }
    if( nsteps>0 )
    {
     EnableMenuItem( hMenu, IDM_E_KINETICS , MF_ENABLED );
     EnableMenuItem( hMenu, IDM_E_METABOLITES , MF_ENABLED );
    }
    else
    {
     EnableMenuItem( hMenu, IDM_E_KINETICS , MF_GRAYED );
     EnableMenuItem( hMenu, IDM_E_METABOLITES , MF_GRAYED );
     EnableMenuItem( hMenu, IDM_E_LOOPS , MF_GRAYED );
    }
    EnableMenuItem( hMenu, IDM_F_SAVE, MF_ENABLED );
    if( nloops > 0 )
     EnableMenuItem( hMenu, IDM_E_LOOPS , MF_ENABLED );
    else
     EnableMenuItem( hMenu, IDM_E_LOOPS , MF_GRAYED );
    InvalidateRect( hWnd, NULL, TRUE );
   }
   else
   {
    LoadString( hInst, nRc, szString, sizeof(szString) );
    MessageBeep( MB_ICONQUESTION );
    MessageBox( NULL, szString, NULL, MB_ICONINFORMATION );
    SendMessage( hWnd, WM_COMMAND, IDM_F_NEW, 0 );
   }
   break;

  case WM_COMMAND:
   switch (wParam)
   {
    case IDA_F1HELP:
    case IDM_H_CONTENTS:
   	 WinHelp( hWnd, (LPSTR) szHelpFile, HELP_INDEX, 0 );
   	 break;

    case IDM_H_SEARCH:
   	 WinHelp( hWnd, (LPSTR) szHelpFile, HELP_PARTIALKEY, (DWORD) (LPSTR) "" );
   	 break;

    case IDM_H_HELPONHELP:
   	 WinHelp( hWnd, (LPSTR) szHelpFile, HELP_HELPONHELP, 0 );
   	 break;

    case IDM_H_ABOUT:
     lpfnProc = MakeProcInstance((FARPROC)AboutBox, hInst);
     DialogBox(hInst, (LPSTR)"ABOUTBOX", hWnd, lpfnProc);
     FreeProcInstance(lpfnProc);
     break;

    case IDM_F_OPEN:
     if( notsaved )
      AskAboutSave( hWnd, hInst, FileName, MB_ICONQUESTION | MB_YESNO );
     if( GetOFileName( hWnd,
       				  (LPSTR) FileName, 256,
      				  (LPSTR) "Open topology file",
       				  (LPSTR) "topology (*.TOP)\0*.TOP\0simulation (*.SIM)\0*.SIM\0" ) )
      SendMessage( hWnd, WM_USER+1, 0, 0 );
     break;

    case IDM_F_CLOSE:
     SendMessage( hWnd, WM_CLOSE, 0, 0 );
     break;

    case IDM_F_SAVE:
     WriteTop( FileName );
     notsaved = 0;
     break;

    case IDM_F_SAVEAS:
     if( GetSFileName( hWnd,
       				  (LPSTR) FileName, sizeof(FileName),
      				  (LPSTR) "Save topology file",
       				  (LPSTR) "topology (*.TOP)\0*.TOP\0" ) )
     {
      if( !(nRc = WriteTop( FileName ) ) )
      {
       /* get the filename without the path						*/
       GetFileTitle( (LPSTR) FileName, (LPSTR) FileTitle, sizeof(FileTitle) );
       /* signal that there has not been any change yet			*/
       notsaved = 0;
       EnableMenuItem( hMenu, IDM_F_SAVE, MF_ENABLED );
       InvalidateRect( hWnd, NULL, TRUE );
      }
     }
     break;

    case IDM_F_NEW:
     if( notsaved )
      AskAboutSave( hWnd, hInst, FileName, MB_ICONQUESTION | MB_YESNO );
     for( i=0; i<MAX_STEP; i++ ) kinetu[i] = NOT;
     nloops = kinass = loopass = notsaved = 0;
     topname[0] = '\0';
     FileName[0] = '\0';
     ClearReactions();
     EnableMenuItem( hMenu, IDM_F_SAVE, MF_GRAYED );
     EnableMenuItem( hMenu, IDM_E_KINETICS, MF_GRAYED );
     EnableMenuItem( hMenu, IDM_E_METABOLITES, MF_GRAYED );
     EnableMenuItem( hMenu, IDM_E_LOOPS, MF_GRAYED );
     InvalidateRect( hWnd, NULL, TRUE );
     break;

    case IDM_E_REACTIONS:
     lpfnProc = MakeProcInstance( (FARPROC)EdReact, hInst);
     DialogBox( hInst, (LPSTR)"TOP_PARSER", hWnd, lpfnProc );
     FreeProcInstance( lpfnProc );
     hMenu = GetMenu( hWnd );
     if( nsteps>0 )
     {
      EnableMenuItem( hMenu, IDM_E_KINETICS , MF_ENABLED );
      EnableMenuItem( hMenu, IDM_E_METABOLITES , MF_ENABLED );
     }
     else
     {
      EnableMenuItem( hMenu, IDM_E_KINETICS , MF_GRAYED );
      EnableMenuItem( hMenu, IDM_E_METABOLITES , MF_GRAYED );
      EnableMenuItem( hMenu, IDM_E_LOOPS , MF_GRAYED );
     }
     InvalidateRect( hWnd, NULL, TRUE );
     break;

    case IDM_E_METABOLITES:
     lpfnProc = MakeProcInstance((FARPROC)EdMetnam, hInst);
     DialogBox(hInst, (LPSTR)"METNAM", hWnd, lpfnProc);
     FreeProcInstance(lpfnProc);
     InvalidateRect( hWnd, NULL, TRUE );
     break;

    case IDM_E_KINETICS:
     lpfnProc = MakeProcInstance((FARPROC) EdKinet, hInst);
     DialogBox(hInst, (LPSTR)"REACT_KINET", hWnd, lpfnProc);
     FreeProcInstance(lpfnProc);
     if( nloops > 0 )
      EnableMenuItem( hMenu, IDM_E_LOOPS , MF_ENABLED );
     InvalidateRect( hWnd, NULL, TRUE );
     break;

    case IDM_E_LOOPS:
     lpfnProc = MakeProcInstance((FARPROC) EdLoop, hInst);
     DialogBox(hInst, (LPSTR)"LOOP_ED", hWnd, lpfnProc);
     FreeProcInstance(lpfnProc);
     InvalidateRect( hWnd, NULL, TRUE );
     break;

    case IDM_E_NAME:
     lpfnProc = MakeProcInstance((FARPROC) EdName, hInst);
     DialogBox(hInst, (LPSTR)"TITLE_ED", hWnd, lpfnProc);
     FreeProcInstance(lpfnProc);
     InvalidateRect( hWnd, NULL, TRUE );
     break;

    case IDM_E_RATES:
     lpfnProc = MakeProcInstance((FARPROC) EdUdkt, hInst);
     DialogBox(hInst, (LPSTR)"ED_UDKT", hWnd, lpfnProc);
     FreeProcInstance(lpfnProc);
     InvalidateRect( hWnd, NULL, TRUE );
     break;

    default:
     return DefWindowProc(hWnd, Message, wParam, lParam);
   }
   break;        /* End of WM_COMMAND                             */

  default:
   return DefWindowProc(hWnd, Message, wParam, lParam);
 }
 return 0L;
}     /* End of WndProc                                         */


BOOL FAR PASCAL AboutBox(HWND hWndDlg, WORD Message, WORD wParam, LONG lParam)
{
 switch(Message)
 {
  case WM_INITDIALOG:
   SendDlgItemMessage( hWndDlg, IDSTAT_2, WM_SETTEXT, 0, (DWORD) (LPSTR) VERSION );
   break;

  case WM_CLOSE:
   /* Closing the Dialog behaves the same as Cancel               */
   PostMessage(hWndDlg, WM_COMMAND, IDCANCEL, 0L);
   break;

  case WM_COMMAND:
   if( wParam == IDOK || wParam == IDCANCEL )
   EndDialog(hWndDlg, FALSE);
   break;

  default:
   return FALSE;
 }
 return TRUE;
}


/************************************************************************/
/*                                                                      */
/* nCwRegisterClasses Function                                          */
/*                                                                      */
/* The following function registers all the classes of all the windows  */
/* associated with this application. The function returns an error code */
/* if unsuccessful, otherwise it returns 0.                             */
/*                                                                      */
/************************************************************************/

int nCwRegisterClasses(void)
{
 WNDCLASS   wndclass;    /* struct to define a window class             */

 memset(&wndclass, 0x00, sizeof(WNDCLASS));
 /* load WNDCLASS with window's characteristics                         */
 wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_BYTEALIGNWINDOW;
 wndclass.lpfnWndProc = WndProc;
 /* Extra storage for Class and Window objects                          */
 wndclass.cbClsExtra = 0;
 wndclass.cbWndExtra = 0;
 wndclass.hInstance = hInst;
 wndclass.hIcon = LoadIcon(hInst,"GWTOP");
 wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
 /* Create brush for erasing background                                 */
 wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
 wndclass.lpszMenuName = szAppName;   /* Menu Name is App Name */
 wndclass.lpszClassName = szAppName; /* Class Name is App Name */
 if(!RegisterClass(&wndclass))
   return -1;
 return(0);
} /* End of nCwRegisterClasses                                          */

/************************************************************************/
/*  cwCenter Function                                                   */
/*                                                                      */
/*  centers a window based on the client area of its parent             */
/*                                                                      */
/************************************************************************/

void cwCenter( HWND hWnd, int top)
{
 POINT      pt;
 RECT       swp;
 RECT       rParent;
 int        iwidth;
 int        iheight;

 /* get the rectangles for the parent and the child                     */
 GetWindowRect(hWnd, &swp);
 GetClientRect(hWndMain, &rParent);

 /* calculate the height and width for MoveWindow                       */
 iwidth = swp.right - swp.left;
 iheight = swp.bottom - swp.top;

 /* find the center point and convert to screen coordinates             */
 pt.x = (rParent.right - rParent.left) / 2;
 pt.y = (rParent.bottom - rParent.top) / 2;
 ClientToScreen(hWndMain, &pt);

 /* calculate the new x, y starting point                               */
 pt.x = pt.x - (iwidth / 2);
 pt.y = pt.y - (iheight / 2);

 /* top will adjust the window position, up or down                     */
 if(top)
   pt.y = pt.y + top;

 /* move the window                                                     */
 MoveWindow(hWnd, pt.x, pt.y, iwidth, iheight, FALSE);
}

/************************************************************************/
/*  CwUnRegisterClasses Function                                        */
/*                                                                      */
/*  Deletes any refrences to windows resources created for this         */
/*  application, frees memory, deletes instance, handles and does       */
/*  clean up prior to exiting the window                                */
/*                                                                      */
/************************************************************************/

void CwUnRegisterClasses(void)
{
/* WNDCLASS   wndclass;
 memset(&wndclass, 0x00, sizeof(WNDCLASS));*/

 UnregisterClass(szAppName, hInst);
}    /* End of CwUnRegisterClasses                                      */


void CleanUp( HWND hWnd, HANDLE hPrevInstance )
{
 if(!hPrevInstance) CwUnRegisterClasses();
 TidyGepasiVar();
}

⌨️ 快捷键说明

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