home *** CD-ROM | disk | FTP | other *** search
/ CICA 1994 September / CICA_Shareware_for_Windows_Walnut_Creek_September_1994.iso / win3 / programr / atre27.exe / ATREE_27 / MOSQWIN / MOSQWIN.C < prev    next >
C/C++ Source or Header  |  1992-08-01  |  7KB  |  186 lines

  1. /*****************************************************************************
  2.  ****                                                                     ****
  3.  **** mosqwin.c                                                           ****
  4.  ****                                                                     ****
  5.  **** atree release 2.7 for Windows                                       ****
  6.  **** Adaptive Logic Network (ALN) simulation program.                    ****
  7.  **** Copyright (C) A. Dwelly, R. Manderscheid, M. Thomas, W.W. Armstrong ****
  8.  ****               1991, 1992                                            ****
  9.  **** License:                                                            ****
  10.  **** A royalty-free license is granted for the use of this software for  ****
  11.  **** NON_COMMERCIAL PURPOSES ONLY. The software may be copied and/or     ****
  12.  **** modified provided this notice appears in its entirety and unchanged ****
  13.  **** in all derived source programs.  Persons modifying the code are     ****
  14.  **** requested to state the date, the changes made and who made them     ****
  15.  **** in the modification history.                                        ****
  16.  ****                                                                     ****
  17.  **** Patent License:                                                     ****
  18.  **** The use of a digital circuit which transmits a signal indicating    ****
  19.  **** heuristic responsibility is protected by U. S. Patent 3,934,231     ****
  20.  **** and others assigned to Dendronic Decisions Limited of Edmonton,     ****
  21.  **** W. W. Armstrong, President.  A royalty-free license is granted      ****
  22.  **** by the company to use this patent for NON_COMMERCIAL PURPOSES to    ****
  23.  **** adapt logic trees using this program and its modifications.         ****
  24.  ****                                                                     ****
  25.  **** Limited Warranty:                                                   ****
  26.  **** This software is provided "as is" without warranty of any kind,     ****
  27.  **** either expressed or implied, including, but not limited to, the     ****
  28.  **** implied warrantees of merchantability and fitness for a particular  ****
  29.  **** purpose.  The entire risk as to the quality and performance of the  ****
  30.  **** program is with the user.  Neither the authors, nor the             ****
  31.  **** University of Alberta, its officers, agents, servants or employees  ****
  32.  **** shall be liable or responsible in any way for any damage to         ****
  33.  **** property or direct personal or consequential injury of any nature   ****
  34.  **** whatsoever that may be suffered or sustained by any licensee, user  ****
  35.  **** or any other party as a consequence of the use or disposition of    ****
  36.  **** this software.                                                      ****
  37.  ****                                                                     ****
  38.  **** Modification history:                                               ****
  39.  ****                                                                     ****
  40.  **** 91.05.20 Initial Implementation, M. Thomas                          ****
  41.  **** 91.07.17 atree v2.0 for Windows, M. Thomas                          ****
  42.  **** 92.04.27 atree v2.5 for Windows, M. Thomas                          ****
  43.  **** 92.03.07 Release 2.6, Monroe Thomas                                 ****
  44.  **** 92.01.08 Release 2.7, Monroe Thomas                                 ****
  45.  ****                                                                     ****
  46.  *****************************************************************************/
  47.  
  48. /*****************************
  49. * Windows Support File for
  50. * Mosquito.C
  51. ******************************/
  52.  
  53. #include <windows.h>
  54. #include "atree.h"
  55. #include "mosqwin.h"
  56.  
  57. extern int NEAR PASCAL main(HWND, HANDLE);
  58. long FAR PASCAL WndProc (HWND, WORD, WORD, LONG);
  59. BOOL FAR PASCAL AboutDlgProc (HWND, WORD, WORD, LONG);
  60.  
  61. extern BOOL quit_flag;
  62.  
  63. HANDLE hInst;
  64. FARPROC lpitAbout;
  65.  
  66. #pragma argsused
  67.  
  68. int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance,
  69.                    LPSTR lpszCmdLine, int nCmdShow)
  70.  
  71. {
  72.     static char szAppName[] = "MOSQUITO";
  73.     HWND hwnd;
  74.     MSG msg;
  75.     WNDCLASS wndclass;
  76.  
  77.     if (!hPrevInstance)
  78.     {
  79.         wndclass.style          = CS_HREDRAW | CS_VREDRAW;
  80.         wndclass.lpfnWndProc    = (long (FAR PASCAL*)()) WndProc;
  81.         wndclass.cbClsExtra     = 0;
  82.         wndclass.cbWndExtra     = 0;
  83.         wndclass.hInstance      = hInstance;
  84.         wndclass.hIcon          = LoadIcon(hInstance, "mosqico");
  85.         wndclass.hCursor        = LoadCursor(hInstance, "mosqcur");
  86.         wndclass.hbrBackground  = GetStockObject(WHITE_BRUSH);
  87.         wndclass.lpszMenuName   = "MENU_RESOURCE";
  88.         wndclass.lpszClassName  = szAppName;
  89.  
  90.         RegisterClass(&wndclass);
  91.     }
  92.  
  93.     hInst = hInstance;
  94.  
  95.     hwnd = CreateWindow(szAppName,                      /* Class */
  96.                          "Mosquito",                    /* Title */
  97.                          WS_OVERLAPPEDWINDOW,           /* Style */
  98.                          CW_USEDEFAULT, CW_USEDEFAULT,  /* x, y */
  99.                          240,180,                       /* xsize, ysize */
  100.                          NULL,                          /* parent */
  101.                          NULL,                          /* class menu */
  102.                          hInstance,                     /* creator */
  103.                          NULL);                         /* Params */
  104.  
  105.  
  106.     ShowWindow(hwnd, nCmdShow);
  107.     UpdateWindow(hwnd);
  108.  
  109.     lpitAbout = MakeProcInstance((FARPROC)AboutDlgProc, hInst);
  110.  
  111.     while (GetMessage(&msg, NULL,0,0))
  112.     {
  113.         TranslateMessage(&msg);
  114.         DispatchMessage(&msg);
  115.     }
  116.  
  117.     FreeProcInstance(lpitAbout);
  118.     return msg.wParam;
  119. }
  120.  
  121.  
  122. long FAR PASCAL WndProc (HWND hwnd, WORD message, WORD wParam, LONG lParam)
  123. {
  124.     static HMENU hMenu;
  125.  
  126.     switch (message)
  127.     {
  128.         case WM_COMMAND:
  129.             switch (wParam)
  130.             {
  131.                 case IDM_HELP:
  132.                     WinHelp(hwnd, "atree.hlp", HELP_CONTEXT, 20);
  133.                     break;
  134.  
  135.                 case IDM_EXIT:
  136.                     DestroyWindow(hwnd);
  137.                     break;
  138.  
  139.                 case IDM_RUN:
  140.                     hMenu = GetMenu(hwnd);
  141.                     EnableMenuItem(hMenu, IDM_RUN, MF_GRAYED);
  142.                     DrawMenuBar(hwnd);
  143.  
  144.                     if (!main(hwnd, hInst))
  145.                     {
  146.                         MessageBeep(0);
  147.                         MessageBox(hwnd,"Could not run Mosquito!", "Multiplexor", MB_OK);
  148.                     }
  149.  
  150.                     EnableMenuItem(hMenu, IDM_RUN, MF_ENABLED);
  151.                     DrawMenuBar(hwnd);
  152.                     break;
  153.  
  154.                 case IDM_ABOUT:
  155.                     DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUT), hwnd,
  156.                               lpitAbout);
  157.                     break;
  158.             }
  159.             break;
  160.  
  161.         case WM_DESTROY:
  162.             atree_quit();
  163.             quit_flag = TRUE;
  164.             PostQuitMessage(0);
  165.             break;
  166.  
  167.         default:
  168.             return DefWindowProc(hwnd,message,wParam,lParam);
  169.     }
  170.     return 0L;
  171. }
  172.  
  173. #pragma argsused
  174.  
  175. BOOL FAR PASCAL AboutDlgProc (HWND hdlg, WORD message, WORD wParam, LONG lParam)
  176. {
  177.     switch (message)
  178.     {
  179.         case WM_COMMAND:
  180.             EndDialog(hdlg, TRUE);
  181.             return TRUE;
  182.         default:
  183.             return FALSE;
  184.    }
  185. }
  186.