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

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

  
/* An example of FUNCDEF'ing the Windows API to present
 * a color dialog.
 */

OPTIONS "C_CALL LABELCHECK WINFUNC NOSOURCE"
NUMERIC DIGITS 10





/* ============== FUNCDEF some needed OS functions ============ */
DO
	/* Define a CHOOSECOLOR struct used with ChooseColor() */
	choosecolor = "32u, void, void, 32u, 32u[16] *, 32u, 32u, void, void"

	/* Register the Windows OS function ChooseColor() */
	FUNCDEF("ChooseColor", "32u, struct CHOOSECOLOR dual", "comdlg32")

	CATCH FAILURE

		CONDITION("M")
		RETURN
END






/* ==================== Present the Color dialog ==================== */

/* Initialize the CHOOSECOLOR struct */
choosecolor. = 0	/* All fields default to 0 */

choosecolor.1 = 36	/* The size of a CHOOSECOLOR dialog */

/* ChooseColor.2 may be set to the handle of some window that you want
 * to be the owner of the color dialog.
 */

/* ChooseColor.4 may be set to the RGB value that you initially want
 * selected.
 */

choosecolor.6 = 1 /* CC_RGBINIT */

/* Present the dialog */
err = choosecolor(choosecolor)
IF err \== 0 THEN DO

	/* NOTE: The 16 values of ChooseColor.5.1 to ChooseColor.5.16 will be
 	 * the RGB values for the 16 custom colors that the user can create.
	 * The next time that you call ChooseColor, you would probably use the
	 * same REXX variable, and do not reinitialize it. That way, you'll
	 * get the same custom colors as the user set the previous time.
	 */

	SAY "RGB value:" choosecolor.4

	SAY "Red value:" C2D(BITAND(D2C(choosecolor.4, 4), '000000FF'x, ' '))
	SAY "Green value:" C2D(BITAND(D2C(choosecolor.4, 4), '0000FF00'x, ' ')) / 256
	SAY "Blue value:" X2D(LEFT(D2X(choosecolor.4, 8), 4))

END
ELSE SAY "ERROR: Presenting Color dialog"

RETURN









/* ************* ColorsToRGB ******************
 * Forms an RGB value out of the passed Red,
 * Green, and Blue color components.
 *
 * rgb = ColorsToRGB(Red, Green, Blue)
 */

colorstorgb:
	RETURN ARG(1) + (ARG(2) * 256) + (ARG(3) * 65536)
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Tue 2024-4-16  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2010-07-16 20:45:52