home *** CD-ROM | disk | FTP | other *** search
- /*
- GIK/2 1.0.1 EWYEAEH.C 5621-432 (C) COPYRIGHT IBM CORP 1991, 1993. ALL RIGHTS RESERVED. LICENSED MATERIALS - PROPERTY OF IBM.
- */
- /**********************************************************************/
- /* */
- /* MODULE PROLOGUE */
- /* */
- /* COMPONENT NAME: Data Flow Diagram (DFD) Example */
- /* */
- /* */
- /* MODULE NAME: EWYEAEH.C */
- /* */
- /* PURPOSE: */
- /* */
- /* This module contains the event handler functions for the */
- /* DFD example. */
- /* */
- /* COPYRIGHT: (C) 1991, 1993 IBM Corporation */
- /* */
- /* DISCLAIMER OF WARRANTIES. The following [enclosed] code is */
- /* sample code created by IBM Corporation. This sample code is not */
- /* part of any standard or IBM product and is provided to you solely */
- /* for the purpose of assisting you in the development of your */
- /* applications. The code is provided "AS IS", without */
- /* warranty of any kind. IBM shall not be liable for any damages */
- /* arising out of your use of the sample code, even if they have been */
- /* advised of the possibility of such damages. */
- /**********************************************************************/
- /*--------------------------------------------------------------------*/
- /* INCLUDE RELATED DEFINES */
- /*--------------------------------------------------------------------*/
-
- #define INCL_DOS /* OS/2 definitions */
- #define INCL_PM /* PM definitions */
-
- /*--------------------------------------------------------------------*/
- /* HEADER FILES */
- /*--------------------------------------------------------------------*/
-
- #include <os2.h> /* OS/2 header file */
- #include <ewyga.h> /* GIK/2 header file */
- #include "ewyeadf.h" /* Generated header file */
- #include <string.h> /* 'C' string handling */
- #include <stdlib.h> /* 'C' memory handling */
- #include "ewyearc.h" /* Dialog constants header */
- #include "ewyea.h" /* Header shared with RC-file */
-
- /*--------------------------------------------------------------------*/
- /* LOCAL FUNCTION PROTOTYPES */
- /*--------------------------------------------------------------------*/
-
- SHORT GSENTRY EvDoubleClick(DHND,SHORT,EVS_DOUBLE_CLICK *);
-
- SHORT GSENTRY EvInit(DHND,SHORT,EVS_INIT *);
- SHORT GSENTRY EvMenu(DHND,SHORT,EVS_MENU *);
- SHORT GSENTRY EvNew(DHND,SHORT,VOID *);
- SHORT GSENTRY EvExitEnd(DHND,SHORT,EVS_EXIT_END *);
-
- /**********************************************************************/
- /* EvDoubleClick */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* SHORT ev_id (I): Identifies the event. */
- /* EVS_DOUBLE_CLICK *pEvs (I): Pointer to instance of event*/
- /* data type. */
- /* SHND shnd (I): Handle of the symbol */
- /* SHORT part_ref (I): Reference number of the symbol part*/
- /* USHORT button (I): Mouse button that is pressed */
- /* It is one of the following: */
- /* GS_MB1 */
- /* GS_MB2 */
- /* */
- /* Returns: */
- /* GS_NO Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_NO_1 Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_RESTORE Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_RESTORE_1 Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_YES The default processing continues. */
- /* */
- /* Description: */
- /* The function handles the event EV_DOUBLE_CLICK. */
- /**********************************************************************/
-
- SHORT GSENTRY EvDoubleClick(DHND dhnd,SHORT ev_id,EVS_DOUBLE_CLICK *pEvs
- )
- {
- PTOOLDATA pToolData; // ptr to appl. data structure
- SHORT type; // type of symbol
- HWND hWndC; // client window handle
- DLG_DATA DlgData; // symbol data
-
- /********************************************************************/
- /* Get the type of symbol that was hit and prepare the parameters. */
- /********************************************************************/
-
- GsGetSymType(dhnd, pEvs->shnd, &type); // get type of symbol hit
- //
- pToolData = NULL;
- GsGetDiagPointerN(dhnd, PTOOLDATA_ID, (PVOID *)&pToolData);
- pToolData->dhnd = dhnd; // diagram handle
- pToolData->shnd = pEvs->shnd; // symbol handle
- //
- GsGetHwnd(dhnd, GS_WIN_MAIN, 0, FID_CLIENT, &hWndC); // get client handle
- //
- if (pEvs->part_ref != FN_NAME)
- {
-
- /*----------------------------------------------------------------*/
- /* Get the data from the object data buffer and check if the file */
- /* specification of a diagram was specified. */
- /*----------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, pEvs->shnd, &DlgData, //
- sizeof(DLG_DATA));
- //
- if (strlen(DlgData.szRefDiag) > 0) // refinement exists ?
- PerformRefinement(dhnd, pEvs->shnd);
- else
- if (WinDlgBox(HWND_DESKTOP, // Display the refinement
- hWndC, // dialog. This allows the
- SAMPLE_RefDlgProc, // user to specify an
- pToolData->hResModule, // existing diagram.
- DID_REF, //
- (PVOID)pToolData))
- PerformRefinement(dhnd, pEvs->shnd);
- }
- return GS_YES;
- }
-
- /**********************************************************************/
- /* EvInit */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* SHORT ev_id (I): Identifies the event. */
- /* EVS_INIT *pEvs (I): Pointer to instance of event*/
- /* data type. */
- /* VOID *pInit_data (I): Pointer passed from the customizing*/
- /* code to the parameter pInit_data of*/
- /* the GIK/2 function GsInitWin */
- /* HAB hab (I): Handle to anchor block */
- /* HWND hwnd_client (I): Handle to client window */
- /* HWND hwnd_frame (I): Handle to frame window */
- /* */
- /* Returns: */
- /* GS_NO The window is closed. */
- /* GS_YES The initialization of the GIK/2 window continues. */
- /* */
- /* Description: */
- /* The function handles the event EV_INIT. */
- /**********************************************************************/
-
- SHORT GSENTRY EvInit(DHND dhnd,SHORT ev_id,EVS_INIT *pEvs)
- {
- CHAR szLoadError[ERROR_MSG_SIZE]; // error msg
- PTOOLDATA pToolData; // ptr to appl. data structure
- DLG_DATA DlgData; // symbol data
- static int topdiag;
-
- /********************************************************************/
- /* Allocate the data structure for this application. */
- /********************************************************************/
-
- pToolData = (PTOOLDATA)malloc(sizeof(TOOLDATA));
- memset(pToolData, '\0', sizeof(TOOLDATA)); // reset
- //
- if (topdiag) // parameter passed to this instance
- {
-
- /*----------------------------------------------------------------*/
- /* Get the symbol handle and the diagram handle of the parent */
- /* symbol in the parent diagram and store it. */
- /*----------------------------------------------------------------*/
-
- pToolData->shndPar = ((PTOOLDATA)pEvs->pInit_data)->shnd;
- pToolData->dhndPar = ((PTOOLDATA)pEvs->pInit_data)->dhnd;
-
- /*----------------------------------------------------------------*/
- /* Store the diagram handle of this instance in the parent symbol.*/
- /*----------------------------------------------------------------*/
-
- GsGetSymObjectData(pToolData->dhndPar, pToolData->shndPar, //
- &DlgData, sizeof(DLG_DATA));
- DlgData.dhndRef = dhnd;
- GsPutSymObjectData(pToolData->dhndPar, pToolData->shndPar, //
- &DlgData, sizeof(DLG_DATA));
-
- /*----------------------------------------------------------------*/
- /* Store the handle of the resource module. */
- /*----------------------------------------------------------------*/
-
- pToolData->hResModule = ((PTOOLDATA)pEvs->pInit_data)->hResModule;
-
- /*----------------------------------------------------------------*/
- /* Load the application icon from the resource module. */
- /*----------------------------------------------------------------*/
-
- GsUseIcon(dhnd, pToolData->hResModule, SAMPLE_ICON, GS_WIN_MAIN);
- }
- else
- {
- topdiag = 1;
-
- /*----------------------------------------------------------------*/
- /* Load the resource NLS module. */
- /*----------------------------------------------------------------*/
-
- if (DosLoadModule(szLoadError, sizeof(szLoadError), NLS_RESOURCE,
- &(pToolData->hResModule)))
- {
-
- /****************************************************************/
- /* ** nls dll not in current path, have a second try ** */
- /****************************************************************/
-
- if (DosLoadModule(szLoadError, sizeof(szLoadError),
- NLS_RESOURCE_2ND_TRY, &(pToolData->hResModule)))
- {
-
- /**************************************************************/
- /* ** sorry, dll somewhere else ** */
- /**************************************************************/
-
- GsMessageBox(dhnd, szLoadError, EV_INIT_TITLE, MB_OK, NULL); // error !
- return GS_NO; // do not proceed
- }
- }
-
- /*----------------------------------------------------------------*/
- /* Load the application icon from the resource module. */
- /*----------------------------------------------------------------*/
-
- GsUseIcon(dhnd, pToolData->hResModule, SAMPLE_ICON, GS_WIN_MAIN);
- }
-
- /********************************************************************/
- /* Store the pointer to the data structure in the diagram record. */
- /********************************************************************/
-
- GsPutDiagPointerN(dhnd, PTOOLDATA_ID, pToolData);
- GsPutDiagModify(dhnd, GS_NO);
- return GS_YES;
- }
-
- /**********************************************************************/
- /* EvMenu */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* SHORT ev_id (I): Identifies the event. */
- /* EVS_MENU *pEvs (I): Pointer to instance of event*/
- /* data type. */
- /* SHORT win_id (I): Identification of the window */
- /* It is one of the following: */
- /* GS_WIN_MAIN */
- /* GS_WIN_OV */
- /* USHORT menu_id (I): Identifier of the menu bar choice */
- /* */
- /* Returns: */
- /* GS_NO Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_NO_1 Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_RESTORE Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_RESTORE_1 Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_YES The default processing continues. */
- /* */
- /* Description: */
- /* The function handles the event EV_MENU. */
- /**********************************************************************/
-
- SHORT GSENTRY EvMenu(DHND dhnd,SHORT ev_id,EVS_MENU *pEvs)
- {
- SHND shnd; // symbol handle
- SHORT ConnCnt = 0; // counter link
- SHORT NodeCnt = 0; // counter node
- DLG_DATA DlgData; // symbol data
- SHORT symType; // symbol type
- SHORT symForm; // symbol form
-
- /********************************************************************/
- /* Disable all non-generic actions. */
- /********************************************************************/
-
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, AH_CONTROLFLOW, GS_OFF);
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, AH_DATAFLOW, GS_OFF);
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, AH_REFINE, GS_OFF);
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, AH_UNREFINE, GS_OFF);
-
- /********************************************************************/
- /* Check if a link is selected. */
- /********************************************************************/
-
- GsCollectSym(dhnd, GS_LINK, GS_SYM_SELECTED, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &shnd) != GSE_COLLECTION_EMPTY)
- {
- ConnCnt++;
- }
-
- /********************************************************************/
- /* Count all selected nodes. */
- /********************************************************************/
-
- GsCollectSym(dhnd, GS_NODE, GS_SYM_SELECTED, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &shnd) != GSE_COLLECTION_EMPTY)
- NodeCnt++;
-
- /********************************************************************/
- /* If exactly one function is selected, enable the refinement */
- /* action, if this function has a refinement diagram, enable the */
- /* unrefine action. */
- /********************************************************************/
-
- if (NodeCnt == 1 && ConnCnt == 0)
- {
- GsGetFirstSym(dhnd, GS_NODE, GS_SYM_SELECTED, GS_UPPER_FIRST, &shnd)
- ;
- GsGetSymType(dhnd, shnd, &symType);
- if (symType == FUNCTION)
- {
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, AH_REFINE, GS_ON);
- //
- GsGetSymObjectData(dhnd, shnd, &DlgData, sizeof(DLG_DATA));
- if (strlen(DlgData.szRefDiag) > 0)
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, //
- AH_UNREFINE, GS_ON);
- }
- }
-
- /********************************************************************/
- /* If more than one links are selected, enable the link style */
- /* actions. */
- /********************************************************************/
-
- if (NodeCnt == 0 && ConnCnt > 1)
- {
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, AH_CONTROLFLOW, GS_OFF);
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, AH_DATAFLOW, GS_OFF);
- }
- if (NodeCnt == 0 && ConnCnt == 1)
- {
- GsGetFirstSym(dhnd, GS_LINK, GS_SYM_SELECTED, GS_UPPER_FIRST, &shnd)
- ;
- GsGetSymForm(dhnd, shnd, &symForm);
- if (symForm == F_CONTROLFLOW)
- {
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, AH_DATAFLOW, GS_ON);
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, AH_CONTROLFLOW, GS_OFF);
- }
- if (symForm == F_DATAFLOW)
- {
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, AH_DATAFLOW, GS_OFF);
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, AH_CONTROLFLOW, GS_ON);
- }
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, AH_REFINE, GS_OFF);
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, AH_UNREFINE, GS_OFF);
- }
- //
- return GS_YES;
- }
-
- /**********************************************************************/
- /* EvNew */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* SHORT ev_id (I): Identifies the event. */
- /* VOID *pEvs (I): Pointer to instance of event*/
- /* data type. */
- /* */
- /* Returns: */
- /* GS_NO Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_NO_1 Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_RESTORE Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_RESTORE_1 Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_YES The default processing continues. */
- /* */
- /* Description: */
- /* The function handles the event EV_NEW. */
- /**********************************************************************/
-
- SHORT GSENTRY EvNew(DHND dhnd,SHORT ev_id,VOID *pEvs)
- {
- PTOOLDATA pToolData; // ptr to appl. data structure
-
- /********************************************************************/
- /* Reinitialize the data structure for this instance. */
- /********************************************************************/
-
- pToolData = NULL;
- GsGetDiagPointerN(dhnd, PTOOLDATA_ID, (PVOID *)&pToolData); // get ptr
- //
- pToolData->shnd = pToolData->shndPar = (SHND)0L;
- pToolData->dhnd = pToolData->dhndPar = (DHND)0L;
- return GS_YES;
- }
-
- /**********************************************************************/
- /* EvExitEnd */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* SHORT ev_id (I): Identifies the event. */
- /* EVS_EXIT_END *pEvs (I): Pointer to instance of event*/
- /* data type. */
- /* SHORT close (I): Indicator that specifies whether */
- /* the event is triggered during the */
- /* processing of the WM_CLOSE or the */
- /* WM_DESTROY message */
- /* It is one of the following: */
- /* GS_YES. The WM_CLOSE message is */
- /* processed. */
- /* GS_NO. The WM_DESTROY message is*/
- /* processed. */
- /* HAB hab (I): Handle to anchor block */
- /* HWND hwnd_client (I): Handle to client window */
- /* HWND hwnd_frame (I): Handle to frame window */
- /* */
- /* Returns: */
- /* GS_NO Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_NO_1 Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_RESTORE Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_RESTORE_1 Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_YES The default processing continues. */
- /* */
- /* Description: */
- /* The function handles the event EV_EXIT_END. */
- /**********************************************************************/
-
- SHORT GSENTRY EvExitEnd(DHND dhnd,SHORT ev_id,EVS_EXIT_END *pEvs)
- {
- PTOOLDATA pToolData; // ptr to appl. data structure
- PTOOLDATA pRefToolData; // ptr to appl. data structure
- DLG_DATA DlgData; // symbol data
- SHND shnd; // symbol handle
-
- /********************************************************************/
- /* Get the pointer to the data structure. */
- /********************************************************************/
-
- pToolData = NULL;
- GsGetDiagPointerN(dhnd, PTOOLDATA_ID, (PVOID *)&pToolData); // get ptr
- if (pToolData) // for safety
- {
-
- /*----------------------------------------------------------------*/
- /* Reinitialize the pointer to the refinement diagram in the */
- /* application data of the parent symbol in the parent diagram. */
- /*----------------------------------------------------------------*/
-
- if (pToolData->shndPar) // if the parent diagram is open
- {
- GsGetSymObjectData(pToolData->dhndPar, pToolData->shndPar, //
- &DlgData, sizeof(DLG_DATA));
- DlgData.dhndRef = 0L;
- GsPutSymObjectData(pToolData->dhndPar, pToolData->shndPar, //
- &DlgData, sizeof(DLG_DATA));
- }
-
- /*----------------------------------------------------------------*/
- /* Loop over all node symbols and if they have a refinement */
- /* diagram open, reset the pointer to this instance in the */
- /* refinement diagram. */
- /*----------------------------------------------------------------*/
-
- GsCollectSym(dhnd, GS_NODE, GS_ANY_SYM, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &shnd) != GSE_COLLECTION_EMPTY)
- {
- GsGetSymObjectData(dhnd, shnd, //
- &DlgData, sizeof(DLG_DATA));
- if (DlgData.dhndRef)
- {
- pRefToolData = NULL;
- GsGetDiagPointerN(DlgData.dhndRef, PTOOLDATA_ID, //
- (PVOID *)&pRefToolData);
- pRefToolData->dhndPar = 0L;
- pRefToolData->shndPar = 0L;
- }
- }
-
- /******************************************************************/
- /* Free the data structure for this instance. */
- /******************************************************************/
- // DosFreeSeg(SELECTOROF(pToolData)); // free it
-
- free(pToolData);
- GsPutDiagPointerN(dhnd, PTOOLDATA_ID, NULL); // reset
- }
- return GS_YES;
- }
-
- /**********************************************************************/
- /* SAMPLE_RefDlgProc */
- /* */
- /* Parameters: */
- /* HWND hDlg (I): Window handle of dialog box */
- /* ULONG msg (I): Message */
- /* MPARAM mp1 (I): Parameter 1 */
- /* MPARAM mp2 (I): Parameter 2 */
- /* */
- /* Returns: */
- /* MRESULT (TRUE or FALSE) depending on processing. */
- /* */
- /* Description: */
- /* This is the dialog box window procedure for the refinement */
- /* action. The data entered is stored in the object data buffer */
- /* of the selected function symbol. */
- /**********************************************************************/
-
- MRESULT GSENTRY SAMPLE_RefDlgProc(HWND hDlg, //
- ULONG msg, //
- MPARAM mp1, //
- MPARAM mp2)
- {
- static PTOOLDATA pToolData; // ptr to appl. data structure
- static DLG_DATA DlgData; // symbol data
-
- switch (msg)
- {
- case WM_INITDLG :
-
- /*--------------------------------------------------------------*/
- /* Get the pointer to the application data and retrieve the */
- /* symbol data. */
- /*--------------------------------------------------------------*/
-
- pToolData = (PTOOLDATA)LONGFROMMP(mp2); // remember ptr
- GsGetSymObjectData(pToolData->dhnd, pToolData->shnd, &DlgData,
- sizeof(DLG_DATA));
- break;
- //
- case WM_CONTROL :
- switch (SHORT1FROMMP(mp1))
- {
-
- /*------------------------------------------------------------*/
- /* Store what has been entered by the user. */
- /*------------------------------------------------------------*/
-
- case DID_REF_NAME :
- WinQueryWindowText(WinWindowFromID(hDlg,
- DID_REF_NAME),
- GS_FILE_SPEC_LEN,
- DlgData.szRefDiag);
- break;
- default :
- break;
- }
- break;
- //
- case WM_COMMAND :
- switch (SHORT1FROMMP(mp1))
- {
- case DID_REF_OK :
-
- /*----------------------------------------------------------*/
- /* Store the refinement information in the function symbol. */
- /*----------------------------------------------------------*/
-
- GsPutSymObjectData(pToolData->dhnd, pToolData->shnd, &DlgData,
- sizeof(DlgData));
- //
- WinDismissDlg(hDlg, // dismiss the dialog
- TRUE);
- break;
- //
- case DID_REF_CANCEL :
- case DID_CANCEL :
- WinDismissDlg(hDlg, // dismiss the dialog
- FALSE);
- break;
- default :
- break;
- }
- break;
- //
- default :
- return WinDefDlgProc(hDlg,
- msg,
- mp1,
- mp2);
- }
-
- return (MPARAM)FALSE;
- }
-
- /**********************************************************************/
- /* PerformRefinement */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* SHND shnd (I): Symbol handle. */
- /* */
- /* Returns: */
- /* Nothing. */
- /* */
- /* Description: */
- /* The function performs a refinement action, i.e. invokes */
- /* another instance of the data-flow diagram editor and optionally */
- /* opens a diagram. */
- /**********************************************************************/
-
- VOID PerformRefinement(DHND dhnd, //
- SHND shnd)
- {
- PTOOLDATA pToolData; // ptr to appl. data structure
- HWND hWndF; // frame window handle
- HWND hWndFrameOld; // frame window handle
- HWND hWndHelp; // frame window handle
- DHND dhndNew; // new diagram handle
- DLG_DATA DlgData; // symbol data
- CHAR filespec[GS_FILE_SPEC_LEN+1]; // design file spec
- SHND shndNew; // symbol handle
- HAB hab;
-
- /********************************************************************/
- /* Get the pointer to the data structure. */
- /********************************************************************/
-
- pToolData = NULL;
- GsGetDiagPointerN(dhnd, PTOOLDATA_ID, (PVOID *)&pToolData);
-
- /********************************************************************/
- /* Prepare parameter. */
- /********************************************************************/
-
- pToolData->shnd = shnd; // prepare parameters
- pToolData->dhnd = dhnd;
-
- /********************************************************************/
- /* Get the application data from the object data buffer. */
- /********************************************************************/
-
- GsGetSymObjectData(dhnd, shnd, &DlgData, sizeof(DLG_DATA));
-
- /********************************************************************/
- /* Perform the refinement. */
- /********************************************************************/
-
- if (DlgData.dhndRef)
- {
-
- /*----------------------------------------------------------------*/
- /* If the refinement diagram is already open, activate it. */
- /*----------------------------------------------------------------*/
-
- GsGetHwnd(DlgData.dhndRef, GS_WIN_MAIN, 0, 0, &hWndF); // get frame handle
- WinSetActiveWindow(HWND_DESKTOP, // make window active
- hWndF);
- }
- else
- {
-
- /*----------------------------------------------------------------*/
- /* Bring up another instance of the editor. */
- /*----------------------------------------------------------------*/
-
- GsGetDesignFileSpec(dhnd, filespec, sizeof(filespec));
- if (GsInitWin(&dhndNew, NULL, filespec, pToolData, //
- HWND_DESKTOP, 1))
- GsMessageBox(dhnd, REF_ERROR, EV_DOUBLE_CLICK_TITLE, MB_OK, NULL);
- else
- if (strlen(DlgData.szRefDiag) != 0)
- if (GsOpen(dhndNew, DlgData.szRefDiag) == GS_OK)
- {
-
- /*------------------------------------------------------------*/
- /* Reset dhndRef in symbols of opened diagram. */
- /*------------------------------------------------------------*/
-
- GsCollectSym(dhndNew, GS_NODE, GS_ANY_SYM, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhndNew, &shndNew) !=
- GSE_COLLECTION_EMPTY)
- {
- GsGetSymObjectData(dhndNew, shndNew, &DlgData, //
- sizeof(DLG_DATA));
- DlgData.dhndRef = 0L;
- GsPutSymObjectData(dhndNew, shndNew, &DlgData, //
- sizeof(DLG_DATA));
- GsPutDiagModify(dhndNew, GS_NO);
- }
-
- /*------------------------------------------------------------*/
- /* Make refinement symbol part visible. */
- /*------------------------------------------------------------*/
-
- GsPutPartVisibility(dhnd, shnd, FN_REFINEMENT, GS_ON);
-
- /*------------------------------------------------------------*/
- /* Refresh the screen of the parent. */
- /*------------------------------------------------------------*/
-
- GsUpdateGraphics(dhnd);
- }
- else
- {
-
- /*------------------------------------------------------------*/
- /* Open failed, reinitialize the refinement information. */
- /*------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, shnd, &DlgData, sizeof(DLG_DATA));
- DlgData.szRefDiag[0] = '\0';
- GsPutSymObjectData(dhnd, shnd, &DlgData, sizeof(DLG_DATA));
- }
- GsGetSymObjectData(dhnd, shnd, &DlgData, sizeof(DLG_DATA));
- if (DlgData.szRefDiag[0] != '\0')
- {
-
- /*--------------------------------------------------------------*/
- /* Make refinement symbol part visible. */
- /*--------------------------------------------------------------*/
-
- GsPutPartVisibility(dhnd, shnd, FN_REFINEMENT, GS_ON);
-
- /*--------------------------------------------------------------*/
- /* Refresh the screen of the parent. */
- /*--------------------------------------------------------------*/
-
- GsUpdateGraphics(dhnd);
- }
-
- /******************************************************************/
- /* Get the help window hwnd from the old window and associate /* */
- /* it with the refined window handle. */
- /******************************************************************/
-
- GsGetHwnd(dhnd, GS_WIN_MAIN, 0, 0, &hWndFrameOld); // get frame handle
- GsGetHwnd(dhndNew, GS_WIN_MAIN, 0, 0, &hWndF); // get frame handle
- hWndHelp = WinQueryHelpInstance(hWndFrameOld);
- GsGetHab(&hab);
- WinGetLastError(hab);
- if (!WinAssociateHelpInstance(hWndHelp, hWndF))
- {
- WinGetLastError(hab);
- GsMessageBox(dhndNew, HELP_LOAD_ERROR, HELP_LOAD_ERROR_TITLE,
- MB_OK, NULL);
- }
- }
- }
-
- /**********************************************************************/
- /* DefineRefinement */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* SHND shnd (I): Symbol handle. */
- /* */
- /* Returns: */
- /* Nothing. */
- /* */
- /* Description: */
- /* The function defines a refinement for the save and save-as */
- /* actions. */
- /**********************************************************************/
-
- VOID DefineRefinement(DHND dhnd)
- {
- PTOOLDATA pToolData; // ptr to appl. data structure
- CHAR fileSpec[GS_FILE_SPEC_LEN+1]; // file specification
- DLG_DATA DlgData; // symbol data
-
- pToolData = NULL;
- GsGetDiagPointerN(dhnd, PTOOLDATA_ID, (PVOID *)&pToolData); // get ptr
-
- /********************************************************************/
- /* If the parent symbol handle is null, the current diagram is the */
- /* top diagram. In this case no file specification is stored. */
- /********************************************************************/
-
- if (!pToolData->shndPar)
- return ;
-
- /********************************************************************/
- /* Get the application data structure of the parent symbol. */
- /********************************************************************/
-
- GsGetSymObjectData(pToolData->dhndPar, pToolData->shndPar, //
- &DlgData, sizeof(DLG_DATA));
-
- /********************************************************************/
- /* Remember the file specification in the application data of the */
- /* parent symbol. */
- /********************************************************************/
-
- GsGetFileSpec(dhnd, fileSpec, GS_FILE_SPEC_LEN);
- strcpy(DlgData.szRefDiag, fileSpec);
- GsPutSymObjectData(pToolData->dhndPar, pToolData->shndPar, //
- &DlgData, sizeof(DLG_DATA));
-
- /********************************************************************/
- /* Make refinement symbol part visible. */
- /********************************************************************/
-
- GsPutPartVisibility(pToolData->dhndPar, pToolData->shndPar,
- FN_REFINEMENT, GS_ON);
-
- /********************************************************************/
- /* Refresh the screen of the parent. */
- /********************************************************************/
-
- GsUpdateGraphics(pToolData->dhndPar);
- }