home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wpsgpf.zip / UFAAA.C < prev   
Text File  |  1995-02-22  |  6KB  |  138 lines

  1. //-----------------------------------------------------------------------------
  2. // UserFunctions UFaaa (aaa.ORC)
  3. //-----------------------------------------------------------------------------
  4. #define INCL_PM
  5. #include <os2.h>
  6.  
  7. #include <stdlib.h>       // Miscellaneous function declarations
  8. #include <stdio.h>       // Declarations for standard I/O routines
  9. #include <string.h>      // String function declarations
  10. #include <malloc.h>     // Definitions for memory allocation
  11.  
  12. #include "aaa.Ids"
  13. #include "aaa.Ext"
  14. #include "aaa.H"
  15.  
  16. /*-----------------------------------*/
  17. /* Proto types of internal functions */
  18. /*-----------------------------------*/
  19. VOID RegisterSOMView (HWND hwnd, WPSimple *somSelf, WPSimpleData *somThis, ULONG ulView);
  20.  
  21. //-------------------------------------------------------------------
  22. VOID UFInitSOMView (PGPFPARMS pGpfParms) {
  23.  
  24.    PINSTANCEAAA pI = malloc (sizeof(INSTANCEAAA));
  25.    PPARAMAAA  pP = pGpfParms->pCrtParms;
  26.    WPSimple     *somSelf = pP->somSelf;
  27.    WPSimpleData *somThis = pP->somThis;
  28.  
  29.    /*-------------------------------------------------------*/
  30.    /* Copy parameter structure into instance data structure */
  31.    /*-------------------------------------------------------*/
  32.    memcpy (&(pI->paramaaa), pP, sizeof (PARAMAAA));
  33.    pGpfParms->pUsrParms = pI;
  34.  
  35.    /*---------------------------------------------------------------*/
  36.    /* Now we have to add the Gpf window to the list of object views */
  37.    /* For this we have written a generalized function               */
  38.    /*---------------------------------------------------------------*/
  39.    RegisterSOMView (pGpfParms->hwnd, somSelf, somThis, pP->ulView);
  40.  
  41.    /*-----------------------------------------------------------------*/
  42.    /* Here you can add additional initialization of the Gpf window... */
  43.    /*-----------------------------------------------------------------*/
  44.  
  45.    pGpfParms->mresult = (MRESULT) FALSE;      /* Set Return Code */
  46.    return;
  47. }
  48.  
  49. //-------------------------------------------------------------------
  50. VOID UFCloseSOMView (PGPFPARMS pGpfParms) {
  51.  
  52.    WinDestroyWindow (WinQueryWindow (pGpfParms->hwnd, QW_PARENT));
  53.    return;
  54. }
  55.  
  56. //-------------------------------------------------------------------
  57. VOID UFDestroySOMView ( PGPFPARMS pGpfParms ) {
  58. /*-------------------------------------------------------------*/
  59. /* Here we have to remove the object's view from the view list */
  60. /*-------------------------------------------------------------*/
  61.  
  62.    PVIEWITEM    pvi;
  63.    PUSEITEM     pui;
  64.    PINSTANCEAAA pI = pGpfParms->pUsrParms;
  65.    PPARAMAAA    pP = &(pI->paramaaa);
  66.    WPSimpleData *somThis  = pP->somThis;
  67.    WPSimple     *somSelf  = pP->somSelf;
  68.    ULONG        ulView    = pP->ulView;
  69.    HWND         hwndFrame = WinQueryWindow (pGpfParms->hwnd,
  70.                                             QW_PARENT);
  71.  
  72.    // -------------------------------------------------------------------
  73.    // Find the matching item in the inuse list
  74.    // -------------------------------------------------------------------
  75.    hwndFrame = WinQueryWindow (pGpfParms->hwnd, QW_PARENT);
  76.    pui = _wpFindUseItem (somSelf, USAGE_OPENVIEW, NULL);
  77.    while (NULL != pui) {
  78.       pvi = (PVIEWITEM)(pui+1);
  79.       if (pvi->handle == hwndFrame) { break; }
  80.       pui = _wpFindUseItem (somSelf, USAGE_OPENVIEW, pui);
  81.     }  // end while
  82.  
  83.     // -------------------------------------------------------------------
  84.     // Delete the item
  85.     // -------------------------------------------------------------------
  86.     if (pui) {
  87.         _wpDeleteFromObjUseList (somSelf, pui);
  88.         free (pui);
  89.      } // end if
  90.  
  91.      //--------------------------------------------------------------------
  92.      // The view is now closed
  93.      //--------------------------------------------------------------------
  94.      _hwndInfoView = NULLHANDLE;
  95.      DosBeep (1000,100);
  96.      return;
  97. }
  98.  
  99. //--------------------------------------------------------------------------
  100. VOID UFPush (PGPFPARMS pGpfParms) {
  101.  
  102.    PINSTANCEAAA pI = pGpfParms->pUsrParms;
  103.    PPARAMAAA    pP = &(pI->paramaaa);
  104.    WPSimpleData *somThis = pP->somThis;
  105.  
  106.    WinSetDlgItemShort (pGpfParms->hwnd, ID_ENTRYFIELD1,
  107.                         (USHORT) _lIconState, TRUE);
  108.    return;
  109. }
  110.  
  111. //--------------------------------------------------------------------------
  112. VOID RegisterSOMView (HWND hwnd, WPSimple *somSelf, WPSimpleData *somThis, ULONG ulView) {
  113.  
  114.    PVIEWITEM    pvi;
  115.    PUSEITEM     pui;
  116.    HWND         hwndFrame = WinQueryWindow (hwnd,
  117.                                             QW_PARENT);
  118.    //-Views-------------------------------------------------------------
  119.    // Register and display the view
  120.    //-------------------------------------------------------------------
  121.    _wpRegisterView (somSelf, hwndFrame, CLSNAME_INFOVIEW);
  122.    WinSetActiveWindow (HWND_DESKTOP, hwndFrame);
  123.  
  124.    //-Views-------------------------------------------------------------
  125.    // Create and add the uselist item for the new open view
  126.    //-------------------------------------------------------------------
  127.    pui = (PUSEITEM) malloc (sizeof(USEITEM) + sizeof(VIEWITEM));
  128.    if (NULL != pui) {
  129.       pvi = (PVIEWITEM)(pui+1);
  130.       memset (pui, 0, sizeof(USEITEM)+sizeof(VIEWITEM) );
  131.       pui->type   = USAGE_OPENVIEW;
  132.       pvi->view   = ulView;
  133.       pvi->handle = hwndFrame;
  134.       _wpAddToObjUseList (somSelf, pui);
  135.    }
  136.    return;
  137. }
  138.