Donate Now Goal amount for this month: 100 USD, Received: 0 USD (0%)
Donate to support this site and ThinBASIC project development

Results 1 to 1 of 1

Thread: system colors

  1. #1

    system colors

    (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
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	system-colors-go.jpg 
Views:	49 
Size:	64.0 KB 
ID:	7745  
    Last edited by largo_winch; 30-12-2011 at 17:37.

Similar Threads

  1. Anaglyph - is it possible to preserve colors?
    By Petr Schreiber in forum Real world situations and solutions using thinBasic
    Replies: 4
    Last Post: 02-02-2010, 23:10
  2. Console Colors
    By danbaron in forum General purpose scripts
    Replies: 0
    Last Post: 30-01-2010, 08:21
  3. console_box colors
    By sandyrepope in forum Console
    Replies: 4
    Last Post: 30-06-2008, 10:18
  4. colors and console_printat
    By sandyrepope in forum Console
    Replies: 4
    Last Post: 22-02-2007, 17:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •