/* GUIBEGIN WINDOW , 31, 131, 252, 68, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , CTLCOLORSTATIC example FONT 8, 400, MS Shell Dlg TEXT 14, 13, 17, 8, GROUP, , , , Hello TEXT 122, 13, 55, 8, GROUP, , , , This is some text. TEXT 122, 32, 26, 8, GROUP, , , , Entry 4 TEXT 13, 31, 26, 8, GROUP, , , , Entry 3 DEND GUIEND */ /* * An example of handling the CTLCOLORSTATIC event of a * REXX GUI window to set the color of TEXT controls. */ OPTIONS "C_CALL LABELCHECK WINFUNC NOSOURCE" LIBRARY rexxgui DO /* Register GetStockObject so we can grab one of the preset brushes for drawing text. */ FUNCDEF("GetStockObject", "void, 32u", "gdi32") /* Register SetBkColor so we can change the background color for text. */ FUNCDEF("SetBkColor", "32u, void, 32u", "gdi32") /* Register SetTextColor so we can change the foreground color for text. */ FUNCDEF("SetTextColor", "32u, void, 32u", "gdi32") CATCH FAILURE CONDITION("M") RETURN END GuiErr = "SYNTAX" GuiHeading = 1 GuiCreateWindow('NORMAL') Again: DO FOREVER GuiGetMsg() CATCH SYNTAX CONDITION('M') SIGNAL Again CATCH HALT FINALLY GuiDestroyWindow() END RETURN /* ================== WM_CTLCOLORSTATIC ================== * This handles the CTLCOLORSTATIC event for my window. * * This event happens when REXX GUI wants us to return * a "brush" used for drawing TEXT controls. * * ARG(1) is our device context handle. * ARG(2) is the handle to the entry control (window). */ WM_CTLCOLORSTATIC: /* * For CTLCOLORSTATIC, we need to return a handle * to the brush we want to use for drawing TEXT controls. * We'll just get one of the preset brushes using * GetStockObject(). That way we don't need to * do CreateSolidBrush() ahead of time, and then * DeleteObject that when we're done with it. * When we handle CTLCOLORSTATIC here, we return * the brush we want. * * The first arg to SetTextColor or SetBkColor is the * device context handle for the control whose color * is to change. Windows passed that to our windows * procedure as the 3rd arg. * * The second arg is a numeric value which is a * combination of Red, Green, and Blue values for the * desired color. Each value can be from 0 to 255, * with the brightest intensity as 255. For example * if you set the green value to 0, the red value * to 0 and the blue value to 255, you'll get a very * pronounced, light blue. If you set green to 40, * red to 40, and blue to 40, you may get a grey. * Different combinations of the 3 values will yield * different colors. When you pass the 3 values to * SetTextColor or SetBkColor, you must multiply the * red value by 65536, and multiply the green value by * 256. Then you add up the red, green, and blue * values. For example, here's how we would set the * background color with red = 100, green = 40, and * blue = 60. * * SetBkColor(ARG(1), (100 * 65536) + (40 * 256) + 60) * * Of course, if a particular component is 0, then you * can just leave it out. (If all 3 components are 0, * then just pass a 0). */ SetTextColor(ARG(1), 125 * 256 /* medium green */) SetBkColor(ARG(1), 255 /* bright red */) RETURN GetStockObject(5 /* NULL_BRUSH */)