How to define color constants? lazarus / 31-LCL ---------------------------------------------------------------------- stem · 2018-06-19 17:51 Hi, I want to have color constants in a separate unit. The line Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i MYCOLOR = TColor($FF0000); gets compiled, but using the color in Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i xyz.Canvas.Pen.Color := MYCOLOR; results in having the color blue, although I wanted to have red. What am I doing wrong? Thank you! stem ---------------------------------------------------------------------- wp · 2018-06-19 17:55 TColor has the oppositve byte order of HTML: TColor = $ssBBGGRR (ss used for system colors, is zero for "normal" colors)), HTML = #RRGGBB. ---------------------------------------------------------------------- Thaddy · 2018-06-19 17:55 Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  const MYCOLOR:TColor = $FF0000; ---------------------------------------------------------------------- Thaddy · 2018-06-19 18:00 Quote from: wp on June 19, 2018, 07:55:25 pmTColor has the oppositve byte order of HTML: TColor = $ssBBGGRR (ss used for system colors), HTML = #RRGGBB. Unless you read something more than I did (html): his declaration is wrong in the first place. This gets converted back to native resolution, so the cast is useless. ---------------------------------------------------------------------- Handoko · 2018-06-19 18:00 @stem You can use the constants available in unit Graphics. clRed is TColor($0000FF) on my Linux system, on certain OS/hardware it may be different. Here I copied/pasted some part of the code in unit Graphics: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i const  // The following colors match the predefined Delphi Colors   // standard colors  clBlack   = TColor($000000);  clMaroon  = TColor($000080);  clGreen   = TColor($008000);  clOlive   = TColor($008080);  clNavy    = TColor($800000);  clPurple  = TColor($800080);  clTeal    = TColor($808000);  clGray    = TColor($808080);  clSilver  = TColor($C0C0C0);  clRed     = TColor($0000FF);  clLime    = TColor($00FF00);  clYellow  = TColor($00FFFF);  clBlue    = TColor($FF0000);  clFuchsia = TColor($FF00FF);  clAqua    = TColor($FFFF00);  clLtGray  = TColor($C0C0C0); // clSilver alias  clDkGray  = TColor($808080); // clGray alias  clWhite   = TColor($FFFFFF);  StandardColorsCount = 16;   // extended colors  clMoneyGreen = TColor($C0DCC0);  clSkyBlue    = TColor($F0CAA6);  clCream      = TColor($F0FBFF);  clMedGray    = TColor($A4A0A0);  ExtendedColorCount = 4;   // special colors  clNone    = TColor($1FFFFFFF);  clDefault = TColor($20000000);   // system colors  clScrollBar               = TColor(SYS_COLOR_BASE or COLOR_SCROLLBAR);  clBackground              = TColor(SYS_COLOR_BASE or COLOR_BACKGROUND);  clActiveCaption           = TColor(SYS_COLOR_BASE or COLOR_ACTIVECAPTION);  clInactiveCaption       = TColor(SYS_COLOR_BASE or COLOR_INACTIVECAPTION);  clMenu                  = TColor(SYS_COLOR_BASE or COLOR_MENU);  clWindow                = TColor(SYS_COLOR_BASE or COLOR_WINDOW);  clWindowFrame           = TColor(SYS_COLOR_BASE or COLOR_WINDOWFRAME);  clMenuText              = TColor(SYS_COLOR_BASE or COLOR_MENUTEXT);  clWindowText            = TColor(SYS_COLOR_BASE or COLOR_WINDOWTEXT);  clCaptionText           = TColor(SYS_COLOR_BASE or COLOR_CAPTIONTEXT);  clActiveBorder            = TColor(SYS_COLOR_BASE or COLOR_ACTIVEBORDER);  clInactiveBorder          = TColor(SYS_COLOR_BASE or COLOR_INACTIVEBORDER);  clAppWorkspace          = TColor(SYS_COLOR_BASE or COLOR_APPWORKSPACE);  clHighlight             = TColor(SYS_COLOR_BASE or COLOR_HIGHLIGHT);  clHighlightText         = TColor(SYS_COLOR_BASE or COLOR_HIGHLIGHTTEXT);  clBtnFace               = TColor(SYS_COLOR_BASE or COLOR_BTNFACE);  clBtnShadow             = TColor(SYS_COLOR_BASE or COLOR_BTNSHADOW);  clGrayText              = TColor(SYS_COLOR_BASE or COLOR_GRAYTEXT);  clBtnText               = TColor(SYS_COLOR_BASE or COLOR_BTNTEXT);  clInactiveCaptionText     = TColor(SYS_COLOR_BASE or COLOR_INACTIVECAPTIONTEXT);  clBtnHighlight            = TColor(SYS_COLOR_BASE or COLOR_BTNHIGHLIGHT);  cl3DDkShadow            = TColor(SYS_COLOR_BASE or COLOR_3DDKSHADOW);  cl3DLight               = TColor(SYS_COLOR_BASE or COLOR_3DLIGHT);  clInfoText              = TColor(SYS_COLOR_BASE or COLOR_INFOTEXT);  clInfoBk                = TColor(SYS_COLOR_BASE or COLOR_INFOBK);   clHotLight              = TColor(SYS_COLOR_BASE or COLOR_HOTLIGHT);  clGradientActiveCaption   = TColor(SYS_COLOR_BASE or COLOR_GRADIENTACTIVECAPTION);  clGradientInactiveCaption = TColor(SYS_COLOR_BASE or COLOR_GRADIENTINACTIVECAPTION);  clMenuHighlight           = TColor(SYS_COLOR_BASE or COLOR_MENUHILIGHT);  clMenuBar               = TColor(SYS_COLOR_BASE or COLOR_MENUBAR);  clForm                    = TColor(SYS_COLOR_BASE or COLOR_FORM);   // synonyms: do not show them in color lists  clColorDesktop            = TColor(SYS_COLOR_BASE or COLOR_DESKTOP);  cl3DFace                  = TColor(SYS_COLOR_BASE or COLOR_3DFACE);  cl3DShadow                = TColor(SYS_COLOR_BASE or COLOR_3DSHADOW);  cl3DHiLight               = TColor(SYS_COLOR_BASE or COLOR_3DHIGHLIGHT);  clBtnHiLight              = TColor(SYS_COLOR_BASE or COLOR_BTNHILIGHT); ---------------------------------------------------------------------- Thaddy · 2018-06-19 18:05 const or vars? If they are not declared as I showed those are bugs. ---------------------------------------------------------------------- Handoko · 2018-06-19 18:09 clRed is declared as a const in unit Graphics. ---------------------------------------------------------------------- wp · 2018-06-19 18:10 Quote from: Thaddy on June 19, 2018, 08:00:10 pmhis declaration is wrong in the first place. His declaration is correct (see the declaration of the clXXX constants in unit graphics). What's wrong is that he is writing the bytes in the wrong order. In TColor the red-green-blue bytes must be read from right to left - unlike HTML where they are read from left to right. ---------------------------------------------------------------------- wp · 2018-06-19 18:12 Quote from: Thaddy on June 19, 2018, 08:05:50 pmconst or vars? Hey come on Thaddy - an experienced guy like you knows that a var cannot be declared without type. ---------------------------------------------------------------------- stem · 2018-06-19 18:44 Thank you! ---------------------------------------------------------------------- valdir.marcos · 2018-06-22 03:26 Quote from: Thaddy on June 19, 2018, 08:05:50 pmconst or vars? If they are not declared as I showed those are bugs. Quote from: wp on June 19, 2018, 08:10:57 pmQuote from: Thaddy on June 19, 2018, 08:00:10 pmhis declaration is wrong in the first place. His declaration is correct (see the declaration of the clXXX constants in unit graphics). What's wrong is that he is writing the bytes in the wrong order. In TColor the red-green-blue bytes must be read from right to left - unlike HTML where they are read from left to right. Quote from: wp on June 19, 2018, 08:12:47 pmQuote from: Thaddy on June 19, 2018, 08:05:50 pmconst or vars? Hey come on Thaddy - an experienced guy like you knows that a var cannot be declared without type. Good to see that Thaddy can make mistakes as any of us!...