怎样实现这个样子..

qdsunboy 2003-03-13 09:46:11
2个EDIT
1个BUTTON
在其中一个EDIT输入DELPHI里的颜色代码.例如$00009F00
点击按钮后在另一个EDIT里显示出RGB代码也就是网页里用的颜色#******

麻烦详细一点的代码..谢谢了.分不够再加.
...全文
36 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yczyk 2003-03-14
  • 打赏
  • 举报
回复
同意楼上的!
hjb8000 2003-03-14
  • 打赏
  • 举报
回复
ColorToRGB
NightCloud 2003-03-13
  • 打赏
  • 举报
回复
uses Graphics;
然后使用如下的函数:
function ColorToRGB(Color: TColor): Longint;

edit2.text:=InttoStr(ColorToRGB($00009F000));

edit2.text:=InttoStr(ColorToRGB(StrToInt(edit1.text)));


lxl 2003-03-13
  • 打赏
  • 举报
回复
Delphi的颜色数值的位排列顺序是BGR而HTML则是RGB。
所以你只要作一个操作将这几位调换一下并转换成为十六进制就可以了
function DELPHIColorToRGB(Color:TColor):integer;
var
i:integer;
myrgb:array[0..2] of BYTE;
begin
for i:=0 to 2 do
begin
myrgb[i]:=Color and $ff;
Color:=Color shr 8;
end;
Result:=RGB(myrgb[2],myrgb[1],myrgb[0]);
end;

qdsunboy 2003-03-13
  • 打赏
  • 举报
回复
能不能麻烦用中文.然后详细一点我初学...谢谢了...
ly_liuyang 2003-03-13
  • 打赏
  • 举报
回复
Converts a TColor value into an RGB representation of the color.

Unit

Graphicsor QGraphics

Category

graphics utilities

Delphi syntax:

function ColorToRGB(Color: TColor): Longint;

C++ syntax:

extern PACKAGE int __fastcall ColorToRGB(TColor Color);

Description

Call ColorToRGB to obtain an RGB representation of a color for using with Windows API calls. ColorToRGB strips away the information that is stored in the highest order bits about which palette to use for colors that are not always available.

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧