Older Version Newer Version

JanetTerra JanetTerra Aug 4, 2006 - "Added a link to LBPE: Layered Window Transparency and restored white spaces in formatting"

[[user:JanetTerra]] =Transparent Window= This demo creates a window of varying degrees of transparency. Thanks to John Richardson for the code contained with LB Window Spier, a Libby Contest entry, 2004. The function for obtaining the OS Version was obtained at Alyce's Restaurant found at URL http://www.alycesrestaurant.com/osversion.htm ---- [[code format="vb"]] Nomainwin WindowWidth Nomainwin WindowWidth = 600 WindowHeight WindowHeight = 400 UpperLeftX UpperLeftX = int((DisplayWidth-WindowWidth)/2) UpperLeftY UpperLeftY = int((DisplayHeight-WindowHeight)/2) text$ text$ = "Translucence here is initially set at 200. Try " + _ "setting "setting to higher and lower numbers for desired " + _ "transparency. "transparency. 0 will make your window complete " + _ "transparent. "transparent. 255 is the maximum. This code was " + _ "taken "taken from the Libby contest entry, LB Window Spier" + _ ", ", by John Richardson. This demo will NOT work on " + _ "Windows "Windows 98 or Windows 95." Statictext Statictext #transp.txt1, text$, 20, 20, 550, 200 Statictext Statictext #transp.txt2, "", 20, 250, 550, 100 Open Open "Transparent Window" for Window as #transp #transp, #transp, "Trapclose EndDemo" hTransp hTransp = hWnd(#transp) #transp, #transp, "Font Verdana 12 Bold" If If OSVersionFlag() Then Call Call TransparentWindow hTransp, 200 #transp.txt2, #transp.txt2, "Success!" Else #transp.txt2, Else #transp.txt2, "This demo will NOT work on Windows 98 " + _ "or "or Windows 95" End End If Wait Wait Sub EndDemo handle$ Close Close #transp End End End Sub Sub TransparentWindow handle, translucence CallDLL CallDLL #user32, "SetWindowLongA", _ handle handle as Ulong, _ -20 -20 as Long, _ 524544 524544 as Long, _ layer layer as Long CallDLL CallDLL #user32, "SetLayeredWindowAttributes", _ handle handle as Ulong, _ 0 0 as Long, _ translucence translucence as Long, _ 2 2 as Long, _ layer layer as Long End Sub Function OSVersionFlag() struct struct OSVERSIONINFO, _ dwOSVersionInfoSize dwOSVersionInfoSize as Long, _ dwMajorVersion dwMajorVersion as Long, _ dwMinorVersion dwMinorVersion as Long, _ dwBuildNumber dwBuildNumber as Long, _ dwPlatformId dwPlatformId as Long, _ szCSDVersion szCSDVersion as Char[128] L L = Len(OSVERSIONINFO.struct) OSVERSIONINFO.dwOSVersionInfoSize.struct OSVERSIONINFO.dwOSVersionInfoSize.struct = L CallDLL CallDLL #kernel32, "GetVersionExA", _ OSVERSIONINFO OSVERSIONINFO as struct, _ result result as Boolean MajorVer MajorVer = OSVERSIONINFO.dwMajorVersion.struct If If MajorVer < 5 Then OSVersionFlag OSVersionFlag = 0 Else OSVersionFlag Else OSVersionFlag = 1 End End If End Function [[code]] ---- For more coding tricks with transparent windows, see [[http://lbpe.wikispaces.com/LayeredWindowTransparency|Fun with Transparent Windows]] at the [[http://lbpe.wikispaces.com/|Liberty BASIC Programmer's Encyclopedia]] Wiki site. [[user:JanetTerra|1154710571]]