http://files.cnblogs.com/xe2011/StringToColor.rar

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls; type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm} uses IniFiles; procedure TForm1.Button1Click(Sender: TObject);
begin
Caption := ExtractFilePath(Application.ExeName);
end; procedure TForm1.Button2Click(Sender: TObject);
begin
Color := StringToColor('clRed');
end; procedure SaveConfig(fileName: string; Form: TForm);
var
f:string;
begin
f:=ExtractFilePath(Application.ExeName) + fileName;
with TIniFile.Create( f ) do
begin
WriteString('MainForm', 'Color', ColorToString(Form.Color));
end;
end; procedure LoadConfig(fileName: string; Form: TForm);
var
s:string;
f:string;
begin
f:=ExtractFilePath(Application.ExeName) + fileName;
with TIniFile.Create(f) do
begin
s:= ReadString('MainForm', 'Color', 'clBtnFace');
Form.Color := StringToColor(s);
end;
end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
SaveConfig('Config.ini',Form1);
end; procedure TForm1.FormCreate(Sender: TObject);
begin
LoadConfig('Config.ini',Form1);
end; end.

Delphi 颜色转换的更多相关文章

  1. delphi 颜色转换函数总结

    unit UColor; interface uses windows, sysutils, classes, graphics; function HexToInt(Hexa: String): L ...

  2. iOS中RGB颜色转换

    iOS中RGB常用的色值,同时可将对颜色的设置定义成宏,方便开发应用,如: // RGB颜色转换(16进制->10进制) #define UIColorFromRGB(rgbValue) [UI ...

  3. UIColor各种颜色转换

    1.Hex值颜色转换 #import <UIKit/UIKit.h> @interface UIColor (Extension) // 根据无符号的32位整数转换为对应的RGB颜色 + ...

  4. js颜色转换

    很久之前面试遇到过一个题.写个颜色转换的方法. function RGB2Color(r,g,b) { return '#' + byte2Hex(r) + byte2Hex(g) + byte2He ...

  5. C语言颜色转换宏

    C语言颜色转换宏 #define COLOR_BPP16_RGB555 /* Win RGB */ #define COLOR_RGB(r,g,b) ((COLORREF)(((BYTE)(r)|(( ...

  6. iOS开发-16进制颜色转换

    项目中经常会用到颜色转换,有的是通过十六进制转成数字转颜色,想简单的点直接通过字符串转一下,简单扩展了一下分类UIColor,代码如下: +(UIColor *)colorWithHex:(NSStr ...

  7. OpenCV颜色转换和皮肤检测

    本笔记重点记录OpenCV中的颜色转换和利用色彩空间的特性进行皮肤检测 颜色转换 实现原理 之所以要引入色调/饱和度/亮度的色彩空间概念,是因为人们喜欢凭直觉分辨各种颜色,而它与这种方式吻合.实际上, ...

  8. delphi OleVariant转换RecordSet

    delphi OleVariant转换RecordSet uses Data.Win.ADODB; function varToRecordSet( parms : OleVariant ) : Da ...

  9. delphi 颜色,字体保存到INI文件

    颜色转换成整型保存{也可以用ColorToString  / stringTOColor}字体用下面的函数转换成字符串,然后保存 unit xFonts; interface uses Classes ...

随机推荐

  1. demo_04绘制三角形

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  2. SVN遇到Can't convert string from 'UTF-8' to native encoding

    刚配好mysql,svn co代码的时候遇到问题 svn: Can't convert string from 'UTF-8' to native encoding: svn: platform/co ...

  3. 转: QtCreator调试程序时GDB崩溃

    这个情况出现在QtCreator的2.5版以上,是由于新版QtCreator至少需要7.2 IIRC版的GDB.可以到:http://builds.qt-project.org/job/gdb-win ...

  4. [译]36 Days of Web Testing(六)

    Day 30 Test in situ  真实场景下的测试 为什么? 我十分推崇现场测试,简单讲就是要在你的站点或应用真实使用的场景下进行测试.但随着人口增长,对于"真实场景"的定 ...

  5. Spring MVC和Struts2的区别

    1. 机制:spring mvc的入口是servlet,而struts2是filter,这样就导致了二者的机制不同. 2. 性能:spring会稍微比struts快.spring mvc是基于方法的设 ...

  6. Microsoft HoloLens 技术解谜(下)

    读者提问之“HoloLens 的深度传感器有没有可能是基于 TOF?” 先介绍下背景知识,市面上常见的有三种类型的深度传感器: 结构光,这个技术的代表产品是 Kinect 一代,它的传感器芯片用的是 ...

  7. OTG线与普通USB线的区别

    转自OTG线与普通USB线的区别 USB数据线是我们常见的设备,OTG线作为近年来随着手机行业的快速发展,逐步进入了我们的日常使用范围.OTG线与普通USB线的有什么区别?       USB数据线用 ...

  8. Katu Puzzle

    poj3678:http://poj.org/problem?id=3678 题意:给你一些数,然后这些要么是0要么是1,然后回给出一些数之间的and,or,xor的值,问你是否存在一组解. 题解:2 ...

  9. Party

    hdu3062:http://acm.hdu.edu.cn/showproblem.php?pid=3062 题意:中文题. 题解:很明显的2-sat.然后要深刻理解命题和逆否命题.如这一题,c1,c ...

  10. 在DJANGO的类视图中实现登陆要求和权限保护

    以前接触的是基于函数的保护,网上材料比较多. 但基于类视图的很少. 补上! Decorating class-based views 装饰类视图 对于类视图的扩展并不局限于使用mixin.你也可以使用 ...