home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cenvi23.zip / PMDLL.LIB < prev    next >
Text File  |  1995-03-01  |  7KB  |  143 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. gSwCntrlDef.hwnd       = UWORD32;
  83. gSwCntrlDef.hwndIcon   = UWORD32;
  84. gSwCntrlDef.program    = UWORD32;
  85. gSwCntrlDef.process    = UWORD32;
  86. gSwCntrlDef.session    = UWORD32;
  87. gSwCntrlDef.visibility = UWORD32;
  88. gSwCntrlDef.jump       = UWORD32;
  89. gSwCntrlDef.title      = 68;
  90. gSwCntrlDef.ProgType   = UWORD32;
  91.  
  92. WinQuerySwitchList(pAnchorBlock)
  93.    // return an array of switch list handles.  Number can be determined by
  94.    // the size of the array returned, which will be NULL for an error.
  95. {
  96.    #define FIRST_SWENTRY_OFFSET 4 // offset in returned block of first entry
  97.    #define ORD_WIN32QUERYSWITCHLIST 126
  98.  
  99.    // determine how big the blob must be to hold the data received and then
  100.    // allocate it much bigger just to be sure
  101.    lWQCount = PMDynamicLink("PMSHAPI",ORD_WIN32QUERYSWITCHLIST,BIT32,CDECL,pAnchorBlock,NULL,0);
  102.    if ( lWQCount == 0 )
  103.       return NULL;
  104.  
  105.    // create big big big extrabig BLOb to hold received data
  106.    lSwCntrlSize = BLObSize(gSwCntrlDef);
  107.    lWinSizeNeeded = (lWQCount * lSwCntrlSize) + FIRST_SWENTRY_OFFSET;
  108.    BLObSize(lWQblob,lWinSizeNeeded*2);
  109.  
  110.    // once again, query for list of WinSwitches
  111.    lWQCount = PMDynamicLink("PMSHAPI",ORD_WIN32QUERYSWITCHLIST,BIT32,CDECL,
  112.                             pAnchorBlock,lWQblob,lWinSizeNeeded * 3 / 2);
  113.    if ( lWQCount == 0 )
  114.       return NULL;
  115.  
  116.    // create array for lWQCount entries to hold the Switch entries
  117.    for ( lCount = 0, lWEoffset = FIRST_SWENTRY_OFFSET; lCount < lWQCount; lCount++, lWEOffset += lSwCntrlSize )
  118.       lSWEntry[lCount] = BLObGet(lWQblob,lWEoffset,gSwCntrlDef).hwnd;
  119.  
  120.    // finished, and so return this array
  121.    return lSWEntry;
  122. }
  123.  
  124. WinQuerySwitchEntry(pSwitchListHandle,pSwitchControlData)
  125.    // Query based on this pSwitchListHandle for SwitchControl Data.  Return 0 for
  126.    // success else error.  Set pSwitchControlData to structure with the following
  127.    // structure members (all integers except for title):
  128.    //  hwnd:      Window Handle
  129.    //  hwndIcon:  Icon handle
  130.    //  program:  Program handle
  131.    //  process:   Process ID
  132.    //  session:   Session ID
  133.    //  visibility:  ???
  134.    //  jump:        ???
  135.    //  title:     title of this window; string
  136.    //  ProgType:  program type
  137. {
  138.    #define ORD_WIN32QUERYSWITCHENTRY         124
  139.    return PMDynamicLink("PMSHAPI",ORD_WIN32QUERYSWITCHENTRY,BIT32,CDECL,
  140.                         pSwitchListHandle,gSwCntrlDef,pSwitchControlData);
  141. }
  142.  
  143.