Liberty BASIC Community Forum
The Liberty BASIC Language >> Liberty BASIC 5 >> Control colours
http://libertybasic.conforums.com/index.cgi?board=lb5&action=display&num=1511182348

Control colours
Post by JohnnyD on Nov 20th, 2017, 06:52am

Hi Carl,

this may have been asked already, but will all controls, textboxes (including text in textboxes), statictexts etc. have their own individual colour selections instead of blanket ForegroundColor$?

This would be really sexy if so!

JohnnyD

Re: Control colours
Post by Rod on Nov 20th, 2017, 07:12am

Can actually be done in LB v4.5. John Davidson showed us how.

Code:
    nomainwin

    '|---------- Red Text Controls ----------|
    ForegroundColor$="red"
    TextboxColor$="darkblue"

    statictext #red.st1,"Red on darkblue", 10, 10, 100, 17
    textbox #red.tb1,10, 30, 100, 25

    stylebits #red,0,_WS_VISIBLE,0,0
    open "Red window" for window_popup as #red


    '|-------- green Text Controls -------|
    ForegroundColor$="darkgreen"
    TextboxColor$="green"

    statictext #green.st1,"Darkgreen on green", 120, 10, 100, 17
    textbox #green.tb1,120, 30, 100, 25

    stylebits #green,0,_WS_VISIBLE,0,0
    open "Green window" for window_popup as #green


    '|-------- Normal Text Controls ---------|

    'Open the mainGUI
    WindowWidth = 250
    WindowHeight = 160
    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)

    TextboxColor$="" 'default
    ForegroundColor$="" 'default

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

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


    'Move the controls from the 'color' windows to the main GUI.
    '              Parent     Child
    call setParent hWnd(#1) , hWnd(#red.st1)
    call setParent hWnd(#1) , hWnd(#red.tb1)
    call setParent hWnd(#1) , hWnd(#green.st1)
    call setParent hWnd(#1) , hWnd(#green.tb1)

    #red.tb1 "123"
    #green.tb1 "123"
    #1.tb1 "123"
wait

[quit.1]
    close #green
    close #red
    close #1
END



SUB setParent parent,child
    calldll #user32, "SetParent",_
                      child as ulong,_
                     parent as ulong,_
                          r as long
END SUB




 

Re: Control colours
Post by JohnnyD on Nov 20th, 2017, 4:42pm

Hi Rod,

The setParent sub is missing.

In LB 5 it would be nice to do it all natively.

John.
Re: Control colours
Post by Rod on Nov 21st, 2017, 02:27am

Fixed the code, native would be nice.