largo_winch
27-12-2011, 20:11
(reorganized this example)
System Colors:
' Empty GUI script created on 12-27-2011 19:04:35 by (ThinAIR)
'this example shows a view of the system color palette.
'--------------------------------------------------------->
Uses "UI", "console"
%ButtonClose = 1001
%Labels = 1002
Declare Function GetSysColor Lib "USER32.DLL" Alias "GetSysColor" (ByVal nIndex As Long) As Long
Type rgbaColor
r As Byte
g As Byte
b As Byte
a As Byte
End Type
Union rgbaOver
p As rgbaColor
v As LONG
End Union
Function TBMain () As Long
Dim hDlg As Long
Dim w As Long, h As Long
Dim x As Long, y As Long, i As Long
Dim fg As Long, bg As Long
Dim gray As Long
Dim names(31) As String
Dim myRgba As rgbaOver
' Array Assign ArrayVariable([StartIndex]) = Expression1 [, Expression2 [, ...] ]
Array Assign names() = "COLOR_SCROLLBAR", "COLOR_BACKGROUND", "COLOR_ACTIVECAPTION", "COLOR_INACTIVECAPTION", _
"COLOR_MENU", "COLOR_WINDOW", "COLOR_WINDOWFRAME", "COLOR_MENUTEXT", "COLOR_WINDOWTEXT", _
"COLOR_CAPTIONTEXT", "COLOR_ACTIVEBORDER", "COLOR_INACTIVEBORDER", "COLOR_APPWORKSPACE", _
"COLOR_HIGHLIGHT", "COLOR_HIGHLIGHTTEXT", "COLOR_BTNFACE", "COLOR_BTNSHADOW", _
"COLOR_GRAYTEXT", "COLOR_BTNTEXT", "COLOR_INACTIVECAPTIONTEXT", "COLOR_BTNHIGHLIGHT", _
"COLOR_3DDKSHADOW", "COLOR_3DLIGHT", "COLOR_INFOTEXT", "COLOR_INFOBK", "NONE", _
"COLOR_HOTLIGHT", "COLOR_GRADIENTACTIVECAPTION", "COLOR_GRADIENTINACTIVECAPTION", _
"COLOR_MENUHILIGHT", "COLOR_MENUBAR"
y = 10
x = 10
Dialog New Pixels, 0, "System Colors", -1,-1, 670, 324, %WS_OVERLAPPEDWINDOW Or %WS_VISIBLE Or %WS_CAPTION Or %WS_SYSMENU, 0 To hDlg
'CONTROL ADD BUTTON, hDlg, %ButtonClose, "Click to kill", 90, 50, 40, 14
Dialog Get Client hDlg To w, h
For i = 1 To 30
Control Add Label, hDlg, %Labels+i, names(i) + " (" + Format$(i,"0") + ")", x, y, 210, 23, %SS_CENTER Or %SS_SUNKEN Or %SS_CENTERIMAGE
bg = GetSysColor(i-1) 'trick for thinbasic as 0 doesn't exist in arrays
myRgba.v = bg
gray = (myRgba.p.R*.299 + myRgba.p.G*.587 + myRgba.p.B*.114)
If gray>128 Then
fg = %BLACK
Else
fg = %RGB_WHITE
End If
Control Set Color hDlg, %Labels+i, fg, bg
x +=220
If x+210 > w Then x = 10: y+= 28
Next
Dialog Show Modal hDlg, Call cbDialog
End Function
CallBack Function cbDialog() As Long
Select Case CBMSG
Case %WM_COMMAND
If CBWPARAM = %ButtonClose Then Dialog End CBHNDL
Case %WM_DESTROY
MsgBox 0, "Window is to be destroyed."
End Select
End Function
Critic: if anyone like this example or copied this would be fair
to make a critic or comment about that example.
but I am sad about such one: sometimes I think it' s
like a supermarket where's all things for free to get.
so you are always shopping here for free and nobody say's
thank you for the gifts. can you tell me why this unfriendly
behaviour is usual here at board? there's always a lot of work
or time spending with these examples, you can imagine.
I wanted to make thinbasic better and learn with these language.
what's your opinion they are always getting these things for free?
bye, largo
System Colors:
' Empty GUI script created on 12-27-2011 19:04:35 by (ThinAIR)
'this example shows a view of the system color palette.
'--------------------------------------------------------->
Uses "UI", "console"
%ButtonClose = 1001
%Labels = 1002
Declare Function GetSysColor Lib "USER32.DLL" Alias "GetSysColor" (ByVal nIndex As Long) As Long
Type rgbaColor
r As Byte
g As Byte
b As Byte
a As Byte
End Type
Union rgbaOver
p As rgbaColor
v As LONG
End Union
Function TBMain () As Long
Dim hDlg As Long
Dim w As Long, h As Long
Dim x As Long, y As Long, i As Long
Dim fg As Long, bg As Long
Dim gray As Long
Dim names(31) As String
Dim myRgba As rgbaOver
' Array Assign ArrayVariable([StartIndex]) = Expression1 [, Expression2 [, ...] ]
Array Assign names() = "COLOR_SCROLLBAR", "COLOR_BACKGROUND", "COLOR_ACTIVECAPTION", "COLOR_INACTIVECAPTION", _
"COLOR_MENU", "COLOR_WINDOW", "COLOR_WINDOWFRAME", "COLOR_MENUTEXT", "COLOR_WINDOWTEXT", _
"COLOR_CAPTIONTEXT", "COLOR_ACTIVEBORDER", "COLOR_INACTIVEBORDER", "COLOR_APPWORKSPACE", _
"COLOR_HIGHLIGHT", "COLOR_HIGHLIGHTTEXT", "COLOR_BTNFACE", "COLOR_BTNSHADOW", _
"COLOR_GRAYTEXT", "COLOR_BTNTEXT", "COLOR_INACTIVECAPTIONTEXT", "COLOR_BTNHIGHLIGHT", _
"COLOR_3DDKSHADOW", "COLOR_3DLIGHT", "COLOR_INFOTEXT", "COLOR_INFOBK", "NONE", _
"COLOR_HOTLIGHT", "COLOR_GRADIENTACTIVECAPTION", "COLOR_GRADIENTINACTIVECAPTION", _
"COLOR_MENUHILIGHT", "COLOR_MENUBAR"
y = 10
x = 10
Dialog New Pixels, 0, "System Colors", -1,-1, 670, 324, %WS_OVERLAPPEDWINDOW Or %WS_VISIBLE Or %WS_CAPTION Or %WS_SYSMENU, 0 To hDlg
'CONTROL ADD BUTTON, hDlg, %ButtonClose, "Click to kill", 90, 50, 40, 14
Dialog Get Client hDlg To w, h
For i = 1 To 30
Control Add Label, hDlg, %Labels+i, names(i) + " (" + Format$(i,"0") + ")", x, y, 210, 23, %SS_CENTER Or %SS_SUNKEN Or %SS_CENTERIMAGE
bg = GetSysColor(i-1) 'trick for thinbasic as 0 doesn't exist in arrays
myRgba.v = bg
gray = (myRgba.p.R*.299 + myRgba.p.G*.587 + myRgba.p.B*.114)
If gray>128 Then
fg = %BLACK
Else
fg = %RGB_WHITE
End If
Control Set Color hDlg, %Labels+i, fg, bg
x +=220
If x+210 > w Then x = 10: y+= 28
Next
Dialog Show Modal hDlg, Call cbDialog
End Function
CallBack Function cbDialog() As Long
Select Case CBMSG
Case %WM_COMMAND
If CBWPARAM = %ButtonClose Then Dialog End CBHNDL
Case %WM_DESTROY
MsgBox 0, "Window is to be destroyed."
End Select
End Function
Critic: if anyone like this example or copied this would be fair
to make a critic or comment about that example.
but I am sad about such one: sometimes I think it' s
like a supermarket where's all things for free to get.
so you are always shopping here for free and nobody say's
thank you for the gifts. can you tell me why this unfriendly
behaviour is usual here at board? there's always a lot of work
or time spending with these examples, you can imagine.
I wanted to make thinbasic better and learn with these language.
what's your opinion they are always getting these things for free?
bye, largo