📄 xgraphics.pas
字号:
unit xGraphics;
interface
uses Windows, Messages, SysUtils, Forms, Controls, Graphics, ShellAPI, Registry;
function ColorToRGBString(AColor: TColor): string;
function RGBStringToColor(RGBStr: string): TColor;
function MyLoadIcon(const Filename: string; DefaultIcon: HICON = 0): HICON;
function CursorToIcon(const hc: HCURSOR; bDestroyCursor: Boolean = False): HICON;
function ColorNumToStr(Num: Integer): string;
implementation
uses xStrings, xFiles;
function ColorToRGBString(AColor: TColor): string;
begin
Result := Format('%d %d %d',[GetRValue(AColor), GetGValue(AColor), GetBValue(AColor)]);
end;
function RGBStringToColor(RGBStr: string): TColor;
var
I : Integer;
R, G, B: Byte;
begin
Result := $00000000;
RGBStr := Trim(RGBStr);
if CountWords(RGBStr) <> 3 then Exit;
// Red Value
I := Pos(' ', RGBStr);
R := StrToIntDef(Copy(RGBStr, 1, I - 1), 0);
Delete(RGBStr, 1, I);
// Green Value
I := Pos(' ', RGBStr);
G := StrToIntDef(Copy(RGBStr, 1, I - 1), 0);
Delete(RGBStr, 1, I);
// Blue
B := StrToIntDef(RGBStr, 0);
Result := RGB(R, G, B);
end;
function MyLoadIcon(const Filename: string;
DefaultIcon: HICON = 0): HICON;
var
IconNo: Integer;
S, Ext: string;
begin
Result := 0;
S := AnsiUpperCase(Filename);
IconNo := TruncateTrailNumber(S);
Ext := ExtractFileExt(S);
if Ext = '.ICO' then
Result := LoadImage(HInstance, PChar(S), IMAGE_ICON, 32, 32,
LR_LOADFROMFILE)
else if ((Ext = '.ICL') or (Ext = '.DLL') or (Ext = '.EXE'))
and (IconNo <> -1) then
Result := ExtractIcon(HInstance, PChar(S), IconNo);
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -