home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / componen / interact / demo / data.2 / samples / ansic / TRAVEL / TRAVEL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-05  |  7.5 KB  |  286 lines

  1. //lRegen_FileHeading
  2. //lRegen_FileHeading
  3.  
  4.      /********************************************************************
  5.       *
  6.       *   Source File:  travel.c                                          
  7.       *   Author:       RC                                                
  8.       *   Module:       Source for travel application                     
  9.       *   Program Desc:                                                                                 
  10.       *   Date:         Fri Apr 05 12:07:04 1996                          
  11.       *   Language:     ANSI C
  12.       *
  13.       ********************************************************************/
  14.  
  15. #include ".\travel.h"
  16.  
  17. #include "ctl3d.h"
  18. //lRegen_Variables
  19.  
  20. HWND hIDO;
  21. LPLINE_CLASS_STRUCT lpLine;
  22.  
  23. static char miles[15+1];
  24. static char city[15+1];
  25.  
  26. //lRegen_Variables
  27.  
  28. HINSTANCE   hInstance;
  29. char        szAppName[30];
  30.  
  31. BOOL CALLBACK EXPORT MainWndProc(HWND, UINT, WPARAM, LPARAM);
  32. HACCEL   hAccel;
  33.  
  34. int PASCAL WinMain(HINSTANCE hInst,             // Application Instance Handle
  35.                    HINSTANCE hPrevInstance,     // Previous Instance Handle
  36.                    LPSTR  lpszCmdLine,          // Pointer to Command Line
  37.                    int    nCmdShow)             // Show Window Option
  38. {
  39.    //lRegen_BeginFunction
  40.    //lRegen_BeginFunction
  41.  
  42.    MSG      msg;
  43.    HWND     hWndMain;
  44.  
  45.    WNDCLASS wndclass;
  46.    hInstance = hInst;
  47.    lstrcpy(szAppName, "travel");
  48.    hAccel = LoadAccelerators(hInstance, "travel");
  49.  
  50.  
  51.    Ctl3dRegister(hInstance);
  52.    Ctl3dAutoSubclass(hInstance);
  53.    //lRegen_InitView
  54.    //lRegen_InitView
  55.  
  56.    if(NULL == (hWndMain = CreateDialog(hInstance,
  57.                    MAKEINTRESOURCE(master),
  58.                    NULL,
  59.                    MainWndProc)))
  60.    {
  61.         MessageBox(NULL, "Unable to display main dialog", "System Error", MB_OK);
  62.         return FALSE;
  63.    }
  64.  
  65.    SetMenu(hWndMain, LoadMenu(hInstance, "travel"));
  66.  
  67.    //lRegen_MainWnd
  68.    //lRegen_MainWnd
  69.  
  70.    ShowWindow(hWndMain, nCmdShow);
  71.    UpdateWindow(hWndMain);
  72.  
  73.    //lRegen_MainEnd
  74.    //lRegen_MainEnd
  75.  
  76.    while(GetMessage(&msg, NULL, 0, 0))
  77.          if(!IsDialogMessage(hWndMain, &msg))
  78.          if(!TranslateAccelerator(hWndMain, hAccel, &msg))
  79.           {
  80.              TranslateMessage(&msg);
  81.              DispatchMessage(&msg);
  82.           }
  83.  
  84.    //Regen_AppTerm
  85.    //Regen_AppTerm
  86.  
  87.    return msg.wParam;
  88. }
  89.  
  90. BOOL CALLBACK EXPORT MainWndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
  91. {
  92.    WORD CtlId;
  93.    WORD Notify;
  94.    HWND CtlWnd;
  95.  
  96.    //lRegen_WindowProcVariables
  97.    //lRegen_WindowProcVariables
  98.  
  99.    switch(uMessage)
  100.    {
  101.       //lRegen_WndProc
  102.  
  103.       case IDOM_NOTIFY_BEFOREHIDETOOLSPALETTE :
  104.          idoCancelAction(GetDlgItem(hWnd, IDC_IDO));
  105.          break;
  106.  
  107.  
  108.       case IDOM_NOTIFY_RELATIONADDREQUEST :
  109.  
  110.          lpLine = (LPLINE_CLASS_STRUCT)lParam;
  111.          // save the distance of the new relation in static var: miles
  112.          if(!fnnewpath(hWnd, 0, (LPVOID)(LPSTR)miles))
  113.          {
  114.             // the user has canceled the addition of the new relation
  115.             idoCancelAction(GetDlgItem(hWnd, IDC_IDO));
  116.          }
  117.  
  118.          break;
  119.  
  120.  
  121.       case IDOM_NOTIFY_RELATIONADDED :
  122.          {
  123.  
  124.             LPRELATION lpRelation;
  125.  
  126.  
  127.             lpRelation = (LPRELATION)lParam;
  128.             idoRelationSetText(lpRelation, miles);
  129.             idoRelationRepaint(lpRelation);
  130.  
  131.          }
  132.          break;
  133.  
  134.  
  135.       case IDOM_NOTIFY_ENTITYADDREQUEST :
  136.          {
  137.  
  138.             LPENTITY lpEntity;
  139.  
  140.  
  141.             if(!fnnewcity(hWnd, 0, (LPVOID)(LPSTR)city))
  142.             {
  143.                // the user has canceled the addition of the new city
  144.                idoCancelAction(GetDlgItem(hWnd, IDC_IDO));
  145.                return TRUE;
  146.             }
  147.  
  148.             lpEntity = (LPENTITY)lParam;
  149.             lstrcpy(lpEntity->name, city);
  150.             lstrcpy(lpEntity->text, city);
  151.  
  152.          }
  153.          break;
  154.  
  155.       //lRegen_WndProc
  156.  
  157.       case WM_INITDIALOG :
  158.          //Regen_WM_INITDIALOG
  159.          {
  160.             long lStyle = WS_VISIBLE | WS_CHILD | WS_HSCROLL | WS_VSCROLL | WS_TABSTOP;
  161.             RECT rect;
  162.  
  163.             GetClientRect(hWnd, &rect);
  164.  
  165. #ifdef WIN32
  166.             hIDO = CreateWindow("pvIDO32", "", lStyle,
  167.                                  0, 0, rect.right, rect.bottom,
  168.                                  hWnd, (HMENU)IDC_IDO, hInstance, NULL);
  169. #else
  170.             hIDO = CreateWindow("pvIDO", "", lStyle,
  171.                                  0, 0, rect.right, rect.bottom,
  172.                                  hWnd, (HMENU)IDC_IDO, hInstance, NULL);
  173. #endif
  174.  
  175.             idoSetEditMode(hIDO, TRUE);
  176.             idoSetToolsPalette(hIDO, TRUE);
  177.             idoSetRulesEnforced(hIDO, FALSE);
  178.             idoReadDiagram(hIDO, "travel.ido");
  179.  
  180.          }
  181.          //Regen_WM_INITDIALOG
  182.          return TRUE;
  183.  
  184.       case WM_SIZE :
  185.          //Regen_WM_SIZE
  186.          {
  187.             RECT rect;
  188.  
  189.             GetClientRect(hWnd, &rect);
  190.  
  191.             SetWindowPos(GetDlgItem(hWnd, IDC_IDO), NULL, 0, 0,
  192.                          rect.right, rect.bottom,
  193.                          SWP_NOZORDER);
  194.          }
  195.          //Regen_WM_SIZE
  196.          break;
  197.  
  198.       case WM_COMMAND :
  199.       #ifdef WIN32
  200.          CtlId  = LOWORD(wParam);
  201.          Notify = HIWORD(wParam);
  202.          CtlWnd = (HWND)lParam;
  203.       #else
  204.          CtlId  = wParam;
  205.          Notify = HIWORD(lParam);
  206.          CtlWnd = (HWND)LOWORD(lParam);
  207.       #endif
  208.          if(!CtlWnd)
  209.          {                             // Process Menu Commands
  210.             //Regen_CustomMenuItems
  211.             //Regen_CustomMenuItems
  212.             switch(CtlId)  // Determine which Menu ID
  213.             {
  214.             case IDM_SHORTESTDISTANCE :
  215.                //lRegen_Start_IDM_SHORTESTDISTANCE
  216.                //lRegen_Start_IDM_SHORTESTDISTANCE
  217.                if(fndistance(hWnd, 0, NULL))
  218.                {
  219.                }
  220.                //Regen_End_IDM_SHORTESTDISTANCE
  221.                //Regen_End_IDM_SHORTESTDISTANCE
  222.                break;
  223.             case IDM_FILE_PRINT :
  224.                //lRegen_Start_IDM_FILE_PRINT
  225.                idoPrintDiagram(GetDlgItem(hWnd, IDC_IDO));
  226.                //lRegen_Start_IDM_FILE_PRINT
  227.                //Regen_End_IDM_FILE_PRINT
  228.                //Regen_End_IDM_FILE_PRINT
  229.                break;
  230.             case IDM_APP_EXIT :
  231.                //lRegen_Start_IDM_APP_EXIT
  232.                //lRegen_Start_IDM_APP_EXIT
  233.                //Regen_End_IDM_APP_EXIT
  234.                //Regen_End_IDM_APP_EXIT
  235.                SendMessage (hWnd, WM_CLOSE, 0, 0L);
  236.                return 0;
  237.  
  238.             case IDM_ABOUT :
  239.                //lRegen_Start_IDM_ABOUT
  240.                //lRegen_Start_IDM_ABOUT
  241.                if(fnAbouttravel(hWnd, 0, NULL))
  242.                {
  243.                }
  244.                //Regen_End_IDM_ABOUT
  245.                //Regen_End_IDM_ABOUT
  246.                break;
  247.             }
  248.          }
  249.          else
  250.          {
  251.             //Regen_CustomCommand
  252.             //Regen_CustomCommand
  253.  
  254.             switch(CtlId)
  255.             {
  256.             }
  257.          }
  258.          break;
  259.  
  260.       case WM_CLOSE :
  261.  
  262.          //lRegen_WM_Close
  263.          //lRegen_WM_Close
  264.  
  265.          DestroyWindow(hWnd);
  266.  
  267.          return TRUE;
  268.  
  269.       case WM_DESTROY :
  270.  
  271.          //lRegen_WM_DESTROY
  272.          DestroyWindow(GetDlgItem(hWnd, IDC_IDO));
  273.          //lRegen_WM_DESTROY
  274.  
  275.          PostQuitMessage(0);
  276.          break;
  277.  
  278.       default :
  279.          return FALSE;
  280.    }
  281.    return FALSE;
  282. }
  283.  
  284. //Regen_CustomCode
  285. //Regen_CustomCode
  286.