LB Booster
Programming >> Compatibility with LB4 >> Textbox color
http://lbb.conforums.com/index.cgi?board=compatibility&action=display&num=1460115125

Textbox color
Post by Richard Russell on Apr 8th, 2016, 11:32am

There's a thread at the Liberty BASIC Community Forum describing a trick that allows textboxes and statictext controls, in the same window, to have different foreground colors. This doesn't work in LBB (it relies on undocumented internal behavior) but it's easy enough to achieve an equivalent effect:

Code:
    nomainwin

    WindowWidth = 250
    WindowHeight = 160
    UpperLeftX = int((DisplayWidth-WindowWidth)/2)
    UpperLeftY = int((DisplayHeight-WindowHeight)/2)

    statictext #1.st1, "Normal", 10, 70, 50, 17
    textbox    #1.tb1, 10, 90, 100, 25

    stylebits  #1.st2, _ES_READONLY, _WS_HSCROLL or _WS_VSCROLL or _
                       _WS_DLGFRAME or _ES_MULTILINE, 0, 0
    texteditor #1.st2, 10, 10, 100, 17
    stylebits  #1.tb2, _WS_BORDER, _WS_HSCROLL or _WS_VSCROLL or _
                       _WS_DLGFRAME or _ES_MULTILINE, _WS_EX_CLIENTEDGE, 0
    texteditor #1.tb2, 10, 30, 100, 25

    stylebits  #1.st3, _ES_READONLY, _WS_HSCROLL or _WS_VSCROLL or _
                       _WS_DLGFRAME or _ES_MULTILINE, 0, 0
    texteditor #1.st3, 120, 10, 100, 17
    stylebits  #1.tb3, _WS_BORDER, _WS_HSCROLL or _WS_VSCROLL or _
                       _WS_DLGFRAME or _ES_MULTILINE, _WS_EX_CLIENTEDGE, 0
    texteditor #1.tb3,120, 30, 100, 25

    open "Main GUI" for window as #1
    print #1, "font ms_sans_serif 8"
    print #1, "trapclose [quit.1]"

    hw1 = hwnd(#1)
    calldll #user32, "SetMenu", hw1 as ulong, 0 as long, r as long
    
    #1.tb1 "123"
    #1.st2 "Red on darkblue"
    #1.st2 "!forecolor red"
    #1.st2 "!backcolor buttonface"
    #1.tb2 "!forecolor red"
    #1.tb2 "!backcolor darkblue"
    #1.tb2 "123"
    #1.st3 "Darkgreen on green"
    #1.st3 "!forecolor darkgreen"
    #1.st3 "!backcolor buttonface"
    #1.tb3 "!forecolor darkgreen"
    #1.tb3 "!backcolor green"
    #1.tb3 "123"
wait

[quit.1]
    close #1
end 

Richard.