home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
wpsgpf.zip
/
UFAAA.C
< prev
Wrap
Text File
|
1995-02-22
|
6KB
|
138 lines
//-----------------------------------------------------------------------------
// UserFunctions UFaaa (aaa.ORC)
//-----------------------------------------------------------------------------
#define INCL_PM
#include <os2.h>
#include <stdlib.h> // Miscellaneous function declarations
#include <stdio.h> // Declarations for standard I/O routines
#include <string.h> // String function declarations
#include <malloc.h> // Definitions for memory allocation
#include "aaa.Ids"
#include "aaa.Ext"
#include "aaa.H"
/*-----------------------------------*/
/* Proto types of internal functions */
/*-----------------------------------*/
VOID RegisterSOMView (HWND hwnd, WPSimple *somSelf, WPSimpleData *somThis, ULONG ulView);
//-------------------------------------------------------------------
VOID UFInitSOMView (PGPFPARMS pGpfParms) {
PINSTANCEAAA pI = malloc (sizeof(INSTANCEAAA));
PPARAMAAA pP = pGpfParms->pCrtParms;
WPSimple *somSelf = pP->somSelf;
WPSimpleData *somThis = pP->somThis;
/*-------------------------------------------------------*/
/* Copy parameter structure into instance data structure */
/*-------------------------------------------------------*/
memcpy (&(pI->paramaaa), pP, sizeof (PARAMAAA));
pGpfParms->pUsrParms = pI;
/*---------------------------------------------------------------*/
/* Now we have to add the Gpf window to the list of object views */
/* For this we have written a generalized function */
/*---------------------------------------------------------------*/
RegisterSOMView (pGpfParms->hwnd, somSelf, somThis, pP->ulView);
/*-----------------------------------------------------------------*/
/* Here you can add additional initialization of the Gpf window... */
/*-----------------------------------------------------------------*/
pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code */
return;
}
//-------------------------------------------------------------------
VOID UFCloseSOMView (PGPFPARMS pGpfParms) {
WinDestroyWindow (WinQueryWindow (pGpfParms->hwnd, QW_PARENT));
return;
}
//-------------------------------------------------------------------
VOID UFDestroySOMView ( PGPFPARMS pGpfParms ) {
/*-------------------------------------------------------------*/
/* Here we have to remove the object's view from the view list */
/*-------------------------------------------------------------*/
PVIEWITEM pvi;
PUSEITEM pui;
PINSTANCEAAA pI = pGpfParms->pUsrParms;
PPARAMAAA pP = &(pI->paramaaa);
WPSimpleData *somThis = pP->somThis;
WPSimple *somSelf = pP->somSelf;
ULONG ulView = pP->ulView;
HWND hwndFrame = WinQueryWindow (pGpfParms->hwnd,
QW_PARENT);
// -------------------------------------------------------------------
// Find the matching item in the inuse list
// -------------------------------------------------------------------
hwndFrame = WinQueryWindow (pGpfParms->hwnd, QW_PARENT);
pui = _wpFindUseItem (somSelf, USAGE_OPENVIEW, NULL);
while (NULL != pui) {
pvi = (PVIEWITEM)(pui+1);
if (pvi->handle == hwndFrame) { break; }
pui = _wpFindUseItem (somSelf, USAGE_OPENVIEW, pui);
} // end while
// -------------------------------------------------------------------
// Delete the item
// -------------------------------------------------------------------
if (pui) {
_wpDeleteFromObjUseList (somSelf, pui);
free (pui);
} // end if
//--------------------------------------------------------------------
// The view is now closed
//--------------------------------------------------------------------
_hwndInfoView = NULLHANDLE;
DosBeep (1000,100);
return;
}
//--------------------------------------------------------------------------
VOID UFPush (PGPFPARMS pGpfParms) {
PINSTANCEAAA pI = pGpfParms->pUsrParms;
PPARAMAAA pP = &(pI->paramaaa);
WPSimpleData *somThis = pP->somThis;
WinSetDlgItemShort (pGpfParms->hwnd, ID_ENTRYFIELD1,
(USHORT) _lIconState, TRUE);
return;
}
//--------------------------------------------------------------------------
VOID RegisterSOMView (HWND hwnd, WPSimple *somSelf, WPSimpleData *somThis, ULONG ulView) {
PVIEWITEM pvi;
PUSEITEM pui;
HWND hwndFrame = WinQueryWindow (hwnd,
QW_PARENT);
//-Views-------------------------------------------------------------
// Register and display the view
//-------------------------------------------------------------------
_wpRegisterView (somSelf, hwndFrame, CLSNAME_INFOVIEW);
WinSetActiveWindow (HWND_DESKTOP, hwndFrame);
//-Views-------------------------------------------------------------
// Create and add the uselist item for the new open view
//-------------------------------------------------------------------
pui = (PUSEITEM) malloc (sizeof(USEITEM) + sizeof(VIEWITEM));
if (NULL != pui) {
pvi = (PVIEWITEM)(pui+1);
memset (pui, 0, sizeof(USEITEM)+sizeof(VIEWITEM) );
pui->type = USAGE_OPENVIEW;
pvi->view = ulView;
pvi->handle = hwndFrame;
_wpAddToObjUseList (somSelf, pui);
}
return;
}