Controls are not supposed/designed to change background color.
They are designed to have a background color that fits the dialog. So actually (standard) controls "ask the dialog" to set the background color for them.
A static text control sends the message gui_native::wm_ctlcolorstatic
to the dialog and the dialog then returns a brush
of the desired kind (e.g. color).
This code will set the background color of a dialog all standard controls to the system "window" color (which is white by default).
Code: Select all
new : (window Parent).
windowColor : nativeResponse :=
onNative : nativeMessageHandler.
onNative(_Window, Msg, _WParam, LParam) = windowColor :-
This:getVpiWindow() <> LParam,
onNative(_Window, _Msg, _WParam, _LParam) = defaultNativeHandling.
You will have to create a suitable brush
(notice that "Sys" brushes does not need to be released, but other brushes must). And you should only return it for your particular control.