/* GUIBEGIN WINDOW , 219, 299, 240, 153, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , Sizing example FONT 8, 400, MS Shell Dlg TEXT 7, 9, 40, 8, GROUP, , , , Type here: ENTRY 51, 8, 186, 12, H_AUTO|BORDER|TABSTOP, , MyEntry LIST 4, 27, 233, 128, NOTIFY|BORDER|VSCROLL|TABSTOP, , MyList DEND GUIEND */ OPTIONS "C_CALL LABELCHECK NOSOURCE" /* This example demonstrates how to dynamically resize controls to fit * inside of a window when that window is resized. Here, we have a list * and an entry control that we'll dynamically resize. To do this, we * have a "SIZE" event handler for our window. * * We also limit the size that the user can reduce the window. We do * that in our "GETMINMAXINFO" event handler. */ LIBRARY rexxgui DO /* FUNCDEF a MINMAXINFO structure that the OS will pass to us. */ FUNCDEF("MINMAXINFO", "32,32,32,32,32,32,32,32,32,32") CATCH FAILURE CONDITION("M") RETURN END GuiErr = "SYNTAX" GuiHeading = 1 GuiCreateWindow('NORMAL') /* The dimensions in the GUI comment are expressed in "Dialog Units". * Dialog Units are tied to the font used for the window. By doing this, * it allows a window and its controls to look just about the same * regardless of what resolution a user has his desktop set to. But now * that the window/controls are sized and placed accordingly, we want to * get the X and Y positions of each control in pixels. So, we'll call * GuiGetCtlPlacement(). */ GuiGetCtlPlacement("MyList", "MyList.1", "MyList.2", "MyList.3", "MyList.4") GuiGetCtlPlacement("MyEntry", "MyEntry.1", "MyEntry.2", "MyEntry.3", "MyEntry.4") Again: DO FOREVER GuiGetMsg() CATCH SYNTAX CONDITION('M') SIGNAL Again CATCH HALT FINALLY GuiDestroyWindow() END RETURN /* ================== WM_GETMINMAXINFO ================== * This handles the GETMINMAXINFO event for my window. * * Reginald calls thius when the user is resizing the * the window. * * ARG(2) is the MINMAXINFO structure we need to fill in. */ WM_GETMINMAXINFO: /* Use CONVERTDATA to stuff the MINMAXINFO struct that the * OS passes us into a REXX stem variable named "MinMax." */ CONVERTDATA(ARG(2), "MinMax", "struct MINMAXINFO") /* MinMax.7 and MinMax.8 determine the minimum width and * height that you allow for the window. Here we are going * to allow a minimum width of 275 and a minimum height of * 200. */ MinMax.7 = 275 MinMax.8 = 200 /* MinMax.9 and MinMax.10 determine the maximum width and * height that you allow for the window. Here we do not * set these because we want to allow the window to be * maximized to the fullest possible amount. But if you * have a need to set the maximum width/height to something * like 400/200, you could do this: * * MinMax.9 = 400 * MinMax.10 = 200 */ /* Finally, we have to stuff this REXX variable back into * the MINMAXINFO struct the OS passed us. Use CONVERTDATA * again, but this time with the 'FROM' option. */ CONVERTDATA(ARG(2), "MinMax", "struct MINMAXINFO", 'FROM') /* Don't let REXX GUI handle this event. */ RETURN "" /* ================== WM_SIZE ================== * This handles the SIZE event for my window. * * Reginald calls this when the user has resized the * the window. * * ARG(1) and ARG(2) are the X and Y positions of the * top left corner of where we can start placing * controls within the inner window. * ARG(3) is the width of the inner window. * ARG(4) is the height of the inner window. */ WM_SIZE: IF EXISTS("MYENTRY.3") THEN DO /* For MyEntry, we only ever change the width. The * X and Y positions stay the same, as does the height. * For the width, we take the window's width, and * subtract the entry's X position from it. We also * subtract a few pixels to account for some space * before the right border of the window. */ GuiSetCtlPlacement("MyEntry", , , ARG(3) - MyEntry.1 - 5, MyEntry.4) /* For MyList, we change the width and height. The * X and Y positions stay the same. For the width, we * take the window's width, and subtract the list's X * position from it. We also subtract a few pixels to * account for some space before the right border of * the window. For the height, we take the window's * height, and subtract the list's Y position, plus a * few pixels before the bottom border. NOTE: If we * don't use the REALHEIGHT style, the OS will round * off the height so that only complete lines are shown. */ GuiSetCtlPlacement("MyList", , , ARG(3) - MyList.1 - 5, ARG(4) - MyList.2 - 4) END /* Don't let REXX GUI handle this event. */ RETURN ""