home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / componen / interact / demo / data.2 / samples / ansic / INTERACT / DELETEEN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-19  |  5.6 KB  |  188 lines

  1. //lRegen_FileHeading
  2. //lRegen_FileHeading
  3.  
  4.      /********************************************************************
  5.       *
  6.       *   Source File:  deleteen.c                                        
  7.       *   Author:                                                         
  8.       *   Module:                                                         
  9.       *   Program Desc:                                                                                 
  10.       *   Date:         Mon Feb 19 13:11:38 1996                          
  11.       *   Language:     ANSI C
  12.       *
  13.       ********************************************************************/
  14.  
  15. #include ".\idoiface.h"
  16.  
  17.  
  18. //lRegen_Variables
  19. //lRegen_Variables
  20.  
  21. VIEW     hViewdeleteentity;
  22. HWND     hWnddeleteentity;
  23. LRESULT CALLBACK EXPORT fndeleteentityWndProc(HWND, UINT, WPARAM, LPARAM);
  24.  
  25. int fndeleteentity(HWND hParentWnd, UINT iData, void FAR *lpData)
  26. {
  27.    int   ReturnCode;
  28.  
  29.    //lRegen_BeginFunction
  30.    //lRegen_BeginFunction
  31.  
  32.    //lRegen_InitDlg
  33.    //lRegen_InitDlg
  34.  
  35.    if(NULL == (hViewdeleteentity = vwCreateView(hInstance,
  36.                    MAKEINTRESOURCE(deleteentity),
  37.                    hParentWnd,
  38.                    (VIEWPROC)fndeleteentityWndProc,
  39.                    NULL)))
  40.    {
  41.          //lRegen_Create
  42.          //lRegen_Create
  43.         return FALSE;
  44.    }
  45.    //lRegen_InitView
  46.    //lRegen_InitView
  47.    if((ReturnCode = vwShowModalView(hViewdeleteentity)) == -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(ReturnCode);
  57. }
  58.  
  59. LRESULT CALLBACK EXPORT fndeleteentityWndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
  60. {
  61. GETVIEW;
  62.    WORD CtlId;
  63.    WORD Notify;
  64.    HWND CtlWnd;
  65.  
  66.    //lRegen_WindowProcVariables
  67.    //lRegen_WindowProcVariables
  68.  
  69.    switch(uMessage)
  70.    {
  71.       //lRegen_WndProc
  72.       //lRegen_WndProc
  73.  
  74.       case WM_INITDIALOG :
  75.          //lRegen_InitDialogBegin
  76.          {
  77.             HWND hIDO = GetActiveIDO();
  78.             ENTITY entity;
  79.             char szNum[20+1];
  80.  
  81.  
  82.             if(IsWindow(hIDO))
  83.             {
  84.                if(idoIterateEntityFirst(hIDO))
  85.                   while(idoIterateEntityNext(hIDO, &entity))
  86.                   {
  87.                      wsprintf(szNum, "%d", entity.id);
  88.                      SendDlgItemMessage(hWnd, IDC_EID, CB_ADDSTRING, 0, (LPARAM)(LPSTR)szNum);
  89.                      SendDlgItemMessage(hWnd, IDC_ENAME, CB_ADDSTRING, 0, (LPARAM)(LPSTR)entity.name);
  90.                   }
  91.             }
  92.          }
  93.          //lRegen_InitDialogBegin
  94.          //Regen_WM_InitDialog
  95.          //Regen_WM_InitDialog
  96.          return TRUE;
  97.  
  98.       case WM_COMMAND :
  99.       #ifdef WIN32
  100.          CtlId  = LOWORD(wParam);
  101.          Notify = HIWORD(wParam);
  102.          CtlWnd = (HWND)lParam;
  103.       #else
  104.          CtlId  = wParam;
  105.          Notify = HIWORD(lParam);
  106.          CtlWnd = (HWND)LOWORD(lParam);
  107.       #endif
  108.          switch(CtlId)
  109.          {
  110.             case IDC_ENAME :
  111.                   switch(Notify)
  112.                   {
  113.                      case CBN_SELCHANGE :
  114.                         //Regen_IDC_ENAME_CBN_SELCHANGE
  115.                         {
  116.                            int index;
  117.  
  118.                            index = (int)SendDlgItemMessage(hWnd, IDC_ENAME, CB_GETCURSEL, 0, 0L);
  119.                            SendDlgItemMessage(hWnd, IDC_EID, CB_SETCURSEL, index, 0L);
  120.                         }
  121.                         //Regen_IDC_ENAME_CBN_SELCHANGE
  122.                         break;
  123.  
  124.                   }
  125.                   break;
  126.             case IDC_EID :
  127.                   switch(Notify)
  128.                   {
  129.                      case CBN_SELCHANGE :
  130.                         //Regen_IDC_EID_CBN_SELCHANGE
  131.                         {
  132.                            int index;
  133.  
  134.                            index = (int)SendDlgItemMessage(hWnd, IDC_EID, CB_GETCURSEL, 0, 0L);
  135.                            SendDlgItemMessage(hWnd, IDC_ENAME, CB_SETCURSEL, index, 0L);
  136.                         }
  137.                         //Regen_IDC_EID_CBN_SELCHANGE
  138.                         break;
  139.  
  140.                   }
  141.                   break;
  142.             case IDOK :
  143.                //Regen_IDOK
  144.                {
  145.                   ENTITY entity;
  146.                   int index;
  147.                   char szNum[20+1];
  148.                   char szName[100+1];
  149.                   int  num;
  150.  
  151.  
  152.                   index = (int)SendDlgItemMessage(hWnd, IDC_ENAME, CB_GETCURSEL, 0, 0L);
  153.                   SendDlgItemMessage(hWnd, IDC_ENAME, CB_GETLBTEXT, index, (LPARAM)(LPSTR)szName);
  154.                   index = (int)SendDlgItemMessage(hWnd, IDC_EID, CB_GETCURSEL, 0, 0L);
  155.                   SendDlgItemMessage(hWnd, IDC_EID, CB_GETLBTEXT, index, (LPARAM)(LPSTR)szNum);
  156.                   num = atoi(szNum);
  157.  
  158.  
  159.                   /*
  160.                    *   Delete an entity.
  161.                    */
  162.                   idoGetEntity(GetActiveIDO(), num, szName, &entity);
  163.                   idoDeleteEntity(GetActiveIDO(), &entity);
  164.                }
  165.                //Regen_IDOK
  166.                break; 
  167.  
  168.             case IDCANCEL :
  169.                //Regen_IDCANCEL
  170.                //Regen_IDCANCEL
  171.                break; 
  172.  
  173.             //lRegen_CustomCommand
  174.             //lRegen_CustomCommand
  175.             }
  176.             break;
  177.  
  178.       case WM_DESTROY :
  179.         //Regen_WM_Destroy
  180.         //Regen_WM_Destroy
  181.          break;
  182.    }
  183.    return DefViewProc(hWnd, uMessage, wParam, lParam);
  184. }
  185.  
  186. //Regen_CustomCode
  187. //Regen_CustomCode
  188.