Color background of standard control

Discussions related to Visual Prolog
daveplummermd
VIP Member
Posts: 88
Joined: 18 Jul 2006 17:18

Color background of standard control

Unread post by daveplummermd » 24 Apr 2019 20:47

Guys

Can the color background of a standard control, specificlly static text control, be modified?
I am reading the disscussions, many answers that refer to "next versions" that have probably been implemented in my 9.01 CE.

After standard creation here:

Code: Select all

 generatedInitialize() :-          setText("eventDispCtrl"),          This:setSize(231, 13),          This:setState([wsf_ClipSiblings]),          addMouseEnterListener(onMouseEnter),          staticText_ctl := textControl::new(This),          staticText_ctl:setText("Event"),          staticText_ctl:setVerticalScroll(false).
I want to change the background color of "staticText_ctl "

Thak in advance
Dave Plummer
Dave Plummer

User avatar
Thomas Linder Puls
VIP Member
Posts: 2449
Joined: 28 Feb 2000 0:01

Re: Color background of standard control

Unread post by Thomas Linder Puls » 26 Apr 2019 12:01

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

constructors     new : (window Parent). clauses     new(Parent) :-         dialog::new(Parent),         generatedInitialize(),         addNativeMessageHandler(onNative).   facts     windowColor : nativeResponse :=         nativeResult(uncheckedConvert(gui_native::lResult, gui_native::getSysColorBrush(gui_native::color_window))).   predicates     onNative : nativeMessageHandler. clauses     onNative(_Window, Msg, _WParam, LParam) = windowColor :-         gui_api::isCtrlColorMsg(Msg),         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.
Regards Thomas Linder Puls
PDC

daveplummermd
VIP Member
Posts: 88
Joined: 18 Jul 2006 17:18

Re: Color background of standard control

Unread post by daveplummermd » 26 Apr 2019 14:25

Perfect, thanks!
Dave Plummer

User avatar
Gukalov
Active Member
Posts: 27
Joined: 5 Oct 2011 15:16

Re: Color background of standard control

Unread post by Gukalov » 26 Apr 2019 15:23

Hi everybody.
In the similar situation I stupidly used imageControl (instead of staticTextControl)
with the set of image files to change the colors and inscriptions (ImageControl:setImageFile(FileName)).

Post Reply