Many of the Windows constants are recognized by Liberty BASIC by preceding that constant with an underscore. As an example, the decimal equivalent of WS_EX_TOOLWINDOW (MSDN Defines a Tool Window here) is 128. With the preceding underscore, Liberty BASIC accurately interprets that constant.
Print _WS_EX_TOOLWINDOW ' Prints 128
While it is most convenient to use the Windows constant itself, the numerical equivalent (either the literal or a variable) can be used just as easily in the Stylebits command.
Stylebits 0, 0, _WS_EX_TOOLWINDOW, 0
is the same as
Stylebits 0, 0, 128, 0
is the same as
exStyle = 128
Stylebits 0, 0, exStyle, 0
This variable must be in decimal (not hexademical) form. If necesssary, use the Liberty BASIC HexDec() function to convert a hexademical value to a decimal value.
valueHex$ = "80"' Hexademical &H80
Print HexDec(valueHex$) ' Prints 128
Demo 1: Opening a Tool Window using the Windows Constant in the Stylebits command
' Open a Tool Window
Nomainwin
Stylebits #w, 0, 0, _WS_EX_TOOLWINDOW, 0
Open"Tool Window"for Window as #w
#w, "Trapclose QuitDemo"
Wait
Sub QuitDemo handle$
Close #handle$
EndSub
Demo 2: Opening a Tool Window using the literal decimal value in the Stylebits command
' Open a Tool Window
Nomainwin
Stylebits #w, 0, 0, 128, 0
Open"Tool Window"for Window as #w
#w, "Trapclose QuitDemo"
Wait
Sub QuitDemo handle$
Close #handle$
EndSub
Demo 3: Opening a Tool Window using a variable in the Stylebits command
' Open a Tool Window
Nomainwin
exStyle = 128
Stylebits #w, 0, 0, exStyle, 0
Open"Tool Window"for Window as #w
#w, "Trapclose QuitDemo"
Wait
Sub QuitDemo handle$
Close #handle$
EndSub
Unrecognized Windows Constants
There are well over 55,000 Windows Constants in use. Many, but not all, Windows constants are recognized by Liberty BASIC. WS_EX_LAYERED is one of the unrecognized constants. Due to the very number of entries alone, a comprehensive list of such constants would be near impossible to find. In the case of the unrecognized WS_EX_LAYERED, Google that constant to find the decimal or hexadecimal equivalent. Remember, if the constant value is given as a hexadecimal string, you must convert that hexadecimal string to the equivalent decimal number. The decimal equivalent of WS_EX_LAYERED is 524288.
It is best to choose a meaningful variable name. In this case, we'll name the variable WS.EX.LAYERED. Liberty BASIC will halt with an error when trying to use an unrecognized Windows constant
Stylebits - Windows shows how to combine two or more Windows constants within the same addbits, removebits, addextendedbits or removeextendedbits of the Stylebits command. Decimal numbers and variables work just as well in combination.
Demo1: Removing the Maximize and Minimize Buttons using Windows Constants in the Stylebits command
Stylebits #w, 0, _WS_MAXIMIZEBOX or _WS_MINIMIZEBOX, 0, 0
Open"No Max/Min Boxes"for Window as #w
#w, "Trapclose QuitDemo"
Wait
Sub QuitDemo handle$
Close #handle$
EndEndSub
Demo2: Removing the Maximize and Minimize Buttons using literals and variables in the Stylebits command
WS.MAXIMIZEBOX = 65536
Stylebits #w, 0, 131072 or WS.MAXIMIZEBOX, 0, 0
Open"No Max/Min Boxes"for Window as #w
#w, "Trapclose QuitDemo"
Wait
Sub QuitDemo handle$
Close #handle$
EndEndSub
Beyond Stylebits
Windows constants can be applied in many other coding situations. One example is passing parameters to a CallDLL #gdi32. Windows constants for opaque and transparent background colors are BKMODE_OPAQUE and BKMODE_TRANSPARENT respectively. Since neither of these constants are recognized by Liberty BASIC, then the value of 1 or 2 must be passed into any CallDLL #gdi32 as either a literal or a variable. The information here can be applied to many other circumstances when the Windows constant is unrecognized by Liberty BASIC and the decimal value is known to the programmer.
Stylebits and Windows Constants
Janet Terra
Recognized Windows Constants
Many of the Windows constants are recognized by Liberty BASIC by preceding that constant with an underscore. As an example, the decimal equivalent of WS_EX_TOOLWINDOW (MSDN Defines a Tool Window here) is 128. With the preceding underscore, Liberty BASIC accurately interprets that constant.
Print _WS_EX_TOOLWINDOW ' Prints 128While it is most convenient to use the Windows constant itself, the numerical equivalent (either the literal or a variable) can be used just as easily in the Stylebits command.
is the same as
is the same as
exStyle = 128 Stylebits 0, 0, exStyle, 0This variable must be in decimal (not hexademical) form. If necesssary, use the Liberty BASIC HexDec() function to convert a hexademical value to a decimal value.
Demo 1: Opening a Tool Window using the Windows Constant in the Stylebits command
Demo 2: Opening a Tool Window using the literal decimal value in the Stylebits command
Demo 3: Opening a Tool Window using a variable in the Stylebits command
Unrecognized Windows Constants
There are well over 55,000 Windows Constants in use. Many, but not all, Windows constants are recognized by Liberty BASIC. WS_EX_LAYERED is one of the unrecognized constants. Due to the very number of entries alone, a comprehensive list of such constants would be near impossible to find. In the case of the unrecognized WS_EX_LAYERED, Google that constant to find the decimal or hexadecimal equivalent. Remember, if the constant value is given as a hexadecimal string, you must convert that hexadecimal string to the equivalent decimal number. The decimal equivalent of WS_EX_LAYERED is 524288.
It is best to choose a meaningful variable name. In this case, we'll name the variable WS.EX.LAYERED. Liberty BASIC will halt with an error when trying to use an unrecognized Windows constant
but will happilly accept either
or
WS.EX.LAYERED = 524288 Stylebits #w, 0, 0, WS.EX.LAYERED, 0Combining Stylebits
Stylebits - Windows shows how to combine two or more Windows constants within the same addbits, removebits, addextendedbits or removeextendedbits of the Stylebits command. Decimal numbers and variables work just as well in combination.
Demo1: Removing the Maximize and Minimize Buttons using Windows Constants in the Stylebits command
Demo2: Removing the Maximize and Minimize Buttons using literals and variables in the Stylebits command
WS.MAXIMIZEBOX = 65536 Stylebits #w, 0, 131072 or WS.MAXIMIZEBOX, 0, 0 Open "No Max/Min Boxes" for Window as #w #w, "Trapclose QuitDemo" Wait Sub QuitDemo handle$ Close #handle$ End End SubBeyond Stylebits
Windows constants can be applied in many other coding situations. One example is passing parameters to a CallDLL #gdi32. Windows constants for opaque and transparent background colors are BKMODE_OPAQUE and BKMODE_TRANSPARENT respectively. Since neither of these constants are recognized by Liberty BASIC, then the value of 1 or 2 must be passed into any CallDLL #gdi32 as either a literal or a variable. The information here can be applied to many other circumstances when the Windows constant is unrecognized by Liberty BASIC and the decimal value is known to the programmer.