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

  1. //lRegen_FileHeading
  2. //lRegen_FileHeading
  3.  
  4.      /********************************************************************
  5.       *
  6.       *   Source File:  currente.c
  7.       *   Author:
  8.       *   Module:
  9.       *   Program Desc:
  10.       *   Date:         Mon Feb 19 13:11:39 1996
  11.       *   Language:     ANSI C
  12.       *
  13.       ********************************************************************/
  14.  
  15. #include ".\idoiface.h"
  16.  
  17.  
  18. //lRegen_Variables
  19. //lRegen_Variables
  20.  
  21. typedef struct tagCURRENTENTITYDATA
  22. {
  23.    long            x;
  24. }CURRENTENTITYDATA, FAR* LPCURRENTENTITYDATA;
  25.  
  26. VIEW     hViewcurrententity;
  27. HWND     hWndcurrententity;
  28. // Data Pointer for Dialog control data elements
  29. HGLOBAL hcurrententityData = NULL;
  30. LPCURRENTENTITYDATA lpcurrententityData = NULL;
  31. LRESULT CALLBACK EXPORT fncurrententityWndProc(HWND, UINT, WPARAM, LPARAM);
  32.  
  33. int fncurrententity(HWND hParentWnd, UINT iData, void FAR *lpData)
  34. {
  35.    int   ReturnCode;
  36.  
  37.    //lRegen_BeginFunction
  38.    //lRegen_BeginFunction
  39.  
  40.    // Associate Data elements with view
  41.    if(NULL == lpcurrententityData)
  42.    {
  43.       hcurrententityData = GlobalAlloc(GHND, sizeof(CURRENTENTITYDATA));
  44.       if(NULL == hcurrententityData)
  45.          return FALSE;
  46.       lpcurrententityData = (LPCURRENTENTITYDATA)GlobalLock(hcurrententityData);
  47.    }
  48.    //lRegen_InitDlg
  49.    //lRegen_InitDlg
  50.  
  51.    if(NULL == (hViewcurrententity = vwCreateView(hInstance,
  52.                    MAKEINTRESOURCE(currententity),
  53.                    hParentWnd,
  54.                    (VIEWPROC)fncurrententityWndProc,
  55.                    NULL)))
  56.    {
  57.          //lRegen_Create
  58.          //lRegen_Create
  59.         return FALSE;
  60.    }
  61.    vwSetFieldVar(hViewcurrententity, IDC_PVNUMERIC1, &lpcurrententityData->x);
  62.    //lRegen_InitView
  63.    //lRegen_InitView
  64.    if((ReturnCode = vwShowModalView(hViewcurrententity)) == -1)
  65.    {
  66.         MessageBox(NULL, "Unable to display view", "System Error",
  67.                    MB_SYSTEMMODAL | MB_ICONHAND | MB_OK);
  68.         return FALSE;
  69.    }
  70.  
  71.    //lRegen_TermView
  72.    //lRegen_TermView
  73.    // Free Data Pointer for Dialog control data elements
  74.    if(NULL != hcurrententityData)
  75.    {
  76.       GlobalUnlock(hcurrententityData);
  77.       GlobalFree(hcurrententityData);
  78.       hcurrententityData  = 0;
  79.       lpcurrententityData = NULL;
  80.    }
  81.    return(ReturnCode);
  82. }
  83.  
  84. LRESULT CALLBACK EXPORT fncurrententityWndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
  85. {
  86. GETVIEW;
  87.    WORD CtlId;
  88.    WORD Notify;
  89.    HWND CtlWnd;
  90.  
  91.    //lRegen_WindowProcVariables
  92.    ENTITY entity;
  93.    //lRegen_WindowProcVariables
  94.  
  95.    switch(uMessage)
  96.    {
  97.       //lRegen_WndProc
  98.       //lRegen_WndProc
  99.  
  100.       case WM_INITDIALOG :
  101.          //lRegen_InitDialogBegin
  102.          {
  103.             HWND hIDO = GetActiveIDO();
  104.             char szNum[20+1];
  105.  
  106.  
  107.             if(IsWindow(hIDO))
  108.             {
  109.                if(idoIterateEntityFirst(hIDO))
  110.                   while(idoIterateEntityNext(hIDO, &entity))
  111.                   {
  112.                      wsprintf(szNum, "%d", entity.id);
  113.                      SendDlgItemMessage(hWnd, IDC_EID, CB_ADDSTRING, 0, (LPARAM)(LPSTR)szNum);
  114.                      SendDlgItemMessage(hWnd, IDC_ENAME, CB_ADDSTRING, 0, (LPARAM)(LPSTR)entity.name);
  115.                   }
  116.             }
  117.  
  118.             lpcurrententityData->x = idoGetNumberOfSelectedEntities(hIDO);
  119.          }
  120.          //lRegen_InitDialogBegin
  121.          //Regen_WM_InitDialog
  122.          //Regen_WM_InitDialog
  123.          return TRUE;
  124.  
  125.       case WM_COMMAND :
  126.       #ifdef WIN32
  127.          CtlId  = LOWORD(wParam);
  128.          Notify = HIWORD(wParam);
  129.          CtlWnd = (HWND)lParam;
  130.       #else
  131.          CtlId  = wParam;
  132.          Notify = HIWORD(lParam);
  133.          CtlWnd = (HWND)LOWORD(lParam);
  134.       #endif
  135.          switch(CtlId)
  136.          {
  137.             case IDC_ENAME :
  138.                   switch(Notify)
  139.                   {
  140.                      case CBN_SELCHANGE :
  141.                         //Regen_IDC_ENAME_CBN_SELCHANGE
  142.                         {
  143.                            int index;
  144.  
  145.                            index = (int)SendDlgItemMessage(hWnd, IDC_ENAME, CB_GETCURSEL, 0, 0L);
  146.                            SendDlgItemMessage(hWnd, IDC_EID, CB_SETCURSEL, index, 0L);
  147.                         }
  148.                         //Regen_IDC_ENAME_CBN_SELCHANGE
  149.                         break;
  150.  
  151.                   }
  152.                   break;
  153.             case IDC_EID :
  154.                   switch(Notify)
  155.                   {
  156.                      case CBN_SELCHANGE :
  157.                         //Regen_IDC_EID_CBN_SELCHANGE
  158.                         {
  159.                            int index;
  160.  
  161.                            index = (int)SendDlgItemMessage(hWnd, IDC_EID, CB_GETCURSEL, 0, 0L);
  162.                            SendDlgItemMessage(hWnd, IDC_ENAME, CB_SETCURSEL, index, 0L);
  163.                         }
  164.                         //Regen_IDC_EID_CBN_SELCHANGE
  165.                         break;
  166.  
  167.                   }
  168.                   break;
  169.             case IDOK :
  170.                //Regen_IDOK
  171.                {
  172.                   int index;
  173.                   char szNum[20+1];
  174.  
  175.  
  176.                   index = (int)SendDlgItemMessage(hWnd, IDC_ENAME, CB_GETCURSEL, 0, 0L);
  177.                   SendDlgItemMessage(hWnd, IDC_ENAME, CB_GETLBTEXT, index, (LPARAM)(LPSTR)entity.name);
  178.                   index = (int)SendDlgItemMessage(hWnd, IDC_EID, CB_GETCURSEL, 0, 0L);
  179.                   SendDlgItemMessage(hWnd, IDC_EID, CB_GETLBTEXT, index, (LPARAM)(LPSTR)szNum);
  180.                   entity.id = atoi(szNum);
  181.  
  182.  
  183.                   /*
  184.                    *   Set Current Entity.
  185.                    */
  186. //                  idoSetCurrentEntity(GetActiveIDO(), &entity);
  187.  
  188.                }
  189.                //Regen_IDOK
  190.                break;
  191.  
  192.             case IDCANCEL :
  193.                //Regen_IDCANCEL
  194.                //Regen_IDCANCEL
  195.                break;
  196.  
  197.             case IDC_PVNUMERIC1 :
  198.                //Regen_IDC_PVNUMERIC1
  199.                //Regen_IDC_PVNUMERIC1
  200.                break;
  201.  
  202.             //lRegen_CustomCommand
  203.             //lRegen_CustomCommand
  204.             }
  205.             break;
  206.  
  207.       case WM_DESTROY :
  208.         //Regen_WM_Destroy
  209.         //Regen_WM_Destroy
  210.          // Free Data Pointer for Dialog control data elements
  211.          if(NULL != hcurrententityData)
  212.          {
  213.             GlobalUnlock(hcurrententityData);
  214.             GlobalFree(hcurrententityData);
  215.             hcurrententityData  = 0;
  216.             lpcurrententityData = NULL;
  217.          }
  218.          break;
  219.    }
  220.    return DefViewProc(hWnd, uMessage, wParam, lParam);
  221. }
  222.  
  223. //Regen_CustomCode
  224. //Regen_CustomCode
  225.