LB Booster
Programming >> Liberty BASIC language >> Transparent backgrounds
http://lbb.conforums.com/index.cgi?board=lblang&action=display&num=1471332952

Transparent backgrounds
Post by Jack Kelly on Aug 16th, 2016, 07:35am

Another question. Is there any way to make the background transparent for windows and/or controls. If so, it would make an easy job of placing a groupbox control in my visual designer program -- which I'm currently calling 'Freeform Lite'.
Re: Transparent backgrounds
Post by Richard Russell on Aug 16th, 2016, 08:31am

on Aug 16th, 2016, 07:35am, Jack Kelly wrote:
Another question. Is there any way to make the background transparent for windows and/or controls.

Does this LBPE article help? The code there can be modified to make just the background transparent as follows:

Code:
    Nomainwin
 
    WindowWidth = 600
    WindowHeight = 400
    UpperLeftX = int((DisplayWidth-WindowWidth)/2)
    UpperLeftY = int((DisplayHeight-WindowHeight)/2)
    text$ = "This code was adapted from the Libby contest " + _
            "entry, LB Window Spier, by John Richardson.  " + _ 
            "It will NOT work on Windows 98 or Windows 95."
    Statictext #transp.txt1, text$, 20, 20, 550, 200
    Stylebits #transp, 0, 0, _WS_EX_LAYERED, 0
    Open "Transparent Window" for Window as #transp
    #transp, "Trapclose EndDemo"
    #transp, "Font Verdana 12 Bold" 
    hTransp = hWnd(#transp)
    Call SetTransparent hTransp
    Wait
 
Sub EndDemo handle$
    Close #handle$
    End
End Sub
 
Sub SetTransparent handle
    CallDLL #user32, "GetSysColor", 15 as Long, buttonface as Long
    CallDLL #user32, "SetLayeredWindowAttributes", _
        handle as Ulong, _
        buttonface as Long, _
        0 as Long, _
        _LWA_COLORKEY as Long, _
        layer as Long
End Sub 

For other options see this more comprehensive article.

Richard.
Re: Transparent backgrounds
Post by Jack Kelly on Aug 17th, 2016, 07:09am

Thanks, Richard, for your quick response to my question yesterday. I'll keep that in my 'bag of tricks'...