How do I make speedbutton colors correctly bright? lazarus / 31-LCL ---------------------------------------------------------------------- bd4kc · 2020-12-14 13:02 I want to do a big, very visible button, acting as a warning in the process of controlling machinery. I set its color, clred, but the red is very dark, and then I use tpanel, the color is bright red. ---------------------------------------------------------------------- winni · 2020-12-14 16:41 Hi! If I set the SpeedButton.color this does not matter - it stays gray. This is OS depenent. Use this: 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   With SpeedButton1.glyph do     begin       width := SpeedButton1.width;     height:= SpeedButton1.height;       canvas.brush.color := clRed;     canvas.fillrect(0,0,width,height);     end;                                   Winni ---------------------------------------------------------------------- bd4kc · 2020-12-14 18:27 THX,I used speedbtn1.canvas.brush.color: =clred; speedbtn1.canvas.fillrect(speedbtn1.clientrect); still got a dark red, not bright red. ---------------------------------------------------------------------- bd4kc · 2020-12-14 19:04 Your code is working properly. What was my mistake? 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 { TForm1 } procedure TForm1.sb1Click(Sender: TObject);begin sb1.Color:=clred; //no effect sb1.Canvas.Brush.Color:=clred; sb1.Glyph.Canvas.Brush.Colo r:=clred; sb1.Canvas.FillRect(sb1.Canvas.ClipRect); sb1.Glyph.Canvas.F illRect(sb1.Canvas.ClipRect);end; procedure TForm1.Button1Click(Sender: TObject);begin  with sb1.Glyph  do     //winni taught me ,work wellbeginwidth:=sb1.Width;  height:=sb1.Height;  canvas.Brush.Color:=clred;  canvas.FillRect(0,0,width,height);  end;end;      Quote from: winni on December 14, 2020, 05:41:17 pmHi! If I set the SpeedButton.color this does not matter - it stays gray. This is OS depenent. Use this: 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   With SpeedButton1.glyph do     begin       width := SpeedButton1.width;     height:= SpeedButton1.height;       canvas.brush.color := clRed;     canvas.fillrect(0,0,width,height);     end;                                   Winni ---------------------------------------------------------------------- winni · 2020-12-14 19:05 Hi What is your OS/Widgetset ??? I did this with Linux64/gtk2 and I got a clear clRed = $0000FF Lack of color inside Windows? Or is your screen hard out of calibration? Winni ---------------------------------------------------------------------- bd4kc · 2020-12-14 19:12 Oh, I see, glyph's width and height are 0 until you set them. ---------------------------------------------------------------------- winni · 2020-12-14 19:17 Bravo! You got it! And forget about the SpeedButton.color. On the most OS that does not work. And dont rely on the metrics of the canvas. It is some kind of fraggle code. Delphi does not have that. Take the dimensions either of the button itself or of the glyph. Winni ---------------------------------------------------------------------- bd4kc · 2020-12-14 20:48 Speedbutton still has the problem of caption being pushed aside. Looks like my usage - big buttons, not quite right. I'm going to download some industrial components and study how they're drawn. I write code on two computers, win10 and ubuntu. Is used to debug a machine, my partner draws drawings, we go to the factory to make parts. It is equipped with 3 servo motors, some homemade circuit boards, many sensors, many microprocessor chips (I am familiar with hardware, circuits, microprocessor assembly language these things, and computer programming is very different) and so on. I made a communication interface with microchips, and then Wrote code on this side of the computer to communicate with them, debugging is more convenient, can work like an office. No one around me uses native code programming, everyone is passionate about web front-end programming or python, and young people don't want to do some bottom-level work, which can mess up their shirts. I can't find anyone around for advice, only warm-hearted friends here, even though the connection to foreign websites here is very slow and disconnects from time to time. ---------------------------------------------------------------------- jamie · 2020-12-14 22:50 The cliprect in the canvas is not the be used that way... Its only there it mark an area for limiting the painting area you want to use the ClientRect for your surface area when calculating because it reports exactly what is visible in the control even if you had scrollbars.  IF you are every doing this with a control that does have scrollbars you also need to use the X,Y Pos of the scroll bars as an offset to your drawing points  But here you are using a Speedbutton which has no scroll bars, so don't worry.. ---------------------------------------------------------------------- winni · 2020-12-15 00:51 Hi! With a big button forget the caption. Put an empty string into it. And then: 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 with Speedbutton.glyph.canvas do   begin   font.height := 32;   font.color :=  clBlue;   TextOut (1,1,'I am a real caption');   end;  done Winni