0

How do I create custom colors?

I do not like the color for the clRed, nor the clMaroon. I want a red that is the same color as this hex value: #AA0000.

This will help a lot to make the form look exactly how I planned it.

Thanks,

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by FlamingClaw
0

I worked out a solution
create a new winapps,put a panel and a button and an editbox onto the form

unit colors_in_hex;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    GroupBox1: TGroupBox;
    Edit1: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var hexnum:String;
    res:Integer;
const
  HexValues='0123456789ABCDEF';
function HexToInt(Hex: string): integer;
var
  i: integer;
begin
  Result := 0;
  case Length(Hex) of
    0: Result := 0;
    1..8: for i:=1 to Length(Hex) do
      Result := 16*Result + Pos(Upcase(Hex[i]), HexValues)-1;
    else for i:=1 to 8 do
      Result := 16*Result + Pos(Upcase(Hex[i]), HexValues)-1;
  end;
end;


begin
  hexnum:=Edit1.Text;
  res:=hextoint(hexnum);
  Panel1.Color:=res;
end;

end.

when you done then write a number to the edit box and press the button

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.