TColor to HTML color

CK CK 3776 
Created at
Updated at  
410 0 0

Put a TColorDialog (ColorDialog1), a TLabel (Label1) and a TButton (Button1) in your form, and assign the Button1.OnClick procedure as follows:

procedure TForm1.Button1Click(Sender: TObject) ;

  function ColorToHtml(DColor:TColor):string;
  var
    tmpRGB : TColorRef;
  begin
    tmpRGB := ColorToRGB(DColor) ;
    Result:=Format('#%.2x%.2x%.2x',
                   [GetRValue(tmpRGB),
                    GetGValue(tmpRGB),
                    GetBValue(tmpRGB)]) ;
  end; {function ColorToHtml}

begin
  if ColorDialog1.Execute then
   Label1.Caption:=ColorToHtml(ColorDialog1.Color) ;
end;
Tags HTML Color Value SaveToFile TDesktopCanvas cmWhiteness Facebook X
Comments 0
Similar posts
  1. Show *any* graphics as Glyph on a SpeedButton
    535
  2. TDesktopCanvas - draw on Windows Desktop
    547
  3. Rotating Text
    444
  4. TImage.Bitmap fade out
    369
  5. Paint a Form with a tiled bitmap image
    408
  6. Rotate Bitmap (any angle, any center of rotation)
    403
  7. Is Point in Polygon?
    367
  8. Implementing a lasso drawing technique
    381
  9. Grayscaling a bitmap ?
    527
  10. Get Cursor Image (draw it on a Canvas)
    681
  11. How to convert HIcon to TIcon ?
    446
  12. Extract an icon from an Windows application and paint on a Form
    412
  13. How to draw transparent text on Windows Desktop
    407
  14. How to convert an ICO to a BMP
    358
  15. How to capture Windows Desktop to Bitmap
    558
  16. Cut a rectangle from an Image to Clipboard
    533
  17. Convert TColor to Hex & Hex to TColor
    583
  18. Convert a BMP to a JPG
    405
  1. Copying Group of Files using Delphi with Standard Animation Dialog (SHFileOperation)
    411
  2. Controling sound volume from code
    417
  3. How to Close Another Application by Windows Caption
    384
  4. How to Change the Windows Start button bitmap
    421
  5. How to capture the output from a DOS (command/console) Window
    960
  6. How to Activate/Deactivate the Screen Saver
    855
  7. Retrieving all image links from an HTML document
    414
  8. List All Network Drives
    389
  9. How to set the "home page" for the Internet Explorer from Delphi code
    428
  10. How to get get IE favorites
    448
  11. Extracting the domain (host) name from an e-mail address
    482
  12. Download a file from the Internet with progress indicator
    550
  13. Are we connected to the Internet?
    419
  14. TImage.Bitmap fade out
    369
  15. TDesktopCanvas - draw on Windows Desktop
    547
  16. Show *any* graphics as Glyph on a SpeedButton
    535
  17. Rotating Text
    444
  18. Paint a Form with a tiled bitmap image
    408
  19. Is Point in Polygon?
    367
  20. Implementing a lasso drawing technique
    381
  21. Grayscaling a bitmap ?
    527
  22. Get Cursor Image (draw it on a Canvas)
    681
  23. How to convert HIcon to TIcon ?
    446
  24. Extract an icon from an Windows application and paint on a Form
    412
  25. How to draw transparent text on Windows Desktop
    407
  26. How to draw rotated text
    1,322
  27. How to convert an ICO to a BMP
    358
  28. How to Convert Pixels to Millimeters
    618
  29. How to capture Windows Desktop to Bitmap
    558
  30. Cut a rectangle from an Image to Clipboard
    533
Recently updated
  1. How do I create animated background for Google Meet?
    18,984
  2. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    192
  3. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    75
  4. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    150
  5. Array of arguments passed to script in PHP
    83
  6. Invalid Auction Storms in Ad Tech
    91
  7. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    194
  8. The Two Clocks of Ad Server Architecture
    61
  9. Frequency Cap Architecture Overview
    505
  10. Collecting Proof-of-Play from 100,000 Screens
    139
  11. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    276
  12. What is RedisVL?
    102
  13. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    218
  14. TPU & GPU Cluster Management Tools
    229
  15. The Concept of Scaffolding in AI Agents
    217
  16. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    568
  17. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    246
  18. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    321
  19. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    196
  20. Machine Learning: Training vs. Ranking
    200
  21. The Continuous Learning Machine: Designing a Loop That Actually Turns
    212
  22. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    188
  23. Designing a Data Curation System Around a Vector Database
    212
  24. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    228
  25. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    646
  26. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    179
  27. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    203
  28. Understanding Data Lineage
    251
  29. System Requirements and Architecture: Intelligent Priority-Based Scheduler
    159
  30. GPU & LLM Cluster Infrastructure & Task Scheduling Architecture
    229