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

  1. //lRegen_FileHeading
  2. //lRegen_FileHeading
  3.  
  4.      /********************************************************************
  5.       *
  6.       *   Source File:  addentit.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. typedef struct tagADDENTITYDATA
  22. {
  23.    char            UNAME[80 + 1];
  24.    long            UID;
  25.    char            U_TEXT[80 + 1];
  26.    char            szUCLASSSelection[80];
  27.    CBARRAY         UCLASS;
  28. }ADDENTITYDATA, FAR* LPADDENTITYDATA;
  29.  
  30. VIEW     hViewaddentity;
  31. HWND     hWndaddentity;
  32. // Data Pointer for Dialog control data elements
  33. HGLOBAL haddentityData = NULL;
  34. LPADDENTITYDATA lpaddentityData = NULL;
  35. LRESULT CALLBACK EXPORT fnaddentityWndProc(HWND, UINT, WPARAM, LPARAM);
  36.  
  37. int fnaddentity(HWND hParentWnd, UINT iData, void FAR *lpData)
  38. {
  39.    int   ReturnCode;
  40.  
  41.    //lRegen_BeginFunction
  42.    //lRegen_BeginFunction
  43.  
  44.    // Associate Data elements with view
  45.    if(NULL == lpaddentityData)
  46.    {
  47.       haddentityData = GlobalAlloc(GHND, sizeof(ADDENTITYDATA));
  48.       if(NULL == haddentityData)
  49.          return FALSE;
  50.       lpaddentityData = (LPADDENTITYDATA)GlobalLock(haddentityData);
  51.    }
  52.    //lRegen_InitDlg
  53.    //lRegen_InitDlg
  54.  
  55.    if(NULL == (hViewaddentity = vwCreateView(hInstance,
  56.                    MAKEINTRESOURCE(addentity),
  57.                    hParentWnd,
  58.                    (VIEWPROC)fnaddentityWndProc,
  59.                    NULL)))
  60.    {
  61.          //lRegen_Create
  62.          //lRegen_Create
  63.         return FALSE;
  64.    }
  65.    vwSetFieldVar(hViewaddentity, IDC_UNAME, lpaddentityData->UNAME);
  66.    vwSetFieldVar(hViewaddentity, IDC_UID, &lpaddentityData->UID);
  67.    vwSetFieldVar(hViewaddentity, IDC_TEXT, lpaddentityData->U_TEXT);
  68.    lpaddentityData->UCLASS.SelectedString = lpaddentityData->szUCLASSSelection;
  69.    vwSetFieldVar(hViewaddentity, IDC_UCLASS, &lpaddentityData->UCLASS);
  70.    //lRegen_InitView
  71.    //lRegen_InitView
  72.    if((ReturnCode = vwShowModalView(hViewaddentity)) == -1)
  73.    {
  74.         MessageBox(NULL, "Unable to display view", "System Error",
  75.                    MB_SYSTEMMODAL | MB_ICONHAND | MB_OK);
  76.         return FALSE;
  77.    }
  78.  
  79.    //lRegen_TermView
  80.    //lRegen_TermView
  81.    // Free Data Pointer for Dialog control data elements
  82.    if(NULL != haddentityData)
  83.    {
  84.       GlobalUnlock(haddentityData);
  85.       GlobalFree(haddentityData);
  86.       haddentityData  = 0;
  87.       lpaddentityData = NULL;
  88.    }
  89.    return(ReturnCode);
  90. }
  91.  
  92. LRESULT CALLBACK EXPORT fnaddentityWndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
  93. {
  94. GETVIEW;
  95.    WORD CtlId;
  96.    WORD Notify;
  97.    HWND CtlWnd;
  98.  
  99.    //lRegen_WindowProcVariables
  100.  
  101.    char szClassName[100+1];
  102.  
  103.    //lRegen_WindowProcVariables
  104.  
  105.    switch(uMessage)
  106.    {
  107.       //lRegen_WndProc
  108.       //lRegen_WndProc
  109.  
  110.       case WM_INITDIALOG :
  111.          //lRegen_InitDialogBegin
  112.          {
  113.             HWND hIDO = GetActiveIDO();
  114.  
  115.  
  116.             if(IsWindow(hIDO))
  117.             {
  118.                if(idoIterateEntityClassFirst(hIDO))
  119.                   while(idoIterateEntityClassNext(hIDO, szClassName))
  120.                      SendDlgItemMessage(hWnd, IDC_UCLASS, CB_ADDSTRING, 0, (LPARAM)(LPSTR)szClassName);
  121.             }
  122.          }
  123.          //lRegen_InitDialogBegin
  124.          //Regen_WM_InitDialog
  125.          //Regen_WM_InitDialog
  126.          return TRUE;
  127.  
  128.       case WM_COMMAND :
  129.       #ifdef WIN32
  130.          CtlId  = LOWORD(wParam);
  131.          Notify = HIWORD(wParam);
  132.          CtlWnd = (HWND)lParam;
  133.       #else
  134.          CtlId  = wParam;
  135.          Notify = HIWORD(lParam);
  136.          CtlWnd = (HWND)LOWORD(lParam);
  137.       #endif
  138.          switch(CtlId)
  139.          {
  140.             case IDC_UNAME :
  141.                //Regen_IDC_UNAME
  142.                //Regen_IDC_UNAME
  143.                break; 
  144.  
  145.             case IDC_TEXT :
  146.                //Regen_IDC_TEXT
  147.                //Regen_IDC_TEXT
  148.                break; 
  149.  
  150.             case IDOK :
  151.                //Regen_IDOK
  152.  
  153.                vwUpdateApp(View);
  154.  
  155.                /*
  156.                 *   Add an entity.
  157.                 */
  158.                idoAddEntityFromClass(GetActiveIDO(),
  159.                                      lpaddentityData->UID,
  160.                                      lpaddentityData->UNAME,
  161.                                      lpaddentityData->szUCLASSSelection,
  162.                                      lpaddentityData->U_TEXT,
  163.                                      0, 0, 0, 0);
  164.  
  165.                //Regen_IDOK
  166.                break; 
  167.  
  168.             case IDCANCEL :
  169.                //Regen_IDCANCEL
  170.                //Regen_IDCANCEL
  171.                break; 
  172.  
  173.             case IDC_UID :
  174.                //Regen_IDC_UID
  175.                //Regen_IDC_UID
  176.                break; 
  177.  
  178.             case IDC_UCLASS :
  179.                //Regen_IDC_UCLASS
  180.                //Regen_IDC_UCLASS
  181.                break; 
  182.  
  183.             //lRegen_CustomCommand
  184.             //lRegen_CustomCommand
  185.             }
  186.             break;
  187.  
  188.       case WM_DESTROY :
  189.         //Regen_WM_Destroy
  190.         //Regen_WM_Destroy
  191.          // Free Data Pointer for Dialog control data elements
  192.          if(NULL != haddentityData)
  193.          {
  194.             GlobalUnlock(haddentityData);
  195.             GlobalFree(haddentityData);
  196.             haddentityData  = 0;
  197.             lpaddentityData = NULL;
  198.          }
  199.          break;
  200.    }
  201.    return DefViewProc(hWnd, uMessage, wParam, lParam);
  202. }
  203.  
  204. //Regen_CustomCode
  205. //Regen_CustomCode
  206.