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

Color background of standard control

Unread post by daveplummermd »

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: 1398
Joined: 28 Feb 2000 0:01

Re: Color background of standard control

Unread post by Thomas Linder Puls »

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: 80
Joined: 18 Jul 2006 17:18

Re: Color background of standard control

Unread post by daveplummermd »

Perfect, thanks!
Dave Plummer
User avatar
Gukalov
VIP Member
Posts: 62
Joined: 5 Oct 2011 15:16

Re: Color background of standard control

Unread post by Gukalov »

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)).
daveplummermd
VIP Member
Posts: 80
Joined: 18 Jul 2006 17:18

Re: Color background of standard control

Unread post by daveplummermd »

Perfect, thanks.
Dave Plummer
Post Reply