There are 2 ways to handle this. If you're handling the PAINT event, then it's easiest to do the window background drawing there. If not, then handle the ERASEBKGND event.
In either case, if you're drawing the background yourself, then pass a Color arg of 0 to GuiWindowDefaults().
To handle ERASEBKGND, you need to FUNCDEF a few Windows OS functions at the start of your script. You also need to create a "brush" of the desired color. (You can alternately use one of the system brushes returned by RxGdi's GdiStockObj, if one of those available colors are what you want. In your above snippet, you're using a system brush, but we'll assume you want a special color).
LIBRARY rexxgui
guierr = "SYNTAX"
guiheading = 1
DO
FUNCDEF("CreateSolidBrush", "32u, 32u", "gdi32")
FUNCDEF("SelectObject", "32u, 32u, 32u", "gdi32")
rect = "32u, 32u, 32u, 32u"
FUNCDEF("FillRect", ", 32u, struct RECT, 32u", "user32")
FUNCDEF("DeleteBrush", ", 32u", "gdi32", "DeleteObject")
CATCH FAILURE
CONDITION('M')
RETURN
END
color = (100 * 65536) + (175 * 256) + 150
brush = createsolidbrush(color)
guiwindowdefaults(, , 0, 'VREDRAW|HREDRAW')
guicreatewindow('NORMAL')
again:
DO FOREVER
guigetmsg()
CATCH SYNTAX
CONDITION('M')
SIGNAL again
CATCH HALT
FINALLY
guidestroywindow()
deletebrush(brush)
END
RETURN
wm_erasebkgnd:
context = ARG(1)
guigetctlplacement(guiwindow, , , 'Width', 'Height')
temp = selectobject(context, brush)
rect.1 = 0
rect.2 = 0
rect.3 = width
rect.4 = height
fillrect(context, rect, brush)
selectobject(context, temp)
RETURN 1 Incidentally, you'll likely want to use the same custom brush for your text control's background, so change your:setbkcolor(ARG(1), 1255)
RETURN getstockobject(5) to...setbkcolor(ARG(1), 1255)
RETURN brush |