home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 035 / cenvi29.zip / PMDLL.LIB < prev    next >
Text File  |  1994-08-27  |  7KB  |  148 lines

  1. /*****************************************************************************
  2.  *** PMdll.lib - This library contains wrappers functions and definitions  ***
  3.  *** ver.3       used in making calls into the Presentation Manager        ***
  4.  ***             DLLs.  This file may be #include'ed into your source      ***
  5.  ***             file, or you may want to improve speed and memory use by  ***
  6.  ***             copying just the relevant sections into your source code. ***             ***
  7.  *****************************************************************************/
  8.  
  9. WinCreateObject(pClassName,pTitle,pSetupString,pLocation,pFlags)
  10. {
  11.    // WinCreateObject: Create an instance of an object class
  12.    //  pClassName: A string which contains the name of the class of which this object is a member.
  13.    //  pTitle: A string which contains the initial title of the object as it is to appear
  14.    //         when displayed on the user interface underneath an icon or on
  15.    //         the title bar of an open object.
  16.    //  pSetupString: A series of "keyname=value" pairs separated by commas, that change the behavior of the object.
  17.    //               Each object class documents its keynames and the parameters parameters it expects to see immediately following.
  18.    //               Note that ALL parameters have safe defaults, so it is never necessary to pass
  19.    //               unnecessary parameters to an object.
  20.    //  pLocation: Folder location.  This can be the real folder path name or one of these:
  21.    //            <WP_NOWHERE>, <WP_DESKTOP>, <WP_OS2SYS>, <WP_TEMPS>, <WP_CONFIG>, <WP_START>, <WP_INFO>, <WP_DRIVES>
  22.    //  pFlags: Creation flags:
  23.          #define CO_FAILIFEXISTS     0
  24.          #define CO_REPLACEIFEXISTS  1
  25.          #define CO_UPDATEIFEXISTS   2
  26.    //  Return: returns handle for object, which is NULL (0) for error, else
  27.    //          handle can be used for further calls for this object
  28.    #define ORD_WINCREATEOBJECT   281
  29.    return PMDynamicLink("PMWP",ORD_WINCREATEOBJECT,BIT32,CDECL,
  30.                         pClassName,pTitle,pSetupString,pLocation,pFlags)
  31. }
  32.  
  33.  
  34. WinQueryObject(pObjectID)
  35. {
  36.    // WinQueryObject: Return a handle to the persistent ObjectID
  37.    //  pObjectID: The ObjectID of an existing object, for example "<WP_DESKTOP>", or
  38.    //            alternatively the fully qualified filename of any file or directory. 
  39.    //  Return: NULL for error, else return a handle to the object created.
  40.    //          This handle is persistent and can be used for the WinSetObjectData
  41.    //          and WinDestroyObject function calls. 
  42.    #define ORD_WINQUERYOBJECT    252
  43.    return PMDynamicLink("PMWP",ORD_WINQUERYOBJECT,BIT32,CDECL,pObjectID);
  44. }
  45.  
  46. WinSetObjectData(pWPObjectHandle,pSetupString)
  47.    // set parameters in SetupString for WPObjectHandle, which is like the value
  48.    // returned by WinCreateObject.
  49.    // Return TRUE for success and FALSE for error.
  50. {
  51.    #define ORD_WINSETOBJECTDATA  250
  52.    return PMDynamicLink("PMWP",ORD_WINSETOBJECTDATA,BIT32,CDECL,pWPObjectHandle,pSetupString)
  53. }
  54.  
  55. WinDestroyObject(pWPObjectHandle)
  56.    // destroy pWPObjectHandle as returned by WinCreateObject
  57.    // Return TRUE for success and FALSE for error.
  58. {
  59.    #define ORD_WINCREATEOBJECT   251
  60.    return PMDynamicLink("PMWP",ORD_WINCREATEOBJECT,BIT32,CDECL,pWPObjectHandle)
  61. }
  62.  
  63.  
  64. WinSwitchToProgram(pSwitchHandle)
  65. {
  66.    // Switch to this handle, where SwitchHandle is an entry entry handle in the window list.
  67.    // Returns 0 for success or one of the following errors:
  68.       #define INV_SWITCH_LIST_ENTRY_HANDLE     4610  // Invalid Window List entry handle of the program to be activated.
  69.       // #define NOT_PERMITTED_TO_CAUSE_SWITCH ????  // Requesting program is not the current foreground process.
  70.    #define ORD_WIN32SWITCHTOPROGRAM    131
  71.    return PMDynamicLink("PMSHAPI",ORD_WIN32SWITCHTOPROGRAM,BIT32,CDECL,pSwitchHandle);
  72.  
  73. }
  74.  
  75. WinQuerySwitchHandle(pWindowHandle,pProcessID)
  76. {
  77.    #define ORD_WIN32QUERYSWITCHHANDLE  125
  78.    return PMDynamicLink("PMSHAPI",ORD_WIN32QUERYSWITCHHANDLE,BIT32,CDECL,
  79.                         pWindowHandle,pProcessID);
  80. }
  81.  
  82. WinQuerySwitchList(pAnchorBlock)
  83.    // return an array of switch list handles.  Number can be determined by
  84.    // the size of the array returned, which will be NULL for an error.
  85. {
  86.    #define FIRST_SWENTRY_OFFSET 4 // offset in returned block of first entry
  87.    #define SWENTRY_SIZE 100       // size of each entry in entry array
  88.    #define ORD_WIN32QUERYSWITCHLIST 126
  89.  
  90.    // determine how big the blob must be to hold the data received and then
  91.    // allocate it much bigger just to be sure
  92.    lWQCount = PMDynamicLink("PMSHAPI",ORD_WIN32QUERYSWITCHLIST,BIT32,CDECL,pAnchorBlock,NULL,0);
  93.    if ( lWQCount == 0 )
  94.       return NULL;
  95.  
  96.    // create big big big extrabig BLOb to hold received data
  97.    lWinSizeNeeded = (lWQCount * SWENTRY_SIZE) + FIRST_SWENTRY_OFFSET;
  98.    BLObSize(lWQblob,lWinSizeNeeded*2);
  99.  
  100.    // once again, query for list of WinSwitches
  101.    lWQCount = PMDynamicLink("PMSHAPI",ORD_WIN32QUERYSWITCHLIST,BIT32,CDECL,
  102.                             pAnchorBlock,lWQblob,lWinSizeNeeded * 3 / 2);
  103.    if ( lWQCount == 0 )
  104.       return NULL;
  105.  
  106.    // create array for lWQCount entries to hold the Switch entries
  107.    for ( lCount = 0, lWEoffset = FIRST_SWENTRY_OFFSET; lCount < lWQCount; lCount++, lWEOffset += SWENTRY_SIZE )
  108.       lSWEntry[lCount] = BLObGet(lWQblob,lWEoffset,UWORD32);
  109.  
  110.    // finished, and so return this array
  111.    return lSWEntry;
  112. }
  113.  
  114. WinQuerySwitchEntry(pSwitchListHandle,pSwitchControlData)
  115.    // Query based on this pSwitchListHandle for SwitchControl Data.  Return 0 for
  116.    // success else error.  Set pSwitchControlData to structure with the following
  117.    // structure members (all integers except for title):
  118.    //  hwnd:      Window Handle
  119.    //  hwndIcon:  Icon handle
  120.    //  program:  Program handle
  121.    //  process:   Process ID
  122.    //  session:   Session ID
  123.    //  visibility:  ???
  124.    //  jump:        ???
  125.    //  title:     title of this window; string
  126.    //  ProgType:  program type
  127.  {
  128.    // create blob to hold all the data
  129.    BLObSize(lSwEntry,SWENTRY_SIZE);
  130.    #define ORD_WIN32QUERYSWITCHENTRY         124
  131.    lResult = PMDynamicLink("PMSHAPI",ORD_WIN32QUERYSWITCHENTRY,BIT32,CDECL,pSwitchListHandle,lSwEntry);
  132.    if ( lResult == 0 ) {
  133.       // place each field in pSwitchControlData structure
  134.       undefine(pSwitchControlData);
  135.       pSwitchControlData.hwnd = BLObGet(lSwEntry,loffset=0,UWORD32);
  136.       pSwitchControlData.hwndIcon = BLObGet(lSwEntry,loffset+=4,UWORD32);
  137.       pSwitchControlData.program = BLObGet(lSwEntry,loffset+=4,UWORD32);
  138.       pSwitchControlData.process = BLObGet(lSwEntry,loffset+=4,UWORD32);
  139.       pSwitchControlData.session = BLObGet(lSwEntry,loffset+=4,UWORD32);
  140.       pSwitchControlData.visibility = BLObGet(lSwEntry,loffset+=4,UWORD32);
  141.       pSwitchControlData.jump = BLObGet(lSwEntry,loffset+=4,UWORD32);
  142.       strcpy(pSwitchControlData.title,BLObGet(lSwEntry,loffset+=4,68));
  143.       pSwitchControlData.ProgType = BLObGet(lSwEntry,loffset+=68,UWORD32);
  144.    }
  145.    return lResult;
  146. }
  147.  
  148.