home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / componen / interact / demo / data.2 / samples / ansic / INTERACT / DELREL.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:  delrel.c                                          
  7.       *   Author:                                                         
  8.       *   Module:                                                         
  9.       *   Program Desc:                                                                                 
  10.       *   Date:         Mon Feb 19 13:11:40 1996                          
  11.       *   Language:     ANSI C
  12.       *
  13.       ********************************************************************/
  14.  
  15. #include ".\idoiface.h"
  16.  
  17.  
  18. //lRegen_Variables
  19. //lRegen_Variables
  20.  
  21. VIEW     hViewdelrel;
  22. HWND     hWnddelrel;
  23. LRESULT CALLBACK EXPORT fndelrelWndProc(HWND, UINT, WPARAM, LPARAM);
  24.  
  25. int fndelrel(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 == (hViewdelrel = vwCreateView(hInstance,
  36.                    MAKEINTRESOURCE(delrel),
  37.                    hParentWnd,
  38.                    (VIEWPROC)fndelrelWndProc,
  39.                    NULL)))
  40.    {
  41.          //lRegen_Create
  42.          //lRegen_Create
  43.         return FALSE;
  44.    }
  45.    //lRegen_InitView
  46.    //lRegen_InitView
  47.    if((ReturnCode = vwShowModalView(hViewdelrel)) == -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 fndelrelWndProc(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.             RELATION relation;
  79.             char szNum[20+1];
  80.  
  81.  
  82.             if(IsWindow(hIDO))
  83.             {
  84.                if(idoIterateRelationFirst(hIDO))
  85.                   while(idoIterateRelationNext(hIDO, &relation))
  86.                   {
  87.                      wsprintf(szNum, "%d", relation.id);
  88.                      SendDlgItemMessage(hWnd, IDC_RID, CB_ADDSTRING, 0, (LPARAM)(LPSTR)szNum);
  89.                      SendDlgItemMessage(hWnd, IDC_RNAME, CB_ADDSTRING, 0, (LPARAM)(LPSTR)relation.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 IDOK :
  111.                //Regen_IDOK
  112.                {
  113.                   RELATION relation;
  114.                   int index;
  115.                   char szNum[20+1];
  116.                   char szName[100+1];
  117.                   int  num;
  118.  
  119.  
  120.                   index = (int)SendDlgItemMessage(hWnd, IDC_RNAME, CB_GETCURSEL, 0, 0L);
  121.                   SendDlgItemMessage(hWnd, IDC_RNAME, CB_GETLBTEXT, index, (LPARAM)(LPSTR)szName);
  122.                   index = (int)SendDlgItemMessage(hWnd, IDC_RID, CB_GETCURSEL, 0, 0L);
  123.                   SendDlgItemMessage(hWnd, IDC_RID, CB_GETLBTEXT, index, (LPARAM)(LPSTR)szNum);
  124.                   num = atoi(szNum);
  125.  
  126.  
  127.                   /*
  128.                    *   Delete a relation.
  129.                    */
  130.                   idoGetRelation(GetActiveIDO(), num, szName, &relation);
  131.                   idoDeleteRelation(GetActiveIDO(), &relation);
  132.                }
  133.                //Regen_IDOK
  134.                break; 
  135.  
  136.             case IDCANCEL :
  137.                //Regen_IDCANCEL
  138.                //Regen_IDCANCEL
  139.                break; 
  140.  
  141.             case IDC_RNAME :
  142.                   switch(Notify)
  143.                   {
  144.                      case CBN_SELCHANGE :
  145.                         //Regen_IDC_RNAME_CBN_SELCHANGE
  146.                         {
  147.                            int index;
  148.  
  149.                            index = (int)SendDlgItemMessage(hWnd, IDC_RNAME, CB_GETCURSEL, 0, 0L);
  150.                            SendDlgItemMessage(hWnd, IDC_RID, CB_SETCURSEL, index, 0L);
  151.                         }
  152.                         //Regen_IDC_RNAME_CBN_SELCHANGE
  153.                         break;
  154.  
  155.                   }
  156.                   break;
  157.             case IDC_RID :
  158.                   switch(Notify)
  159.                   {
  160.                      case CBN_SELCHANGE :
  161.                         //Regen_IDC_RID_CBN_SELCHANGE
  162.                         {
  163.                            int index;
  164.  
  165.                            index = (int)SendDlgItemMessage(hWnd, IDC_RID, CB_GETCURSEL, 0, 0L);
  166.                            SendDlgItemMessage(hWnd, IDC_RNAME, CB_SETCURSEL, index, 0L);
  167.                         }
  168.                         //Regen_IDC_RID_CBN_SELCHANGE
  169.                         break;
  170.  
  171.                   }
  172.                   break;
  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.