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

  1. //lRegen_FileHeading
  2. //lRegen_FileHeading
  3.  
  4.      /********************************************************************
  5.       *
  6.       *   Source File:  idodialo.c
  7.       *   Author:
  8.       *   Module:       Source for idoiface application
  9.       *   Program Desc:
  10.       *   Date:         Thu Mar 07 18:40:47 1996
  11.       *   Language:     ANSI C
  12.       *
  13.       ********************************************************************/
  14.  
  15. #include ".\idoiface.h"
  16.  
  17.  
  18. //lRegen_Variables
  19.  
  20. BOOL bMsg = FALSE;
  21.  
  22. //lRegen_Variables
  23.  
  24. LRESULT CALLBACK EXPORT fnidodialogWndProc(HWND, UINT, WPARAM, LPARAM);
  25.  
  26. int fnidodialog(HWND hClientWnd, UINT iData, void FAR *lpData)
  27. {
  28.    VIEW     hViewidodialog;
  29.    HWND     hWndidodialog;
  30.    //lRegen_BeginFunction
  31.    //lRegen_BeginFunction
  32.  
  33.  
  34.    //lRegen_InitDlg
  35.    //lRegen_InitDlg
  36.  
  37.    if(NULL == (hViewidodialog = vwCreateMDIChildView(hInstance,
  38.                    MAKEINTRESOURCE(idodialog),
  39.                    hClientWnd,
  40.                    fnidodialogWndProc,
  41.                    NULL)))
  42.         return FALSE;
  43.  
  44.  
  45.    //lRegen_InitView
  46.    //lRegen_InitView
  47.    if((hWndidodialog = vwShowMDIChildView(hViewidodialog)) == (HWND)-1)
  48.    {
  49.         MessageBox(NULL, "Unable to display view", "System Error",
  50.                    MB_SYSTEMMODAL | MB_ICONHAND | MB_OK);
  51.         return FALSE;
  52.    }
  53.  
  54.    //lRegen_TermView
  55.    //lRegen_TermView
  56.    return(TRUE);
  57. }
  58.  
  59. LRESULT CALLBACK EXPORT fnidodialogWndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
  60. {
  61. GETVIEW;
  62.    WORD CtlId;
  63.    WORD Notify;
  64.    HWND CtlWnd;
  65.    //lRegen_WindowProcVariables
  66.  
  67.    #define WUM_ADDITEMS WM_USER + 345
  68.  
  69.    //lRegen_WindowProcVariables
  70.  
  71.    switch(uMessage)
  72.    {
  73.        //lRegen_WndProc
  74.  
  75.  
  76.        case WM_USER + 24 :
  77.  
  78.           idoSetEditMode(GetDlgItem(hWnd, IDC_IDO), TRUE);
  79.           idoSetToolsPalette(GetDlgItem(hWnd, IDC_IDO), TRUE);
  80.  
  81.           break;
  82.  
  83.  
  84.        case WUM_ADDITEMS :
  85.  
  86.             /*
  87.              *   Enter IDo into edit mode.
  88.              */
  89.              idoSetEditMode(GetDlgItem(hWnd, IDC_IDO), TRUE);
  90.  
  91.             /*
  92.              *   Add an entity.
  93.              */
  94.             idoAddEntityFromClass(GetDlgItem(hWnd, IDC_IDO), 15, "15L", "Generic", "First Item", 0, 0, 0, 0);
  95.  
  96.             /*
  97.              *   Add an entity.
  98.              */
  99.             idoAddEntityFromClass(GetDlgItem(hWnd, IDC_IDO), 25, "25L", "Generic", "Second Item", 0, 0, 0, 0);
  100.  
  101.  
  102.             /*
  103.              *   Add a relation from First Item to Second Item.
  104.              */
  105.             idoAddRelationFromClass(GetDlgItem(hWnd, IDC_IDO), 35, "35L", "Is Related", "Is Related To",
  106.                              15, "15L",
  107.                              25, "25L");
  108.  
  109.             /*
  110.              *   Delete a relation from First Item to Second Item.
  111.              */
  112. //            idoDeleteRelation(GetDlgItem(hWnd, IDC_IDO), 35, "35L");
  113.  
  114.             /*
  115.              *   Terminate edit mode in IDO.
  116.              */
  117.             idoSetEditMode(GetDlgItem(hWnd, IDC_IDO), FALSE);
  118.  
  119.           break;  // end of WUM_ADDITEMS
  120.  
  121.        // *****************************************************************
  122.        // *****************************************************************
  123.  
  124.        case IDOM_NOTIFY_CLICK_RELATION :
  125.          /*
  126.           *   We are notified that a relation was clicked
  127.           */
  128.           IDO_n_ClickRelation(GetDlgItem(hWnd, IDC_IDO), lParam);
  129.           break;
  130.  
  131.        case IDOM_NOTIFY_CLICK_ENTITY :
  132.          /*
  133.           *   We are notified that an entity was clicked
  134.           */
  135.           IDO_n_ClickEntity(GetDlgItem(hWnd, IDC_IDO), lParam);
  136.           break;
  137.  
  138.        case IDOM_NOTIFY_CLICK_IDO :
  139.          /*
  140.           *   We are notified that the IDO was clicked
  141.           */
  142.           IDO_n_ClickIDO(GetDlgItem(hWnd, IDC_IDO), lParam);
  143.           break;
  144.  
  145.  
  146.        case IDOM_NOTIFY_BEFOREDISPLAYHELP :
  147.          /*
  148.           *   We are notified that the help file is to be displayed
  149.           */
  150. //          SendMessage(GetDlgItem(hWnd, IDC_IDO), IDOM_NOTIFYRESULT, 1, 1);
  151.           break;
  152.  
  153.        case IDOM_NOTIFY_BEFOREDISPLAYOPTIONSMENU :
  154.          /*
  155.           *   We are notified that the options menu is to be displayed
  156.           */
  157. //          SendMessage(GetDlgItem(hWnd, IDC_IDO), IDOM_NOTIFYRESULT, 1, 1);
  158.           break;
  159.  
  160.        case IDOM_NOTIFY_DISPLAYMANAGERULESBUTTON :
  161.           /*
  162.            * Hide rules button if rules are not being enforced.
  163.            */
  164.           if(!idoGetRulesEnforced(GetDlgItem(hWnd, IDC_IDO)))
  165.              idoCancelAction(GetDlgItem(hWnd, IDC_IDO));
  166.           break;
  167.  
  168.        case IDOM_NOTIFY_BEFOREDIAGRAMLOADED :
  169.        case IDOM_NOTIFY_DIAGRAMLOADED :
  170.        case IDOM_NOTIFY_BEFOREDIAGRAMSAVED :
  171.        case IDOM_NOTIFY_DIAGRAMSAVED :
  172.        case IDOM_NOTIFY_BEFOREDIAGRAMRESET :
  173.        case IDOM_NOTIFY_DIAGRAMRESET :
  174.        case IDOM_NOTIFY_BEFOREPALETTELOADED :
  175.        case IDOM_NOTIFY_PALETTELOADED :
  176.        case IDOM_NOTIFY_BEFOREPALETTESAVED :
  177.        case IDOM_NOTIFY_PALETTESAVED :
  178.        case IDOM_NOTIFY_BEFOREPALETTERESET :
  179.        case IDOM_NOTIFY_PALETTERESET :
  180.           IDO_n_FileIO(uMessage, (LPSTR)lParam);
  181.           break;
  182.  
  183.        case IDOM_NOTIFY_RELATIONDELETEREQUEST :
  184.          /*
  185.           *   We are notified that a relation is about to be deleted.
  186.           */
  187.        if(bMsg)
  188.           IDO_n_DeleteRelationRequest(GetActiveIDO(), wParam, (LPLINE_CLASS_STRUCT)(LPVOID)lParam);
  189.           break;
  190.  
  191.        case IDOM_NOTIFY_RELATIONDELETED :
  192.          /*
  193.           *   We are notified that a relation has been deleted.
  194.           */
  195.        if(bMsg)
  196.           IDO_n_DeletedRelation((LPLINE_CLASS_STRUCT)(LPVOID)lParam);
  197.           break;
  198.  
  199.        case IDOM_NOTIFY_RELATIONADDREQUEST :
  200.          /*
  201.           *   We are notified that a relation is about to be added.
  202.           */
  203.        if(bMsg)
  204.           IDO_n_AddRelationRequest(GetActiveIDO(), wParam, (LPLINE_CLASS_STRUCT)(LPVOID)lParam);
  205.           break;
  206.  
  207.        case IDOM_NOTIFY_RELATIONADDED :
  208.          /*
  209.           *   We are notified that a relation has been added.
  210.           */
  211.        if(bMsg)
  212.           IDO_n_AddedRelation((LPLINE_CLASS_STRUCT)(LPVOID)lParam);
  213.           break;
  214.  
  215.        case IDOM_NOTIFY_INVALIDEDITEVENT :
  216.          /*
  217.           *   We are notified that an attempt was made to alter the IDO
  218.           *   even though we are not in edit mode.
  219.           */
  220.           IDO_n_InvalidEditEvent();
  221.           break;
  222.  
  223.        case IDOM_NOTIFY_ENTITYADDREQUEST :
  224.          /*
  225.           *   We are notified that an entity is about to be added.
  226.           */
  227.        if(bMsg)
  228.           IDO_n_AddEntityRequest(GetActiveIDO(), wParam, (LPENTITY_CLASS_STRUCT)(LPVOID)lParam);
  229.           break;
  230.  
  231.        case IDOM_NOTIFY_ENTITYADDED :
  232.          /*
  233.           *   We are notified that an entity has been added.
  234.           */
  235.        if(bMsg)
  236.           IDO_n_AddedEntity((LPENTITY_CLASS_STRUCT)(LPVOID)lParam);
  237.           break;
  238.  
  239.        case IDOM_NOTIFY_ENTITYDELETEREQUEST :
  240.          /*
  241.           *   We are notified that an entity is about to be deleted.
  242.           */
  243.        if(bMsg)
  244.           IDO_n_DeleteEntityRequest(GetActiveIDO(), wParam, (LPENTITY_CLASS_STRUCT)(LPVOID)lParam);
  245.           break;
  246.  
  247.        case IDOM_NOTIFY_ENTITYDELETED :
  248.          /*
  249.           *   We are notified that an entity has been deleted.
  250.           */
  251.        if(bMsg)
  252.           IDO_n_DeletedEntity((LPENTITY_CLASS_STRUCT)(LPVOID)lParam);
  253.           break;
  254.  
  255.  
  256.        case WM_MDIACTIVATE :
  257.           if(wParam)
  258.           {
  259.              idoSetToolsPalette(GetDlgItem(hWnd, IDC_IDO), TRUE);
  260.           }
  261.           else
  262.           {
  263.              idoSetToolsPalette(GetDlgItem(hWnd, IDC_IDO), FALSE);
  264.           }
  265.           break;
  266.  
  267.        //lRegen_WndProc
  268.  
  269.        case WM_INITDIALOG :
  270.           //Regen_WM_INITDIALOG
  271.  
  272. //          PostMessage(hWnd, WUM_ADDITEMS, 0, 0L);
  273.  
  274.  
  275.           //Regen_WM_INITDIALOG
  276.           return TRUE;;
  277.  
  278.       case WM_CREATE :
  279.          //Regen_WM_CREATE
  280.  
  281.          /*
  282.           *   Create the control.  Save the window handle from CreateInstance.
  283.           */
  284.           gData.hWndIDO = IDO_CreateInstance(hWnd, gData.hApp, IDC_IDO,
  285.                                              5,5,35,35);
  286.  
  287.          /*
  288.           *   Display an error message if the control was not created.
  289.           */
  290.           if(!gData.hWndIDO)
  291.              MessageBox(hWnd, "Error creating pvIDO control.", "System Error", MB_OK | MB_ICONSTOP);
  292.  
  293.          PostMessage(hWnd, WM_USER + 24, 0, 0L);
  294.          //Regen_WM_CREATE
  295.          break;
  296.  
  297.       case WM_ERASEBKGND :
  298.          //Regen_WM_ERASEBKGND
  299.          return 0;
  300.          //Regen_WM_ERASEBKGND
  301.          break;
  302.  
  303.       case WM_SIZE :
  304.          //Regen_WM_SIZE
  305.          {
  306.             RECT rect;
  307.  
  308.  
  309.             /*
  310.              *   Reposition the control so it takes up the entire client area of the dialog.
  311.              */
  312.             GetClientRect(hWnd, &rect);
  313.             IDO_Move(GetDlgItem(hWnd, IDC_IDO), 0, 0, rect.right, rect.bottom);
  314.          }
  315.          //Regen_WM_SIZE
  316.          break;
  317.  
  318.          case WM_COMMAND :
  319.       #ifdef WIN32
  320.          CtlId  = LOWORD(wParam);
  321.          Notify = HIWORD(wParam);
  322.          CtlWnd = (HWND)lParam;
  323.       #else
  324.          CtlId  = wParam;
  325.          Notify = HIWORD(lParam);
  326.          CtlWnd = (HWND)LOWORD(lParam);
  327.       #endif
  328.             switch(CtlId)
  329.             {
  330.                //Regen_CustomCommand
  331.                case IDC_IDO :
  332.  
  333.                   switch(Notify)
  334.                   {
  335.  
  336.                      case IDON_SELCHANGE :
  337.                         ReadColor(); // color palette
  338.                         break;
  339.  
  340.                   }
  341.  
  342.                   break;
  343.                //Regen_CustomCommand
  344.             }
  345.             break;
  346.  
  347.       case WM_DESTROY :
  348.         //Regen_WM_Destroy
  349.         //Regen_WM_Destroy
  350.          break;
  351.    }
  352.    return DefMDIChildViewProc(hWnd, uMessage, wParam, lParam);
  353. }
  354.  
  355. //Regen_CustomCode
  356. //Regen_CustomCode
  357.