home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name wndstroy -- Detach window from screen location
- * and discard its memory structures.
- *
- * Synopsis result = wndstroy(pwin);
- *
- * int result Error code, or WN_NO_ERROR if ok.
- * BWINDOW *pwin Pointer to BWINDOW structure to
- * discard.
- *
- * Description This function completely discards a C TOOLS PLUS window
- * structure. It does not affect any video display page.
- *
- * Do NOT use a window structure (or any of its components)
- * after destroying it via WNDSTROY. Its memory has been
- * freed.
- *
- * An error occurs if pwin does not point to a valid window
- * structure.
- *
- * Use WNREMOVE to clean up the screen gracefully before
- * destroying the window with WNDSTROY. Use WNFORGET to
- * abandon a window's border and location without
- * destroying the window itself. Use WNHIDE to make the
- * window temporarily invisible.
- *
- * Returns result Error code, or WN_NO_ERROR if ok.
- * structure, or NIL if failure.
- * *pwin Several fields altered.
- * b_pactnode[][] Window node with active cursor.
- * b_wnerr Possible values:
- * (No change) Success.
- * WN_BAD_WIN *pwin is invalid.
- * WN_NOT_SHOWN Internal error.
- * WN_BAD_NODE Internal error.
- * WN_BAD_PAGE Internal error.
- * WN_BAD_DEV Internal error.
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1986
- *
- **/
-
- #include <string.h>
-
- #include <bwindow.h>
-
- #if MSC300
- #include <malloc.h>
- #else
- #include <stdlib.h>
- #endif
-
- int wndstroy(pwin)
- BWINDOW *pwin;
- {
- int dev;
-
- if (wnvalwin(pwin) == NIL) /* Validate window pointer. */
- return wnerror(WN_BAD_WIN);
-
- dev = pwin->where_shown.dev;
- if (dev == MONO || dev == COLOR) /* If it's showing, */
- {
- if (NIL == wnforget(pwin)) /* abandon border & location. */
- return b_wnerr;
- }
-
- if (pwin->prev.pdata != NIL)
- { /* Free the image of previous */
- /* screen data. */
- free((char *) pwin->prev.pdata);
- pwin->prev.pdata = NIL;
- }
-
- if (pwin->img.pdata != NIL)
- { /* Free the memory copy of the */
- /* window's data area. */
- free((char *) pwin->img.pdata);
- pwin->img.pdata = NIL;
- }
-
- /* Mark the window abandoned. */
- strcpy(pwin->signature,"Destroyed");
-
- free((char *) pwin); /* Free the window itself. */
-
- return WN_NO_ERROR;
- }