Older Version
Newer Version
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 WindowWidthNomainwin WindowWidth = 600WindowHeightWindowHeight = 400UpperLeftXUpperLeftX = int((DisplayWidth-WindowWidth)/2)UpperLeftYUpperLeftY = 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."StatictextStatictext #transp.txt1, text$, 20, 20, 550, 200StatictextStatictext #transp.txt2, "", 20, 250, 550, 100OpenOpen "Transparent Window" for Window as #transp#transp,#transp, "Trapclose EndDemo"hTransphTransp = hWnd(#transp)#transp,#transp, "Font Verdana 12 Bold"IfIf OSVersionFlag() ThenCallCall 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"EndEnd IfWaitWait Sub EndDemo handle$CloseClose #transpEndEnd End Sub Sub TransparentWindow handle, translucenceCallDLLCallDLL #user32, "SetWindowLongA", _handlehandle as Ulong, _-20-20 as Long, _524544524544 as Long, _layerlayer as LongCallDLLCallDLL #user32, "SetLayeredWindowAttributes", _handlehandle as Ulong, _00 as Long, _translucencetranslucence as Long, _22 as Long, _layerlayer as Long End Sub Function OSVersionFlag()structstruct OSVERSIONINFO, _dwOSVersionInfoSizedwOSVersionInfoSize as Long, _dwMajorVersiondwMajorVersion as Long, _dwMinorVersiondwMinorVersion as Long, _dwBuildNumberdwBuildNumber as Long, _dwPlatformIddwPlatformId as Long, _szCSDVersionszCSDVersion as Char[128]LL = Len(OSVERSIONINFO.struct)OSVERSIONINFO.dwOSVersionInfoSize.structOSVERSIONINFO.dwOSVersionInfoSize.struct = LCallDLLCallDLL #kernel32, "GetVersionExA", _OSVERSIONINFOOSVERSIONINFO as struct, _resultresult as BooleanMajorVerMajorVer = OSVERSIONINFO.dwMajorVersion.structIfIf MajorVer < 5 ThenOSVersionFlagOSVersionFlag = 0Else OSVersionFlagElse OSVersionFlag = 1EndEnd 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]]