Guidance
指路人
g.yi.org
Software / Reginald / Examples / winsize.rex

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
/*
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 ""
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2024-4-19  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2010-07-16 20:45:37