Programming Guide


Closes the current window

int sm_close_window(void);



sm_close_window closes a screen opened as a window by sm_r_window, sm_r_at_cur, or one of their variants.

sm_close_window erases the currently open window and restores the screen to its state before the window opened. If LDB processing is active, sm_lstore writes data from the named fields to the LDB; otherwise, all window data is lost. If the closed window was spawned by another one, Panther makes the parent window the current one and restores the cursor to its last position in that window.

Panther automatically calls sm_close_window when you close a form with sm_jclose. sm_jclose calls sm_jform to pop the form stack and calls sm_close_window to empty the form's window stack.

Note: sm_close_window does not close the base screen in a window stack—that is, the active form. To close the active form, call sm_jclose.


#include <smdefs.h>
#include <smkeys.h>

/* In a validation function, if the field contains a */
/* special value, open up a window to prompt for a */
/* second value and save it in another field. */

int validate (field, data, occur, bits)
char *data;
int field, occur, bits;
char buf[256];

if (bits & VALIDED)
return 0;

if (strcmp(data, "other") == 0)
sm_r_at_cur "getsecval");
if (sm_input(IN_DATA) != EXIT)
sm_getfield(buf, 1);
buf[0] = 0;
sm_n_putfield("secval", buf);

return 0;

See Also

sm_r_window, sm_wselect