home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Professional
/
OS2PRO194.ISO
/
os2
/
prgramer
/
cenvi
/
pmdll.lib
< prev
next >
Wrap
Text File
|
1994-03-08
|
7KB
|
134 lines
/*****************************************************************************
*** PMdll.lib - This library contains wrappers functions and definitions ***
*** ver.1 used in making calls into the Presentation Manager ***
*** DLLs. This file may be #include'ed into your source ***
*** file, or you may want to improve speed and memory use by ***
*** copying just the relevant sections into your source code. *** ***
*****************************************************************************/
WinCreateObject(ClassName,Title,SetupString,Location,Flags)
{
// WinCreateObject: Create an instance of an object class
// ClassName: A string which contains the name of the class of which this object is a member.
// Title: A string which contains the initial title of the object as it is to appear
// when displayed on the user interface underneath an icon or on
// the title bar of an open object.
// SetupString: A series of "keyname=value" pairs separated by commas, that change the behavior of the object.
// Each object class documents its keynames and the parameters parameters it expects to see immediately following.
// Note that ALL parameters have safe defaults, so it is never necessary to pass
// unnecessary parameters to an object.
// Location: Folder location. This can be the real folder path name or one of these:
// <WP_NOWHERE>, <WP_DESKTOP>, <WP_OS2SYS>, <WP_TEMPS>, <WP_CONFIG>, <WP_START>, <WP_INFO>, <WP_DRIVES>
// Flags: Creation flags:
#define CO_FAILIFEXISTS 0
#define CO_REPLACEIFEXISTS 1
#define CO_UPDATEIFEXISTS 2
// Return: returns handle for object, which is NULL (0) for error, else
// handle can be used for further calls for this object
#define ORD_WINCREATEOBJECT 281
return PMDynamicLink("PMWP",ORD_WINCREATEOBJECT,BIT32,CDECL,
ClassName,Title,SetupString,Location,Flags)
}
WinQueryObject(ObjectID)
{
// WinQueryObject: Return a handle to the persistent ObjectID
// ObjectID: The ObjectID of an existing object, for example "<WP_DESKTOP>", or
// alternatively the fully qualified filename of any file or directory.
// Return: NULL for error, else return a handle to the object created.
// This handle is persistent and can be used for the WinSetObjectData
// and WinDestroyObject function calls.
#define ORD_WINQUERYOBJECT 252
return PMDynamicLink("PMWP",ORD_WINQUERYOBJECT,BIT32,CDECL,ObjectID);
}
WinSetObjectData(WPObjectHandle,SetupString)
// set parameters in SetupString for WPObjectHandle, which is like the value
// returned by WinCreateObject.
// Return TRUE for success and FALSE for error.
{
#define ORD_WINSETOBJECTDATA 250
return PMDynamicLink("PMWP",ORD_WINSETOBJECTDATA,BIT32,CDECL,WPObjectHandle,SetupString)
}
WinSwitchToProgram(SwitchHandle)
{
// Switch to this handle, where SwitchHandle is an entry entry handle in the window list.
// Returns 0 for success or one of the following errors:
#define INV_SWITCH_LIST_ENTRY_HANDLE 4610 // Invalid Window List entry handle of the program to be activated.
// #define NOT_PERMITTED_TO_CAUSE_SWITCH ???? // Requesting program is not the current foreground process.
#define ORD_WIN32SWITCHTOPROGRAM 131
return PMDynamicLink("PMSHAPI",ORD_WIN32SWITCHTOPROGRAM,BIT32,CDECL,SwitchHandle);
}
WinQuerySwitchHandle(WindowHandle,ProcessID)
{
#define ORD_WIN32QUERYSWITCHHANDLE 125
return PMDynamicLink("PMSHAPI",ORD_WIN32QUERYSWITCHHANDLE,BIT32,CDECL,
WindowHandle,ProcessID);
}
WinQuerySwitchList(AnchorBlock)
// return an array of switch list handles. Number can be determined by
// the size of the array returned, which will be NULL for an error.
{
#define FIRST_SWENTRY_OFFSET 4 // offset in returned block of first entry
#define SWENTRY_SIZE 100 // size of each entry in entry array
#define ORD_WIN32QUERYSWITCHLIST 126
// determine how big the blob must be to hold the data received and then
// allocate it much bigger just to be sure
_WQCount = PMDynamicLink("PMSHAPI",ORD_WIN32QUERYSWITCHLIST,BIT32,CDECL,AnchorBlock,NULL,0);
if ( _WQCount == 0 )
return NULL;
// create big big big extrabig BLOb to hold received data
_WinSizeNeeded = (_WQCount * SWENTRY_SIZE) + FIRST_SWENTRY_OFFSET;
BLObSize(_WQblob,_WinSizeNeeded*2);
// once again, query for list of WinSwitches
_WQCount = PMDynamicLink("PMSHAPI",ORD_WIN32QUERYSWITCHLIST,BIT32,CDECL,
AnchorBlock,_WQblob,_WinSizeNeeded * 3 / 2);
if ( _WQCount == 0 )
return NULL;
// create array for _WQCount entries to hold the Switch entries
for ( i = 0, _WEoffset = FIRST_SWENTRY_OFFSET; i < _WQCount; i++, _WEOffset += SWENTRY_SIZE )
_SWEntry[i] = BLObGet(_WQblob,_WEoffset,UWORD32);
// finished, and so return this array
return _SWEntry;
}
WinQuerySwitchEntry(SwitchListHandle,SwitchControlData)
// Query based on this SwitchListHandle for SwitchControl Data. Return 0 for
// success else error. Set SwitchControlData to structure with the following
// structure members (all integers except for title):
// hwnd: Window Handle
// hwndIcon: Icon handle
// program: Program handle
// process: Process ID
// session: Session ID
// visibility: ???
// jump: ???
// title: title of this window; string
// ProgType: program type
{
// create blob to hold all the data
BLObSize(_SwEntry,SWENTRY_SIZE);
#define ORD_WIN32QUERYSWITCHENTRY 124
_result = PMDynamicLink("PMSHAPI",ORD_WIN32QUERYSWITCHENTRY,BIT32,CDECL,SwitchListHandle,_SwEntry);
if ( _result == 0 ) {
// place each field in SwitchControlData structure
undefine(SwitchControlData);
SwitchControlData.hwnd = BLObGet(_SwEntry,_offset=0,UWORD32);
SwitchControlData.hwndIcon = BLObGet(_SwEntry,_offset+=4,UWORD32);
SwitchControlData.program = BLObGet(_SwEntry,_offset+=4,UWORD32);
SwitchControlData.process = BLObGet(_SwEntry,_offset+=4,UWORD32);
SwitchControlData.session = BLObGet(_SwEntry,_offset+=4,UWORD32);
SwitchControlData.visibility = BLObGet(_SwEntry,_offset+=4,UWORD32);
SwitchControlData.jump = BLObGet(_SwEntry,_offset+=4,UWORD32);
strcpy(SwitchControlData.title,BLObGet(_SwEntry,_offset+=4,68));
SwitchControlData.ProgType = BLObGet(_SwEntry,_offset+=68,UWORD32);
}
return _result;
}