Jump to content

Having problems changing background and text colors in windows


Trax
 Share

Recommended Posts

   This is kind of a side question but it has always driven me a little crazy. A vast majority of times (as in the example below) I have windows that really only contain one value at any given time. I never want to scroll. I never want lists. if I put a value in that windows I want it to overwrite the value that is already there. After looking at all the options I have chosen a listbox. Is that really my best option?

   Anyway..... I have been trying to get things to display in color and am having fits. It might somehow relate to the above side question. I have been using Melba23's example here:

and can't get anything to display in the windows.  Here is my code:

 

<#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=SRT.ico
#AutoIt3Wrapper_Res_Comment=
#AutoIt3Wrapper_Res_Description=
#AutoIt3Wrapper_Run_Au3Stripper=n
#Au3Stripper_Parameters=/so
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
AutoItSetOption("MouseCoordMode", 1) ; 0=Relative to Active Window, 1=Absolute Screen 2=Relitive to Client Area
AutoItSetOption("GUICloseOnESC", 1) ; Close on ESC
#include-once
Opt("TrayMenuMode", 1)

#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <CommInterface.au3>
#include <GuiListBox.au3>
#include <Date.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <File.au3>
#include <GuiRichEdit.au3>

#Region ### START Koda GUI section ### Form=c:\users\jimbecher\desktop\idem v2.10\koda_1.7.2.0\forms\efdeck.kxf
$EFDeck = GUICreate("EF Deck Display", 755, 248, 1001, 271)
$EFDAvgTemp1  = _GUICtrlRichEdit_Create ($EFDeck,"", 184, 24, 57, 19)
$EFDAvgTemp2  = _GUICtrlRichEdit_Create ($EFDeck,"", 184, 112, 57, 19)
$EFDAvgTemp3  = _GUICtrlRichEdit_Create ($EFDeck,"", 184, 200, 57, 19)
$EFDLimit1    = _GUICtrlRichEdit_Create ($EFDeck,"", 328, 24, 57, 19)
$EFDLimit2    = _GUICtrlRichEdit_Create ($EFDeck,"", 328, 112, 57, 19)
$EFDLimit3    = _GUICtrlRichEdit_Create ($EFDeck,"", 328, 200, 57, 19)
$EFDExceeded1 = _GUICtrlRichEdit_Create ($EFDeck,"", 528, 24, 17, 19)
$EFDExceeded2 = _GUICtrlRichEdit_Create ($EFDeck,"", 529, 112, 15, 19)
$EFDExceeded3 = _GUICtrlRichEdit_Create ($EFDeck,"", 528, 200, 17, 19)
$EFDReadings1 = _GUICtrlRichEdit_Create ($EFDeck,"", 672, 24, 57, 19)
$EFDReadings2 = _GUICtrlRichEdit_Create ($EFDeck,"", 672, 112, 57, 19)
$EFDReadings3 = _GUICtrlRichEdit_Create ($EFDeck,"", 672, 192, 57, 19)
$Label2 = GUICtrlCreateLabel("Limit Exceeded:", 448, 24, 79, 17)
$Label1 = GUICtrlCreateLabel(" 3 Hr Avg Temp:", 104, 24, 82, 17)
$Label3 = GUICtrlCreateLabel("Readings:", 616, 24, 52, 17)
$Label5 = GUICtrlCreateLabel("Baghouse 1", 32, 24, 61, 17)
$Label9 = GUICtrlCreateLabel("3 Hr Avg Temp:", 104, 112, 79, 17)
$Label10 = GUICtrlCreateLabel("Limit Exceeded:", 448, 112, 79, 17)
$Label11 = GUICtrlCreateLabel("Readings:", 616, 112, 52, 17)
$Label13 = GUICtrlCreateLabel("Baghouse 2", 32, 112, 61, 17)
$Label17 = GUICtrlCreateLabel("3 Hr Avg Temp:", 104, 200, 79, 17)
$Label18 = GUICtrlCreateLabel("Limit Exceeded:", 440, 200, 79, 17)
$Label19 = GUICtrlCreateLabel("Readings:", 616, 192, 52, 17)
$Label21 = GUICtrlCreateLabel("Baghouse 3", 32, 200, 61, 17)
$Label37 = GUICtrlCreateLabel("Limit: ", 296, 24, 31, 17)
$Label38 = GUICtrlCreateLabel("Limit:", 296, 112, 28, 17)
$Label39 = GUICtrlCreateLabel("Limit", 296, 200, 25, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

ColorWrite($EFDLimit1, 1 & @CRLF, -6, "", 0x000000)
ColorWrite($EFDLimit2, 2 & @CRLF, -6, "", 0x000000)
ColorWrite($EFDLimit3, 3 & @CRLF, -6, "", 0x000000)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            Exit
    EndSwitch
WEnd

Func ColorWrite($hWnd, $sText, $iIncrement = 0, $sAttrib = "", $iColor = -1)
    ; Count the @CRLFs
    StringReplace(_GUICtrlRichEdit_GetText($hWnd, True), @CRLF, "")
    Local $iLines = @extended
    ; Adjust the text char count to account for the @CRLFs
    Local $iEndPoint = _GUICtrlRichEdit_GetTextLength($hWnd, True, True) - $iLines
    ; Add new text
    _GUICtrlRichEdit_AppendText($hWnd, $sText & @CRLF)
    ; Select text between old and new end points
    _GuiCtrlRichEdit_SetSel($hWnd, $iEndPoint, -1)
    ; Convert colour from RGB to BGR
    $iColor = Hex($iColor, 6)
    $iColor = '0x' & StringMid($iColor, 5, 2) & StringMid($iColor, 3, 2) & StringMid($iColor, 1, 2)
    ; Set colour
    If $iColor <> -1 Then _GuiCtrlRichEdit_SetCharColor($hWnd, $iColor)
    ; Set size
    If $iIncrement <> 0 Then _GUICtrlRichEdit_ChangeFontSize($hWnd, $iIncrement)
    ; Set weight
    If $sAttrib <> "" Then _GUICtrlRichEdit_SetCharAttributes($hWnd, $sAttrib)
    ; Clear selection
    _GUICtrlRichEdit_Deselect($hWnd)

EndFunc
>

 

Link to comment
Share on other sites

Link to comment
Share on other sites

Thanks @NINE. I haven't found much in the way of color explanations. I assumed (incorrectly) that 0x000000 would be black on white. Where are the colors defined

Still searching and learning. Would I be better off using listview or listviewex? 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...