LB Booster
Programming >> Liberty BASIC language >> Foreground Color in Statictext Control
http://lbb.conforums.com/index.cgi?board=lblang&action=display&num=1471203876

Foreground Color in Statictext Control
Post by Jack Kelly on Aug 14th, 2016, 7:44pm

Is there any way to get a different foreground color in an individual statictext control? I suppose this question has been discussed adnauseum over the years, but please bear with me. I can't get Cundo's trick to work -- making a popup window a child.

Re: Foreground Color in Statictext Control
Post by Richard Russell on Aug 14th, 2016, 8:45pm

on Aug 14th, 2016, 7:44pm, Jack Kelly wrote:
Is there any way to get a different foreground color in an individual statictext control?

The workaround I use is to replace the statictext control with a texteditor control configured to look the same. It's a bit messy but it works (LBB only):

Code:
    statictext #w.st, "This is a regular STATICTEXT control", 10, 10, 300, 30
    stylebits #w.te, _ES_READONLY, _WS_HSCROLL or _WS_VSCROLL or _WS_DLGFRAME, 0, 0
    texteditor #w.te, 10, 50, 300, 30
    open "Colored statictext" for window as #w
    hw = hwnd(#w)
    calldll #user32, "SetMenu", hw as ulong, 0 as long, r as void
    #w.te "!backcolor buttonface"
    #w.te "!forecolor red"
    #w.te "This is a TEXTEDITOR control masquerading as statictext";
    #w.st "!setfocus"
    wait 

Richard.

Re: Foreground Color in Statictext Control
Post by Jack Kelly on Aug 15th, 2016, 08:00am

Thanks again, Richard. As always, that did the trick!