Subversion Repositories colormanager

Rev

Rev 2 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, SysUtils, Classes, Graphics, Controls, Forms, StdCtrls, ExtCtrls,
  7.   Buttons, Spin, math, ComCtrls, Messages, Menus, Registry, IniFiles,
  8.   ShellApi, Dialogs;
  9.  
  10. // Graphutils
  11. // ColorRGBToHLS
  12.  
  13. type
  14.   TLanguageEntry = record
  15.     name: string;
  16.     text: string;
  17.   end;
  18.  
  19.   TMainForm = class(TForm)
  20.     ColorPanel: TPanel;
  21.     KomplementaerColor: TPanel;
  22.     PickTimer: TTimer;
  23.     PopupMenu: TPopupMenu;
  24.     mGetColor: TMenuItem;
  25.     mPutColor: TMenuItem;
  26.     mAktuell: TMenuItem;
  27.     mKomplementaer: TMenuItem;
  28.     mMixColor: TMenuItem;
  29.     mUmkehren: TMenuItem;
  30.     mAktuell2: TMenuItem;
  31.     mKomplementaer2: TMenuItem;
  32.     WebSafe1: TPanel;
  33.     WebSafe2: TPanel;
  34.     CurrentLbl: TLabel;
  35.     mWebsafe: TMenuItem;
  36.     mWebsafeInv: TMenuItem;
  37.     Panel1: TPanel;
  38.     RGBBox: TGroupBox;
  39.     RLbl: TLabel;
  40.     GLbl: TLabel;
  41.     BLbl: TLabel;
  42.     RDecLbl: TLabel;
  43.     GDecLbl: TLabel;
  44.     BDecLbl: TLabel;
  45.     RHexLbl: TLabel;
  46.     GHexLbl: TLabel;
  47.     BHexLbl: TLabel;
  48.     BDecC: TUpDown;
  49.     GDecC: TUpDown;
  50.     RDecC: TUpDown;
  51.     RHexC: TUpDown;
  52.     GHexC: TUpDown;
  53.     BHexC: TUpDown;
  54.     RDec: TEdit;
  55.     RHex: TEdit;
  56.     GDec: TEdit;
  57.     GHex: TEdit;
  58.     BDec: TEdit;
  59.     BHex: TEdit;
  60.     R: TTrackBar;
  61.     G: TTrackBar;
  62.     B: TTrackBar;
  63.     HSVBox: TGroupBox;
  64.     HLbl: TLabel;
  65.     SLbl: TLabel;
  66.     VLbl: TLabel;
  67.     HDecLbl: TLabel;
  68.     SDecLbl: TLabel;
  69.     VDecLbl: TLabel;
  70.     HHexLbl: TLabel;
  71.     SHexLbl: TLabel;
  72.     VHexLbl: TLabel;
  73.     HDec: TEdit;
  74.     HDecC: TUpDown;
  75.     SDec: TEdit;
  76.     SDecC: TUpDown;
  77.     VDec: TEdit;
  78.     VDecC: TUpDown;
  79.     H: TTrackBar;
  80.     S: TTrackBar;
  81.     V: TTrackBar;
  82.     HHex: TEdit;
  83.     HHexC: TUpDown;
  84.     SHex: TEdit;
  85.     SHexC: TUpDown;
  86.     VHex: TEdit;
  87.     VHexC: TUpDown;
  88.     ColorcodeBox: TGroupBox;
  89.     HTMLLbl: TLabel;
  90.     DelphiLbl: TLabel;
  91.     VisualCLbl: TLabel;
  92.     VisualBasicLbl: TLabel;
  93.     JavaLbl: TLabel;
  94.     PhotoshopLbl: TLabel;
  95.     LongLbl: TLabel;
  96.     HTML: TEdit;
  97.     Delphi: TEdit;
  98.     VisualC: TEdit;
  99.     VisualBasic: TEdit;
  100.     Java: TEdit;
  101.     Photoshop: TEdit;
  102.     Long: TEdit;
  103.     Panel2: TPanel;
  104.     ColorMixerBox: TGroupBox;
  105.     Color1Per: TLabel;
  106.     Color2Per: TLabel;
  107.     Color2: TPanel;
  108.     Color1: TPanel;
  109.     MixedColor: TPanel;
  110.     Color1Edt: TEdit;
  111.     Color1Upd: TUpDown;
  112.     Color2Edt: TEdit;
  113.     Color2Upd: TUpDown;
  114.     ColorBox: TGroupBox;
  115.     DelphiBoxLbl: TLabel;
  116.     DelphiBox: TColorListBox;
  117.     Panel3: TPanel;
  118.     ColorPicker: TGroupBox;
  119.     AverageLbl: TLabel;
  120.     PickBtn: TButton;
  121.     EqualLbl: TLabel;
  122.     GreyscaleBtn: TPanel;
  123.     InvertBtn: TPanel;
  124.     RandomBtn: TPanel;
  125.     WebsafeLbl: TLabel;
  126.     WebSafeBtn: TPanel;
  127.     PanelR: TPanel;
  128.     RedBox: TPaintBox;
  129.     PanelG: TPanel;
  130.     GreenBox: TPaintBox;
  131.     PanelB: TPanel;
  132.     BlueBox: TPaintBox;
  133.     PanelH: TPanel;
  134.     HueBox: TPaintBox;
  135.     PanelS: TPanel;
  136.     SatBox: TPaintBox;
  137.     PanelV: TPanel;
  138.     ValBox: TPaintBox;
  139.     HGra: TEdit;
  140.     HGraC: TUpDown;
  141.     HGraLbl: TLabel;
  142.     WebcolorBox: TListBox;
  143.     WebcolorLbl: TLabel;
  144.     PalLbl: TLabel;
  145.     WinColorDialog: TColorDialog;
  146.     DelphiZutreffend: TListBox;
  147.     DelphiZutreffendLbl: TLabel;
  148.     FavoPnl: TPanel;
  149.     favo14: TPanel;
  150.     favo13: TPanel;
  151.     favo12: TPanel;
  152.     favo11: TPanel;
  153.     favo10: TPanel;
  154.     favo9: TPanel;
  155.     favo8: TPanel;
  156.     favo7: TPanel;
  157.     favo6: TPanel;
  158.     favo5: TPanel;
  159.     favo4: TPanel;
  160.     favo3: TPanel;
  161.     favo2: TPanel;
  162.     favo1: TPanel;
  163.     FavoritenLbl: TLabel;
  164.     BasicPanel: TPanel;
  165.     QBLbl: TLabel;
  166.     cpa1: TPanel;
  167.     cpa16: TPanel;
  168.     cpa15: TPanel;
  169.     cpa14: TPanel;
  170.     cpa13: TPanel;
  171.     cpa12: TPanel;
  172.     cpa11: TPanel;
  173.     cpa10: TPanel;
  174.     cpa9: TPanel;
  175.     cpa8: TPanel;
  176.     cpa7: TPanel;
  177.     cpa6: TPanel;
  178.     cpa5: TPanel;
  179.     cpa4: TPanel;
  180.     cpa3: TPanel;
  181.     cpa2: TPanel;
  182.     PalPanel: TPanel;
  183.     WinPanel: TPanel;
  184.     WindowsLbl: TLabel;
  185.     WinDialog: TLabel;
  186.     cpb48: TPanel;
  187.     cpb47: TPanel;
  188.     cpb46: TPanel;
  189.     cpb45: TPanel;
  190.     cpb44: TPanel;
  191.     cpb43: TPanel;
  192.     cpb42: TPanel;
  193.     cpb41: TPanel;
  194.     cpb40: TPanel;
  195.     cpb39: TPanel;
  196.     cpb38: TPanel;
  197.     cpb37: TPanel;
  198.     cpb36: TPanel;
  199.     cpb35: TPanel;
  200.     cpb34: TPanel;
  201.     cpb33: TPanel;
  202.     cpb32: TPanel;
  203.     cpb31: TPanel;
  204.     cpb24: TPanel;
  205.     cpb23: TPanel;
  206.     cpb30: TPanel;
  207.     cpb22: TPanel;
  208.     cpb29: TPanel;
  209.     cpb21: TPanel;
  210.     cpb28: TPanel;
  211.     cpb20: TPanel;
  212.     cpb27: TPanel;
  213.     cpb19: TPanel;
  214.     cpb25: TPanel;
  215.     cpb26: TPanel;
  216.     cpb18: TPanel;
  217.     cpb17: TPanel;
  218.     cpb16: TPanel;
  219.     cpb15: TPanel;
  220.     cpb14: TPanel;
  221.     cpb13: TPanel;
  222.     cpb12: TPanel;
  223.     cpb11: TPanel;
  224.     cpb10: TPanel;
  225.     cpb9: TPanel;
  226.     cpb8: TPanel;
  227.     cpb7: TPanel;
  228.     cpb6: TPanel;
  229.     cpb5: TPanel;
  230.     cpb4: TPanel;
  231.     cpb3: TPanel;
  232.     cpb2: TPanel;
  233.     cpb1: TPanel;
  234.     JskPanel: TPanel;
  235.     PaintshopProLbl: TLabel;
  236.     cpc47: TPanel;
  237.     cpc46: TPanel;
  238.     cpc45: TPanel;
  239.     cpc44: TPanel;
  240.     cpc43: TPanel;
  241.     cpc42: TPanel;
  242.     cpc39: TPanel;
  243.     cpc38: TPanel;
  244.     cpc37: TPanel;
  245.     cpc36: TPanel;
  246.     cpc35: TPanel;
  247.     cpc34: TPanel;
  248.     cpc31: TPanel;
  249.     cpc30: TPanel;
  250.     cpc29: TPanel;
  251.     cpc28: TPanel;
  252.     cpc27: TPanel;
  253.     cpc26: TPanel;
  254.     cpc23: TPanel;
  255.     cpc22: TPanel;
  256.     cpc21: TPanel;
  257.     cpc20: TPanel;
  258.     cpc19: TPanel;
  259.     cpc18: TPanel;
  260.     cpc40: TPanel;
  261.     cpc32: TPanel;
  262.     cpc24: TPanel;
  263.     cpc16: TPanel;
  264.     cpc15: TPanel;
  265.     cpc14: TPanel;
  266.     cpc13: TPanel;
  267.     cpc12: TPanel;
  268.     cpc11: TPanel;
  269.     cpc10: TPanel;
  270.     cpc7: TPanel;
  271.     cpc6: TPanel;
  272.     cpc5: TPanel;
  273.     cpc4: TPanel;
  274.     cpc3: TPanel;
  275.     cpc2: TPanel;
  276.     cpc8: TPanel;
  277.     cpc48: TPanel;
  278.     cpc41: TPanel;
  279.     cpc33: TPanel;
  280.     cpc25: TPanel;
  281.     cpc17: TPanel;
  282.     cpc9: TPanel;
  283.     cpc1: TPanel;
  284.     favo15: TPanel;
  285.     favo16: TPanel;
  286.     Pal: TListBox;
  287.     WebZutreffendLbl: TLabel;
  288.     WebZutreffend: TListBox;
  289.     Panel4: TPanel;
  290.     Info1: TLabel;
  291.     Info2: TLabel;
  292.     Info4: TLabel;
  293.     Info6: TLabel;
  294.     Info7: TLabel;
  295.     Info8: TLabel;
  296.     Info9: TLabel;
  297.     Info12: TLabel;
  298.     Info5: TLabel;
  299.     Info14: TLabel;
  300.     Info15: TLabel;
  301.     Info13: TLabel;
  302.     ColorTmr: TTimer;
  303.     Info3: TLabel;
  304.     AverageMidLbl: TLabel;
  305.     MagPnl: TPanel;
  306.     MagBox: TPaintBox;
  307.     favo17: TPanel;
  308.     favo18: TPanel;
  309.     favo19: TPanel;
  310.     favo20: TPanel;
  311.     CoordsLbl: TLabel;
  312.     CoordsLbl2: TLabel;
  313.     SPro: TEdit;
  314.     SProLbl: TLabel;
  315.     VProLbl: TLabel;
  316.     VPro: TEdit;
  317.     SProC: TUpDown;
  318.     VProC: TUpDown;
  319.     BPro: TEdit;
  320.     GPro: TEdit;
  321.     RPro: TEdit;
  322.     RProC: TUpDown;
  323.     GProC: TUpDown;
  324.     BProC: TUpDown;
  325.     RProLbl: TLabel;
  326.     GProLbl: TLabel;
  327.     BProLbl: TLabel;
  328.     PageControl1: TPageControl;
  329.     TabSheet1: TTabSheet;
  330.     TabSheet2: TTabSheet;
  331.     TabSheet3: TTabSheet;
  332.     TabSheet4: TTabSheet;
  333.     AverageX: TSpinEdit;
  334.     AverageY: TSpinEdit;
  335.     procedure ColorClick(Sender: TObject; Button: TMouseButton;
  336.       Shift: TShiftState; X, Y: Integer);
  337.     procedure SaveEditChange(Sender: TObject);
  338.     procedure ColorTmrTimer(Sender: TObject);
  339.     procedure LinkClick(Sender: TObject);
  340.     procedure WebZutreffendClick(Sender: TObject);
  341.     procedure DelphiZutreffendClick(Sender: TObject);
  342.     procedure WebcolorBoxClick(Sender: TObject);
  343.     procedure WinDialogClick(Sender: TObject);
  344.     procedure PalClick(Sender: TObject);
  345.     procedure OutboxPaint(Sender: TObject);
  346.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  347.     procedure WebsafeLblClick(Sender: TObject);
  348.     procedure InvertBtnClick(Sender: TObject);
  349.     procedure TakeClick(Sender: TObject);
  350.     procedure DelphiBoxClick(Sender: TObject);
  351.     procedure DefColorClick(Sender: TObject);
  352.     procedure GreyscaleBtnClick(Sender: TObject);
  353.     procedure Menu2Click(Sender: TObject);
  354.     procedure MenuClick(Sender: TObject);
  355.     procedure RandomBtnClick(Sender: TObject);
  356.     procedure PickTimerTimer(Sender: TObject);
  357.     procedure PickBtnClick(Sender: TObject);
  358.     procedure FormCreate(Sender: TObject);
  359.     procedure EditKeyPress(Sender: TObject; var Key: Char);
  360.     procedure UpDownClick(Sender: TObject; Button: TUDBtnType);
  361.     procedure Change(Sender: TObject);
  362.     procedure AverageXYChange(Sender: TObject);
  363.   private
  364.     LangArray: Array of TLanguageEntry;
  365.     function GetLangEntry(name: string): string;
  366.   public
  367.     SampleMethod, NewMethod: byte;
  368.     MemPix: TBitmap;
  369.     BoxBuf, Box2Buf: TBitmap;
  370.     ScreenDC: HDC;
  371.     PopupmenuSender: tobject;
  372.     procedure WMLButtonDown(var Msg: TMessage); message WM_LBUTTONDOWN;
  373.     procedure WMRButtonDown(var Msg: TMessage); message WM_RBUTTONDOWN;
  374.     procedure AppDeactivate(Sender: TObject);
  375.     procedure DrawGrad(BoxNum: integer);
  376.     procedure AktualisiereFarben(RGBAlsQuelle: boolean; ignore: integer = 0);
  377.     procedure AktualisiereWert(Sender: TObject);
  378.     procedure Ladefarbe(col: tcolor);
  379.     procedure BerechneMixColor;
  380.     procedure CheckWebfarben;
  381.     procedure CheckDelphiFarben;
  382.     procedure ZeigeRichtigePalette;
  383.     procedure WriteIntSetting(name: string; wert: integer);
  384.     function ReadIntSetting(name: string): integer;
  385. end;
  386.  
  387. var
  388.   MainForm: TMainForm;
  389.  
  390. implementation
  391.  
  392. {$R *.DFM}
  393.  
  394. {$R WindowsXP.res}
  395.  
  396. const
  397.   // Source: https://developer.mozilla.org/en-US/docs/Web/CSS/named-color
  398.   webfarben: array[0..149] of string = (
  399.     '#f0f8ff', // aliceblue
  400.     '#faebd7', // antiquewhite
  401.     '#00ffff', // aqua
  402.     '#7fffd4', // aquamarine
  403.     '#f0ffff', // azure
  404.     '#f5f5dc', // beige
  405.     '#ffe4c4', // bisque
  406.     '#000000', // black
  407.     '#ffebcd', // blanchedalmond
  408.     '#0000ff', // blue
  409.     '#8a2be2', // blueviolet
  410.     '#a52a2a', // brown
  411.     '#deb887', // burlywood
  412.     '#5f9ea0', // cadetblue
  413.     '#7fff00', // chartreuse
  414.     '#d2691e', // chocolate
  415.     '#ff7f50', // coral
  416.     '#6495ed', // cornflowerblue
  417.     '#fff8dc', // cornsilk
  418.     '#dc143c', // crimson
  419.     '#00ffff', // cyan (synonym of aqua)
  420.     '#00008b', // darkblue
  421.     '#008b8b', // darkcyan
  422.     '#b8860b', // darkgoldenrod
  423.     '#a9a9a9', // darkgray
  424.     '#006400', // darkgreen
  425.     '#a9a9a9', // darkgrey
  426.     '#bdb76b', // darkkhaki
  427.     '#8b008b', // darkmagenta
  428.     '#556b2f', // darkolivegreen
  429.     '#ff8c00', // darkorange
  430.     '#9932cc', // darkorchid
  431.     '#8b0000', // darkred
  432.     '#e9967a', // darksalmon
  433.     '#8fbc8f', // darkseagreen
  434.     '#483d8b', // darkslateblue
  435.     '#2f4f4f', // darkslategray
  436.     '#2f4f4f', // darkslategrey
  437.     '#00ced1', // darkturquoise
  438.     '#9400d3', // darkviolet
  439.     '#ff1493', // deeppink
  440.     '#00bfff', // deepskyblue
  441.     '#696969', // dimgray
  442.     '#696969', // dimgrey
  443.     '#1e90ff', // dodgerblue
  444.     '#b22222', // firebrick
  445.     '#fffaf0', // floralwhite
  446.     '#228b22', // forestgreen
  447.     '#ff00ff', // fuchsia
  448.     '#dcdcdc', // gainsboro
  449.     '#f8f8ff', // ghostwhite
  450.     '#ffd700', // gold
  451.     '#daa520', // goldenrod
  452.     '#808080', // gray
  453.     '#008000', // green
  454.     '#adff2f', // greenyellow
  455.     '#808080', // grey (synonym of gray)
  456.     '#f0fff0', // honeydew
  457.     '#ff69b4', // hotpink
  458.     '#cd5c5c', // indianred
  459.     '#4b0082', // indigo
  460.     '#fffff0', // ivory
  461.     '#f0e68c', // khaki
  462.     '#e6e6fa', // lavender
  463.     '#fff0f5', // lavenderblush
  464.     '#7cfc00', // lawngreen
  465.     '#fffacd', // lemonchiffon
  466.     '#add8e6', // lightblue
  467.     '#f08080', // lightcoral
  468.     '#e0ffff', // lightcyan
  469.     '#fafad2', // lightgoldenrodyellow
  470.     '#d3d3d3', // lightgray
  471.     '#90ee90', // lightgreen
  472.     '#d3d3d3', // lightgrey
  473.     '#ffb6c1', // lightpink
  474.     '#ffa07a', // lightsalmon
  475.     '#20b2aa', // lightseagreen
  476.     '#87cefa', // lightskyblue
  477.     '#778899', // lightslategray
  478.     '#778899', // lightslategrey
  479.     '#b0c4de', // lightsteelblue
  480.     '#ffffe0', // lightyellow
  481.     '#00ff00', // lime
  482.     '#00ff00', // lime
  483.     '#32cd32', // limegreen
  484.     '#faf0e6', // linen
  485.     '#ff00ff', // magenta (synonym of fuchsia)
  486.     '#800000', // maroon
  487.     '#800000', // maroon
  488.     '#66cdaa', // mediumaquamarine
  489.     '#0000cd', // mediumblue
  490.     '#ba55d3', // mediumorchid
  491.     '#9370db', // mediumpurple
  492.     '#3cb371', // mediumseagreen
  493.     '#7b68ee', // mediumslateblue
  494.     '#00fa9a', // mediumspringgreen
  495.     '#48d1cc', // mediumturquoise
  496.     '#c71585', // mediumvioletred
  497.     '#191970', // midnightblue
  498.     '#f5fffa', // mintcream
  499.     '#ffe4e1', // mistyrose
  500.     '#ffe4b5', // moccasin
  501.     '#ffdead', // navajowhite
  502.     '#000080', // navy
  503.     '#fdf5e6', // oldlace
  504.     '#808000', // olive
  505.     '#6b8e23', // olivedrab
  506.     '#ffa500', // orange
  507.     '#ff4500', // orangered
  508.     '#da70d6', // orchid
  509.     '#eee8aa', // palegoldenrod
  510.     '#98fb98', // palegreen
  511.     '#afeeee', // paleturquoise
  512.     '#db7093', // palevioletred
  513.     '#ffefd5', // papayawhip
  514.     '#ffdab9', // peachpuff
  515.     '#cd853f', // peru
  516.     '#ffc0cb', // pink
  517.     '#dda0dd', // plum
  518.     '#b0e0e6', // powderblue
  519.     '#800080', // purple
  520.     '#663399', // rebeccapurple
  521.     '#ff0000', // red
  522.     '#bc8f8f', // rosybrown
  523.     '#4169e1', // royalblue
  524.     '#8b4513', // saddlebrown
  525.     '#fa8072', // salmon
  526.     '#f4a460', // sandybrown
  527.     '#2e8b57', // seagreen
  528.     '#fff5ee', // seashell
  529.     '#a0522d', // sienna
  530.     '#c0c0c0', // silver
  531.     '#87ceeb', // skyblue
  532.     '#6a5acd', // slateblue
  533.     '#708090', // slategray
  534.     '#708090', // slategrey
  535.     '#fffafa', // snow
  536.     '#00ff7f', // springgreen
  537.     '#4682b4', // steelblue
  538.     '#d2b48c', // tan
  539.     '#008080', // teal
  540.     '#d8bfd8', // thistle
  541.     '#ff6347', // tomato
  542.     '#40e0d0', // turquoise
  543.     '#ee82ee', // violet
  544.     '#f5deb3', // wheat
  545.     '#ffffff', // white
  546.     '#f5f5f5', // whitesmoke
  547.     '#ffff00', // yellow
  548.     '#9acd32'  // yellowgreen
  549.   );
  550.  
  551. function TMainForm.GetLangEntry(name: string): string;
  552. var
  553.   i: integer;
  554. begin
  555.   for i := 0 to high(LangArray) do
  556.   begin
  557.     if LangArray[i].name = name then
  558.     begin
  559.       result := LangArray[i].text;
  560.       break;
  561.     end;
  562.   end;
  563. end;
  564.  
  565. // http://www.delphipraxis.net/topic49179_rgb+hsv+und+hsv+rgb.html
  566. // mit 360°
  567. function HSVtoRGB(H:Integer; S, V: Byte): TColor;
  568. var
  569.   ht, d, t1, t2, t3:Integer;
  570.   R,G,B:Word;
  571. begin
  572.   if S = 0 then
  573.    begin
  574.     R := V;  G := V;  B := V;
  575.    end
  576.   else
  577.    begin
  578.     ht := H * 6;
  579.     d := ht mod 360;
  580.  
  581.     t1 := round(V * (255 - S) / 255);
  582.     t2 := round(V * (255 - S * d / 360) / 255);
  583.     t3 := round(V * (255 - S * (360 - d) / 360) / 255);
  584.  
  585.     case ht div 360 of
  586.     0:
  587.       begin
  588.         R := V;  G := t3; B := t1;
  589.       end;
  590.     1:
  591.       begin
  592.         R := t2; G := V;  B := t1;
  593.       end;
  594.     2:
  595.       begin
  596.         R := t1; G := V;  B := t3;
  597.       end;
  598.     3:
  599.       begin
  600.         R := t1; G := t2; B := V;
  601.       end;
  602.     4:
  603.       begin
  604.         R := t3; G := t1; B := V;
  605.       end;
  606.     else
  607.       begin
  608.         R := V;  G := t1; B := t2;
  609.       end;
  610.     end;
  611.    end;
  612.   Result:=RGB(R,G,B);
  613. end;
  614.  
  615. // http://www.delphipraxis.net/topic49179_rgb+hsv+und+hsv+rgb.html
  616. // mit 360°
  617. procedure RGBtoHSV(Red, Green, Blue: Byte; var Hue: Integer; var Saturation, Value: Byte);
  618. var
  619.   Maximum, Minimum: Byte;
  620.   Rc, Gc, Bc: Single;
  621.   H: Single;
  622. begin
  623.   Maximum := Max(Red, Max(Green, Blue));
  624.   Minimum := Min(Red, Min(Green, Blue));
  625.   Value := Maximum;
  626.   if Maximum <> 0 then
  627.     Saturation := MulDiv(Maximum - Minimum, 255, Maximum)
  628.   else
  629.     Saturation := 0;
  630.   if Saturation = 0 then
  631.     Hue := 0 // arbitrary value
  632.   else
  633.   begin
  634.     Assert(Maximum <> Minimum);
  635.     Rc := (Maximum - Red) / (Maximum - Minimum);
  636.     Gc := (Maximum - Green) / (Maximum - Minimum);
  637.     Bc := (Maximum - Blue) / (Maximum - Minimum);
  638.     if Red = Maximum then
  639.       H := Bc - Gc
  640.     else if Green = Maximum then
  641.       H := 2 + Rc - Bc
  642.     else
  643.     begin
  644.       Assert(Blue = Maximum);
  645.       H := 4 + Gc - Rc;
  646.     end;
  647.     H := H * 60;
  648.     if H < 0 then
  649.       H := H + 360;
  650.     Hue := Round(H);
  651.   end;
  652. end;
  653.  
  654. // http://www.delphipraxis.net/topic35695_kontrastfarbe+ermitteln.html
  655. function BlackWhiteContrastColor(value: TColor): TColor;
  656. var
  657.   intensity : Integer;
  658. begin
  659.   value := ColorToRGB(value);
  660.  
  661.   intensity := GetBValue(value) * 21  // Blue
  662.     + GetGValue(value) * 174   // Green
  663.     + GetRValue(value) * 61;   // Red
  664.  
  665.    // intensity = 0        -> dark
  666.    // intensity = 255*256  -> bright
  667.  
  668.   if intensity >= (128*256) then
  669.     Result := clBlack
  670.   else
  671.     Result := clWhite;
  672. end;
  673.  
  674. procedure TMainForm.WMLButtonDown(var Msg: TMessage);
  675. begin
  676.   inherited;
  677.   if not PickBtn.Enabled then begin
  678.     ReleaseCapture;
  679.     PickBtn.Enabled := true;
  680.     Caption := Application.Title;
  681.     PostMessage(MainForm.Handle, WM_ACTIVATE, word(true), 0);
  682.   end;
  683. end;
  684.  
  685. procedure TMainForm.WMRButtonDown(var Msg: TMessage);
  686. begin
  687.   inherited;
  688.   WMLButtonDown(Msg);
  689. end;
  690.  
  691. procedure TMainForm.AppDeactivate(Sender: TObject);
  692. begin
  693.   if not PickBtn.Enabled then
  694.     SetCapture(MainForm.Handle);
  695. end;
  696.  
  697. procedure TMainForm.AverageXYChange(Sender: TObject);
  698. begin
  699.   WriteIntSetting(TSpinEdit(sender).GetNamePath, TSpinEdit(sender).Value);
  700. end;
  701.  
  702. procedure TMainForm.DrawGrad(BoxNum: integer);
  703.  var
  704.   R, G, B, S, V: byte;
  705.   H: integer;
  706. begin
  707.   case BoxNum of
  708.     1:
  709.       begin
  710.         G := Mainform.G.Position;
  711.         B := Mainform.B.Position;
  712.  
  713.         with BoxBuf.Canvas do
  714.         begin
  715.           for R := 0 to 255 do
  716.             Pixels[R, 0] := rgb(R, G, B);
  717.           StretchBlt(RedBox.Canvas.Handle,
  718.             0, 0, RedBox.Width, RedBox.Height,
  719.             Handle,
  720.             0, 0,
  721.             256, 1,
  722.             SRCCOPY);
  723.         end;
  724.       end;
  725.  
  726.     2:
  727.       begin
  728.         R := Mainform.R.Position;
  729.         B := Mainform.B.Position;
  730.  
  731.         with BoxBuf.Canvas do
  732.         begin
  733.           for G := 0 to 255 do
  734.             Pixels[G, 0] := rgb(R, G, B);
  735.           StretchBlt(GreenBox.Canvas.Handle,
  736.             0, 0, GreenBox.Width, GreenBox.Height,
  737.             Handle,
  738.             0, 0,
  739.             256, 1,
  740.             SRCCOPY);
  741.         end;
  742.       end;
  743.  
  744.     3:
  745.       begin
  746.         R := Mainform.R.Position;
  747.         G := Mainform.G.Position;
  748.  
  749.         with BoxBuf.Canvas do
  750.         begin
  751.           for B := 0 to 255 do
  752.             Pixels[B, 0] := rgb(R, G, B);
  753.           StretchBlt(BlueBox.Canvas.Handle,
  754.             0, 0, BlueBox.Width, BlueBox.Height,
  755.             Handle,
  756.             0, 0,
  757.             256, 1,
  758.             SRCCOPY);
  759.         end;
  760.       end;
  761.  
  762.     4:
  763.       begin
  764.         S := Mainform.S.Position;
  765.         V := MainForm.V.Position;
  766.  
  767.         with Box2Buf.Canvas do
  768.         begin
  769.           for H := 0 to 359 do
  770.             Pixels[H, 0] := HSVtoRGB(H, S, V);
  771.           StretchBlt(HueBox.Canvas.Handle,
  772.             0, 0, HueBox.Width, HueBox.Height,
  773.             Handle,
  774.             0, 0,
  775.             360, 1,
  776.             SRCCOPY);
  777.         end;
  778.       end;
  779.  
  780.     5:
  781.       begin
  782.         H := Mainform.H.Position;
  783.         V := MainForm.V.Position;
  784.  
  785.         with BoxBuf.Canvas do
  786.         begin
  787.           for S := 0 to 255 do
  788.             Pixels[S, 0] := HSVtoRGB(H, S, V);
  789.           StretchBlt(SatBox.Canvas.Handle,
  790.             0, 0, SatBox.Width, SatBox.Height,
  791.             Handle,
  792.             0, 0,
  793.             256, 1,
  794.             SRCCOPY);
  795.         end;
  796.       end;
  797.  
  798.     6:
  799.       begin
  800.         H := Mainform.H.Position;
  801.         S := MainForm.S.Position;
  802.  
  803.         with BoxBuf.Canvas do
  804.         begin
  805.           for V := 0 to 255 do
  806.             Pixels[V, 0] := HSVtoRGB(H, S, V);
  807.           StretchBlt(ValBox.Canvas.Handle,
  808.             0, 0, ValBox.Width, ValBox.Height,
  809.             Handle,
  810.             0, 0,
  811.             256, 1,
  812.             SRCCOPY);
  813.         end;
  814.       end;
  815.   end;
  816. end;
  817.  
  818. procedure TMainForm.FormCreate(Sender: TObject);
  819. var
  820.   i: integer;
  821.   ini: tinifile;
  822.   str: TStringList;
  823. begin
  824.   Application.OnDeactivate := AppDeactivate;
  825.   Randomize;
  826.  
  827.   ScreenDC := GetDC(0);
  828.  
  829.   MemPix := TBitmap.Create;
  830.  
  831.   MemPix.Width := MagBox.Width;
  832.   MemPix.Height := MagBox.Height;
  833.   MemPix.Canvas.Pixels[0, 0] := clBlack;
  834.  
  835.   SampleMethod := NewMethod;
  836.  
  837.   BoxBuf := TBitmap.Create;
  838.   BoxBuf.Width := 256;
  839.   BoxBuf.Height := 1;
  840.  
  841.   Box2Buf := TBitmap.Create;
  842.   Box2Buf.Width := 360;
  843.   Box2Buf.Height := 1;
  844.  
  845.   Caption := Application.title;
  846.   Change(r);
  847.   Change(g);
  848.   Change(b);
  849.  
  850.   delphibox.ItemIndex := -1;
  851.   color1upd.position := 50;
  852.   UpDownClick(color1upd, btPrev);
  853.   color1.Color := clBlack;
  854.   PopupmenuSender := color1;
  855.   MenuClick(popupmenu);
  856.   color2.Color := clBlack;
  857.   PopupmenuSender := color2;
  858.   MenuClick(popupmenu);
  859.  
  860.   cpa1.font.color := BlackWhiteContrastColor(cpa1.Color);
  861.   cpa2.font.color := BlackWhiteContrastColor(cpa2.Color);
  862.   cpa3.font.color := BlackWhiteContrastColor(cpa3.Color);
  863.   cpa4.font.color := BlackWhiteContrastColor(cpa4.Color);
  864.   cpa5.font.color := BlackWhiteContrastColor(cpa5.Color);
  865.   cpa6.font.color := BlackWhiteContrastColor(cpa6.Color);
  866.   cpa7.font.color := BlackWhiteContrastColor(cpa7.Color);
  867.   cpa8.font.color := BlackWhiteContrastColor(cpa8.Color);
  868.   cpa9.font.color := BlackWhiteContrastColor(cpa9.Color);
  869.   cpa10.font.color := BlackWhiteContrastColor(cpa10.Color);
  870.   cpa11.font.color := BlackWhiteContrastColor(cpa11.Color);
  871.   cpa12.font.color := BlackWhiteContrastColor(cpa12.Color);
  872.   cpa13.font.color := BlackWhiteContrastColor(cpa13.Color);
  873.   cpa14.font.color := BlackWhiteContrastColor(cpa14.Color);
  874.   cpa15.font.color := BlackWhiteContrastColor(cpa15.Color);
  875.   cpa16.font.color := BlackWhiteContrastColor(cpa16.Color);
  876.  
  877.   // Sprachdatei auslesen
  878.   if fileexists(ExtractFilePath(Application.ExeName)+'Language.ini') then
  879.   begin
  880.     ini := TIniFile.Create(ExtractFilePath(Application.ExeName)+'Language.ini');
  881.     str := TStringList.Create();
  882.     try
  883.       ini.ReadSection(Name, str);
  884.       for i := 0 to str.count-1 do
  885.       begin
  886.         setlength(LangArray, length(LangArray)+1);
  887.         LangArray[length(LangArray)-1].name := str.strings[i];
  888.         LangArray[length(LangArray)-1].text := ini.ReadString(name, str.strings[i], '');
  889.         LangArray[length(LangArray)-1].text := StringReplace(LangArray[length(LangArray)-1].text, '###', #13#10, [rfReplaceAll]);
  890.       end;
  891.     finally
  892.       ini.free;
  893.       str.Free;
  894.     end;
  895.   end;
  896.  
  897.   PageControl1.ActivePageIndex := 0;
  898.  
  899.   // Elemente mit Sprache versehen
  900.   rgbbox.Caption := GetLangEntry('rgb');
  901.   hsvbox.Caption := GetLangEntry('hsv');
  902.   rdeclbl.Caption := GetLangEntry('dec');
  903.   gdeclbl.Caption := GetLangEntry('dec');
  904.   bdeclbl.Caption := GetLangEntry('dec');
  905.   hdeclbl.Caption := GetLangEntry('dec');
  906.   sdeclbl.Caption := GetLangEntry('dec');
  907.   vdeclbl.Caption := GetLangEntry('dec');
  908.   rhexlbl.Caption := GetLangEntry('hex');
  909.   ghexlbl.Caption := GetLangEntry('hex');
  910.   bhexlbl.Caption := GetLangEntry('hex');
  911.   hhexlbl.Caption := GetLangEntry('hex');
  912.   shexlbl.Caption := GetLangEntry('hex');
  913.   vhexlbl.Caption := GetLangEntry('hex');
  914.   hgralbl.Caption := GetLangEntry('gra');
  915.   rlbl.Caption := GetLangEntry('red');
  916.   glbl.Caption := GetLangEntry('green');
  917.   blbl.Caption := GetLangEntry('blue');
  918.   GreyscaleBtn.caption := GetLangEntry('greyscale');
  919.   InvertBtn.caption := GetLangEntry('invert');
  920.   WebSafeBtn.caption := GetLangEntry('websafe');
  921.   RandomBtn.caption := GetLangEntry('random');
  922.   HLbl.caption := GetLangEntry('hue');
  923.   SLbl.caption := GetLangEntry('sat');
  924.   VLbl.caption := GetLangEntry('val');
  925.   ColorcodeBox.caption := GetLangEntry('codes');
  926.   htmllbl.caption := GetLangEntry('html');
  927.   delphilbl.caption := GetLangEntry('delphi');
  928.   VisualClbl.caption := GetLangEntry('cpp');
  929.   visualbasiclbl.caption := GetLangEntry('visualbasic');
  930.   javalbl.caption := GetLangEntry('java');
  931.   photoshoplbl.caption := GetLangEntry('photoshop');
  932.   longlbl.caption := GetLangEntry('long');
  933.   currentlbl.caption := GetLangEntry('current');
  934.   websafelbl.caption := GetLangEntry('websafelbl');
  935.   komplementaercolor.Caption := GetLangEntry('invcolor');
  936.   websafe2.Caption := GetLangEntry('invwebsafe');
  937.   PageControl1.Pages[0].Caption := GetLangEntry('tab1');
  938.   PageControl1.Pages[1].Caption := GetLangEntry('tab2');
  939.   PageControl1.Pages[2].Caption := GetLangEntry('tab3');
  940.   PageControl1.Pages[3].Caption := GetLangEntry('tab4');
  941.   colormixerbox.Caption := getlangentry('colormixer');
  942.   color1.Caption := getlangentry('color') + ' 1';
  943.   color2.Caption := getlangentry('color') + ' 2';
  944.   mixedcolor.caption := getlangentry('mixedcolor');
  945.   colorbox.caption := getlangentry('colors');
  946.   pallbl.Caption := getlangentry('availablepals');
  947.   delphiboxlbl.Caption := getlangentry('delphipal');
  948.   webcolorlbl.Caption := getlangentry('css');
  949.   delphizutreffendlbl.Caption := getlangentry('zutr');
  950.   webzutreffendlbl.Caption := getlangentry('zutr');
  951.   qblbl.Caption := getlangentry('vgapal');
  952.   windialog.Caption := getlangentry('windialog');
  953.   favoritenlbl.Caption := getlangentry('favorites');
  954.   pal.Items.add(getlangentry('windows'));
  955.   pal.Items.add(getlangentry('jasc'));
  956.   windowslbl.Caption := getlangentry('windows');
  957.   PaintshopProlbl.Caption := getlangentry('jasc');
  958.   colorpicker.Caption := getlangentry('colorpicker');
  959.   averagelbl.Caption := getlangentry('averagepix');
  960.   CoordsLbl2.Caption := getlangentry('coords');
  961.   pickbtn.Caption := getlangentry('capture');
  962.   info3.Caption := getlangentry('createdwith');
  963.   info4.Caption := getlangentry('leader');
  964.   info6.Caption := getlangentry('email');
  965.   info8.Caption := getlangentry('website');
  966.   info13.Caption := getlangentry('webportal');
  967.   info14.Caption := getlangentry('viathinksoft');
  968.   info15.Caption := getlangentry('projektseite');
  969.   info5.Caption := getlangentry('contact');
  970.   info12.Caption := getlangentry('links');
  971.   komplementaercolor.Hint := getlangentry('thiscolor');
  972.   websafe2.Hint := getlangentry('thiscolor');
  973.   websafe1.Hint := getlangentry('thiscolor');
  974.   websafelbl.Hint := getlangentry('thiscolor');
  975.   sprolbl.Caption := getlangentry('per');
  976.   vprolbl.Caption := getlangentry('per');
  977.   rprolbl.Caption := getlangentry('per');
  978.   gprolbl.Caption := getlangentry('per');
  979.   bprolbl.Caption := getlangentry('per');
  980.   popupmenu.Items.Items[0].Caption := getlangentry('PopupA');
  981.   popupmenu.Items.Items[0].Items[0].Caption := getlangentry('PopupA1');
  982.   popupmenu.Items.Items[0].Items[1].Caption := getlangentry('PopupA2');
  983.   popupmenu.Items.Items[0].Items[2].Caption := getlangentry('PopupA3');
  984.   popupmenu.Items.Items[0].Items[3].Caption := getlangentry('PopupA4');
  985.   popupmenu.Items.Items[0].Items[4].Caption := getlangentry('PopupA5');
  986.   popupmenu.Items.Items[1].Caption := getlangentry('PopupB');
  987.   popupmenu.Items.Items[1].Items[0].Caption := getlangentry('PopupB1');
  988.   popupmenu.Items.Items[1].Items[1].Caption := getlangentry('PopupB2');
  989.   popupmenu.Items.Items[2].Caption := getlangentry('PopupC');
  990.  
  991.   // Favoriten-Farben und Einstellungen aus Registry holen
  992.   pal.ItemIndex := 0;
  993.   for i := 1 to 20 do
  994.     tpanel(mainform.FindComponent('favo'+inttostr(i))).Color := ReadIntSetting('favo'+inttostr(i));
  995.   pal.ItemIndex := ReadIntSetting('Palette');
  996.   AverageX.Value := ReadIntSetting('AverageX');
  997.   AverageY.Value := ReadIntSetting('AverageY');
  998.  
  999.   ZeigeRichtigePalette;
  1000. end;
  1001.  
  1002. function WebSafeColor(inp: TColor): TColor;
  1003.  
  1004.   function WebSafeVal(int: Byte): Byte;
  1005.   begin
  1006.     case int of
  1007.       0..26: Result := 0;
  1008.       27..76: Result := 51;
  1009.       77..127: Result := 102;
  1010.       128..178: Result := 153;
  1011.       179..229: Result := 209;
  1012.       else Result := 255;
  1013.     end;
  1014.   end;
  1015.  
  1016. begin
  1017.   result := rgb(WebSafeVal(GetRValue(inp)), WebSafeVal(GetGValue(inp)), WebSafeVal(GetBValue(inp)));
  1018. end;
  1019.  
  1020. function InvertString(inp: string): string;
  1021. var
  1022.   i: integer;
  1023. begin
  1024.   result := '';
  1025.   for i := length(inp) downto 1 do
  1026.     result := result + inp[i];
  1027. end;
  1028.  
  1029. procedure TMainForm.AktualisiereFarben(RGBAlsQuelle: boolean; Ignore: integer = 0);
  1030. var
  1031.   hc: integer;
  1032.   sc, lc: byte;
  1033. begin
  1034.   if RGBAlsQuelle then
  1035.   begin
  1036.     RGBtoHSV(R.position, G.position, B.Position, hc, sc, lc);
  1037.     ColorPanel.color := rgb(R.position, G.position, B.Position);
  1038.  
  1039.     h.OnChange := nil;
  1040.     h.position := hc;
  1041.     AktualisiereWert(h);
  1042.     h.OnChange := Change;
  1043.  
  1044.     s.OnChange := nil;
  1045.     s.position := sc;
  1046.     AktualisiereWert(s);
  1047.     s.OnChange := Change;
  1048.  
  1049.     v.OnChange := nil;
  1050.     v.position := lc;
  1051.     AktualisiereWert(v);
  1052.     v.OnChange := Change;
  1053.   end
  1054.   else
  1055.   begin
  1056.     ColorPanel.color := HSVtoRGB(h.Position, s.Position, v.Position);
  1057.  
  1058.     // Die OnChange-Ereignisse werden kurzzeitig entfernt,
  1059.     // um eine unendliche Rückkopplung durch AktualisiereFarben() zu verhindern
  1060.     r.OnChange := nil;
  1061.     g.OnChange := nil;
  1062.     b.OnChange := nil;
  1063.  
  1064.     Ladefarbe(colorpanel.Color);
  1065.  
  1066.     AktualisiereWert(r);
  1067.     AktualisiereWert(g);
  1068.     AktualisiereWert(b);
  1069.  
  1070.     r.OnChange := Change;
  1071.     g.OnChange := Change;
  1072.     b.OnChange := Change;
  1073.   end;
  1074.  
  1075.   VisualC.text := '0x00' + inttohex(GetRValue(ColorPanel.color), 2) + inttohex(GetGValue(ColorPanel.color), 2) +
  1076.     inttohex(GetBValue(ColorPanel.color), 2);
  1077.   HTML.text := '#' + inttohex(GetRValue(ColorPanel.color), 2) + inttohex(GetGValue(ColorPanel.color), 2) +
  1078.     inttohex(GetBValue(ColorPanel.color), 2);
  1079.   Delphi.text := '$00' + inttohex(GetBValue(ColorPanel.color), 2) + inttohex(GetGValue(ColorPanel.color), 2) +
  1080.     inttohex(GetRValue(ColorPanel.color), 2);
  1081.   VisualBasic.text := '&00' + inttohex(GetBValue(ColorPanel.color), 2) + inttohex(GetGValue(ColorPanel.color), 2) +
  1082.     inttohex(GetRValue(ColorPanel.color), 2) + '&';
  1083.   Java.text := '0x' + InvertString(inttohex(GetBValue(ColorPanel.color), 2)) + InvertString(inttohex(GetGValue(ColorPanel.color), 2)) +
  1084.     InvertString(inttohex(GetRValue(ColorPanel.color), 2));
  1085.   Photoshop.text := InvertString(inttohex(GetBValue(ColorPanel.color), 2)) + InvertString(inttohex(GetGValue(ColorPanel.color), 2)) +
  1086.     InvertString(inttohex(GetRValue(ColorPanel.color), 2));
  1087.   Long.Text := inttostr(ColorToRGB(ColorPanel.color));
  1088.  
  1089.   if Ignore <> 1 then
  1090.     CheckDelphiFarben; // Akzeptiert keine Systemfarben: DelphiBox.Selected := ColorPanel.color;
  1091.  
  1092.   if Ignore <> 2 then
  1093.     CheckWebfarben;
  1094.  
  1095.   KomplementaerColor.Color := ColorPanel.Color xor $FFFFFF;
  1096.   KomplementaerColor.Font.Color := BlackWhiteContrastColor(KomplementaerColor.Color);
  1097.  
  1098.   websafe1.Color := WebSafeColor(colorpanel.color);
  1099.   websafe1.Font.Color := BlackWhiteContrastColor(websafe1.Color);
  1100.   websafe2.Color := websafe1.color xor $FFFFFF;
  1101.   websafe2.Font.Color := BlackWhiteContrastColor(websafe2.Color);
  1102.  
  1103.   CurrentLbl.Font.Color := BlackWhiteContrastColor(ColorPanel.Color);
  1104.   WebsafeLbl.Font.Color := BlackWhiteContrastColor(websafe1.Color);
  1105. end;
  1106.  
  1107. function DeleteFirstSeros(str: string): string;
  1108. var
  1109.   ende: boolean;
  1110. begin
  1111.   ende := false;
  1112.   while not ende do
  1113.     if (copy(str, 0, 1) = '0') and (length(str) > 1) then
  1114.       str := copy(str, 2, length(str)-1)
  1115.     else
  1116.       ende := true;
  1117.   result := str;
  1118. end;
  1119.  
  1120. function HexToInt(hex: string; sender: tobject): integer;
  1121. var
  1122.   i: integer;
  1123. begin
  1124.   hex := DeleteFirstSeros(hex);
  1125.   result := -1;
  1126.   for i := $00 to $FF do
  1127.     if uppercase(hex) = inttohex(i, 0) then
  1128.     begin
  1129.       result := i;
  1130.     end;
  1131. end;
  1132.  
  1133. procedure TMainForm.EditKeyPress(Sender: TObject; var Key: Char);
  1134. begin
  1135.   if (sender = HTML) then
  1136.   begin
  1137.     if not (Key in [#13, #08, '0'..'9', '#', 'a'..'f', 'A'..'F']) then Key := #0;
  1138.   end
  1139.   else if (sender = Delphi) then
  1140.   begin
  1141.     if not (Key in [#13, #08, '0'..'9', '$', 'a'..'f', 'A'..'F']) then Key := #0;
  1142.   end
  1143.   else if (sender = VisualC) or (sender = Java) then
  1144.   begin
  1145.     if not (Key in [#13, #08, '0'..'9', 'x', 'a'..'f', 'A'..'F']) then Key := #0;
  1146.   end
  1147.   else if (sender = VisualBasic) then
  1148.   begin
  1149.     if not (Key in [#13, #08, '0'..'9', '&', 'a'..'f', 'A'..'F']) then Key := #0;
  1150.   end
  1151.   else if (sender = Photoshop) then
  1152.   begin
  1153.     if not (Key in [#13, #08, '0'..'9', 'a'..'f', 'A'..'F']) then Key := #0;
  1154.   end
  1155.   else if (sender = Long) or
  1156.     (sender = SPro) or (sender = VPro) or (sender = RPro) or (sender = GPro) or
  1157.     (sender = BPro) then
  1158.   begin
  1159.     if not (Key in [#13, #08, '0'..'9']) then Key := #0;
  1160.   end
  1161.   else if (sender = RHex) or (sender = GHex) or (sender = BHex) or
  1162.           (sender = HHex) or (sender = SHex) or (sender = VHex) then
  1163.   begin
  1164.     if not (Key in [#13, #08, '0'..'9', 'a'..'f', 'A'..'F']) then Key := #0;
  1165.   end
  1166.   else
  1167.   begin
  1168.     if not (Key in [#13, #08, '0'..'9']) then Key := #0;
  1169.   end;
  1170.  
  1171.   if key = #13 then
  1172.   begin
  1173.     Key := #0;
  1174.     if sender = RHex then
  1175.     begin
  1176.       R.Position := hextoint(RHex.text, r);
  1177.       Change(r);
  1178.     end;
  1179.     if sender = RPro then
  1180.     begin
  1181.       if strtoint(tedit(sender).text) > 100 then
  1182.         tedit(sender).Text := inttostr(100);
  1183.       R.Position := round(strtoint(RPro.text) / rproc.max * 255);
  1184.       Change(r);
  1185.     end;
  1186.     if sender = GHex then
  1187.     begin
  1188.       G.Position := hextoint(GHex.text, g);
  1189.       Change(g);
  1190.     end;
  1191.     if sender = GPro then
  1192.     begin
  1193.       if strtoint(tedit(sender).text) > 100 then
  1194.         tedit(sender).Text := inttostr(100);
  1195.       G.Position := round(strtoint(GPro.text) / gproc.max * 255);
  1196.       Change(g);
  1197.     end;
  1198.     if sender = BHex then
  1199.     begin
  1200.       B.Position := hextoint(BHex.text, b);
  1201.       Change(b);
  1202.     end;
  1203.     if sender = BPro then
  1204.     begin
  1205.       if strtoint(tedit(sender).text) > 100 then
  1206.         tedit(sender).Text := inttostr(100);
  1207.       B.Position := round(strtoint(BPro.text) / bproc.max * 255);
  1208.       Change(b);
  1209.     end;
  1210.     if sender = HHex then
  1211.     begin
  1212.       H.Position := ceil(hextoint(HHex.text, h) / 255 * 359);
  1213.       Change(h);
  1214.     end;
  1215.     if sender = HGra then
  1216.     begin
  1217.       H.Position := strtoint(HGra.text);
  1218.       Change(h);
  1219.     end;
  1220.     if sender = SHex then
  1221.     begin
  1222.       S.Position := hextoint(SHex.text, s);
  1223.       Change(s);
  1224.     end;
  1225.     if sender = SPro then
  1226.     begin
  1227.       if strtoint(tedit(sender).text) > 100 then
  1228.         tedit(sender).Text := inttostr(100);
  1229.       S.Position := round(strtoint(SPro.text) / sproc.max * 255);
  1230.       Change(h);
  1231.     end;
  1232.     if sender = VHex then
  1233.     begin
  1234.       v.Position := hextoint(VHex.text, v);
  1235.       Change(v);
  1236.     end;
  1237.     if sender = VPro then
  1238.     begin
  1239.       if strtoint(tedit(sender).text) > 100 then
  1240.         tedit(sender).Text := inttostr(100);
  1241.       V.Position := round(strtoint(VPro.text) / vproc.max * 255);
  1242.       Change(h);
  1243.     end;
  1244.     if sender = RDec then
  1245.     begin
  1246.       if strtoint(RDec.Text) > RDecC.Max then RDec.Text := inttostr(RDecC.Max);
  1247.       if strtoint(RDec.Text) < RDecC.Min then RDec.Text := inttostr(RDecC.Min);
  1248.       R.Position := strtoint(RDec.text);
  1249.       Change(r);
  1250.     end;
  1251.     if sender = GDec then
  1252.     begin
  1253.       if strtoint(GDec.Text) > GDecC.Max then GDec.Text := inttostr(GDecC.Max);
  1254.       if strtoint(GDec.Text) < GDecC.Min then GDec.Text := inttostr(GDecC.Min);
  1255.       G.Position := strtoint(GDec.text);
  1256.       Change(g);
  1257.     end;
  1258.     if sender = BDec then
  1259.     begin
  1260.       if strtoint(BDec.Text) > BDecC.Max then BDec.Text := inttostr(BDecC.Max);
  1261.       if strtoint(BDec.Text) < BDecC.Min then BDec.Text := inttostr(BDecC.Min);
  1262.       B.Position := strtoint(BDec.text);
  1263.       Change(b);
  1264.     end;
  1265.     if sender = HDec then
  1266.     begin
  1267.       if strtoint(HDec.Text) > HDecC.Max then HDec.Text := inttostr(HDecC.Max);
  1268.       if strtoint(HDec.Text) < HDecC.Min then HDec.Text := inttostr(HDecC.Min);
  1269.       H.Position := ceil(strtoint(HDec.text) / 255 * 359);
  1270.       Change(H);
  1271.     end;
  1272.     if sender = SDec then
  1273.     begin
  1274.       if strtoint(SDec.Text) > SDecC.Max then SDec.Text := inttostr(SDecC.Max);
  1275.       if strtoint(SDec.Text) < SDecC.Min then SDec.Text := inttostr(SDecC.Min);
  1276.       S.Position := strtoint(SDec.text);
  1277.       Change(S);
  1278.     end;
  1279.     if sender = VDec then
  1280.     begin
  1281.       if strtoint(VDec.Text) > VDecC.Max then VDec.Text := inttostr(VDecC.Max);
  1282.       if strtoint(VDec.Text) < VDecC.Min then VDec.Text := inttostr(VDecC.Min);
  1283.       V.Position := strtoint(VDec.text);
  1284.       Change(V);
  1285.     end;
  1286.     if sender = Long then
  1287.     begin
  1288.       if strtoint(tedit(sender).text) > 16777215 then
  1289.         tedit(sender).Text := inttostr(16777215);
  1290.  
  1291.       R.OnChange := nil;
  1292.       G.OnChange := nil;
  1293.       B.OnChange := nil;
  1294.  
  1295.       R.Position := getrvalue(strtoint(long.text));
  1296.       G.Position := getgvalue(strtoint(long.text));
  1297.       B.Position := getbvalue(strtoint(long.text));
  1298.  
  1299.       R.OnChange := Change;
  1300.       G.OnChange := Change;
  1301.       B.OnChange := Change;
  1302.  
  1303.       Change(r);
  1304.       Change(g);
  1305.       Change(b);
  1306.     end;
  1307.     if sender = Photoshop then
  1308.     begin
  1309.       R.OnChange := nil;
  1310.       G.OnChange := nil;
  1311.       B.OnChange := nil;
  1312.  
  1313.       R.Position := hextoint(invertstring(copy(Photoshop.text, 5, 2)), r);
  1314.       G.Position := hextoint(invertstring(copy(Photoshop.text, 3, 2)), g);
  1315.       B.Position := hextoint(invertstring(copy(Photoshop.text, 1, 2)), b);
  1316.  
  1317.       R.OnChange := Change;
  1318.       G.OnChange := Change;
  1319.       B.OnChange := Change;
  1320.  
  1321.       Change(r);
  1322.       Change(g);
  1323.       Change(b);
  1324.     end;
  1325.     if sender = Java then
  1326.     begin
  1327.       R.OnChange := nil;
  1328.       G.OnChange := nil;
  1329.       B.OnChange := nil;
  1330.  
  1331.       R.Position := hextoint(invertstring(copy(Java.text, 7, 2)), r);
  1332.       G.Position := hextoint(invertstring(copy(Java.text, 5, 2)), g);
  1333.       B.Position := hextoint(invertstring(copy(Java.text, 3, 2)), b);
  1334.  
  1335.       R.OnChange := Change;
  1336.       G.OnChange := Change;
  1337.       B.OnChange := Change;
  1338.  
  1339.       Change(r);
  1340.       Change(g);
  1341.       Change(b);
  1342.     end;
  1343.     if sender = VisualBasic then
  1344.     begin
  1345.       R.OnChange := nil;
  1346.       G.OnChange := nil;
  1347.       B.OnChange := nil;
  1348.  
  1349.       R.Position := hextoint(copy(VisualBasic.text, 8, 2), r);
  1350.       G.Position := hextoint(copy(VisualBasic.text, 6, 2), g);
  1351.       B.Position := hextoint(copy(VisualBasic.text, 4, 2), b);
  1352.  
  1353.       R.OnChange := Change;
  1354.       G.OnChange := Change;
  1355.       B.OnChange := Change;
  1356.  
  1357.       Change(r);
  1358.       Change(g);
  1359.       Change(b);
  1360.     end;
  1361.     if sender = VisualC then
  1362.     begin
  1363.       R.OnChange := nil;
  1364.       G.OnChange := nil;
  1365.       B.OnChange := nil;
  1366.  
  1367.       R.Position := hextoint(copy(VisualC.text, 9, 2), r);
  1368.       G.Position := hextoint(copy(VisualC.text, 7, 2), g);
  1369.       B.Position := hextoint(copy(VisualC.text, 5, 2), b);
  1370.  
  1371.       R.OnChange := Change;
  1372.       G.OnChange := Change;
  1373.       B.OnChange := Change;
  1374.  
  1375.       Change(r);
  1376.       Change(g);
  1377.       Change(b);
  1378.     end;
  1379.     if sender = Delphi then
  1380.     begin
  1381.       R.OnChange := nil;
  1382.       G.OnChange := nil;
  1383.       B.OnChange := nil;
  1384.  
  1385.       R.Position := hextoint(copy(Delphi.text, 8, 2), r);
  1386.       G.Position := hextoint(copy(Delphi.text, 6, 2), g);
  1387.       B.Position := hextoint(copy(Delphi.text, 4, 2), b);
  1388.  
  1389.       R.OnChange := Change;
  1390.       G.OnChange := Change;
  1391.       B.OnChange := Change;
  1392.  
  1393.       Change(r);
  1394.       Change(g);
  1395.       Change(b);
  1396.     end;
  1397.     if sender = HTML then
  1398.     begin
  1399.       R.OnChange := nil;
  1400.       G.OnChange := nil;
  1401.       B.OnChange := nil;
  1402.  
  1403.       R.Position := hextoint(copy(html.text, 2, 2), r);
  1404.       G.Position := hextoint(copy(html.text, 4, 2), g);
  1405.       B.Position := hextoint(copy(html.text, 6, 2), b);
  1406.  
  1407.       R.OnChange := Change;
  1408.       G.OnChange := Change;
  1409.       B.OnChange := Change;
  1410.  
  1411.       Change(r);
  1412.       Change(g);
  1413.       Change(b);
  1414.     end;
  1415.   end;
  1416. end;
  1417.  
  1418. procedure TMainForm.UpDownClick(Sender: TObject; Button: TUDBtnType);
  1419. begin
  1420.   if hgrac.Position = hgrac.Min then
  1421.     hgrac.Position := hgrac.Max-1;
  1422.   if hgrac.Position = hgrac.Max then
  1423.     hgrac.Position := hgrac.Min+1;
  1424.   if (sender = RHexC) or (sender = RDecC) then
  1425.     R.Position := TUpDown(sender).Position;
  1426.   if (sender = RProC) then
  1427.     R.Position := round(RProC.Position / 100 * 255);
  1428.   if (sender = GHexC) or (sender = GDecC) then
  1429.     G.Position := TUpDown(sender).Position;
  1430.   if (sender = GProC) then
  1431.     G.Position := round(GProC.Position / 100 * 255);
  1432.   if (sender = BHexC) or (sender = BDecC) then
  1433.     B.Position := TUpDown(sender).Position;
  1434.   if (sender = BProC) then
  1435.     B.Position := round(BProC.Position / 100 * 255);
  1436.   if (sender = HHexC) or (sender = HDecC) then
  1437.     H.Position := ceil(TUpDown(sender).Position / 255 * 359);
  1438.   if (sender = HGraC) then
  1439.     H.Position := TUpDown(sender).Position;
  1440.   if (sender = SHexC) or (sender = SDecC) then
  1441.     S.Position := TUpDown(sender).Position;
  1442.   if (sender = SProC) then
  1443.     S.Position := round(SProC.Position / 100 * 255);
  1444.   if (sender = VHexC) or (sender = VDecC) then
  1445.     V.Position := TUpDown(sender).Position;
  1446.   if sender = VProC then
  1447.     V.Position := round(VProC.Position / 100 * 255);
  1448.   if (sender = Color1Upd) then
  1449.   begin
  1450.     Color1Edt.Text := inttostr(Color1Upd.Position);
  1451.     Color2Upd.Position := Color1Upd.Max - Color1Upd.Position;
  1452.     Color2Edt.Text := inttostr(Color2Upd.Position);
  1453.     BerechneMixColor;
  1454.   end;
  1455.   if (sender = Color2Upd) then
  1456.   begin
  1457.     Color2Edt.Text := inttostr(Color2Upd.Position);
  1458.     Color1Upd.Position := Color2Upd.Max - Color2Upd.Position;
  1459.     Color1Edt.Text := inttostr(Color1Upd.Position);
  1460.     BerechneMixColor;
  1461.   end;
  1462. end;
  1463.  
  1464. procedure TMainForm.AktualisiereWert(Sender: TObject);
  1465. begin
  1466.   if sender = R then
  1467.   begin
  1468.     RHex.text := inttohex(R.position, 0);
  1469.     RHexC.Position := R.Position;
  1470.     RDec.text := inttostr(R.position);
  1471.     RDecC.Position := R.Position;
  1472.     RPro.Text := inttostr(round(R.position / 255 * 100));
  1473.     RProC.Position := round(R.position / 255 * 100);
  1474.   end;
  1475.   if sender = G then
  1476.   begin
  1477.     GHex.text := inttohex(G.position, 0);
  1478.     GHexC.Position := G.Position;
  1479.     GDec.text := inttostr(G.position);
  1480.     GDecC.Position := G.Position;
  1481.     GPro.Text := inttostr(round(G.position / 255 * 100));
  1482.     GProC.Position := round(G.position / 255 * 100);
  1483.   end;
  1484.   if sender = B then
  1485.   begin
  1486.     BHex.text := inttohex(B.position, 0);
  1487.     BHexC.Position := B.position;
  1488.     BDec.text := inttostr(B.position);
  1489.     BDecC.Position := B.position;
  1490.     BPro.Text := inttostr(round(B.position / 255 * 100));
  1491.     BProC.Position := round(B.position / 255 * 100);
  1492.   end;
  1493.   if sender = H then
  1494.   begin
  1495.     HHex.text := inttohex(ceil(H.position / 359 * 255), 0);
  1496.     HHexC.Position := ceil(H.position / 359 * 255);
  1497.     HDec.text := inttostr(ceil(H.position / 359 * 255));
  1498.     HDecC.Position := ceil(H.position / 359 * 255);
  1499.     HGra.text := inttostr(H.position);
  1500.     HGraC.Position := H.position;
  1501.   end;
  1502.   if sender = S then
  1503.   begin
  1504.     SHex.text := inttohex(S.position, 0);
  1505.     SHexC.Position := S.position;
  1506.     SDec.text := inttostr(S.position);
  1507.     SDecC.Position := S.position;
  1508.     SPro.Text := inttostr(round(S.position / 255 * 100));
  1509.     SProC.Position := round(S.position / 255 * 100);
  1510.   end;
  1511.   if sender = V then
  1512.   begin
  1513.     VHex.text := inttohex(V.position, 0);
  1514.     VHexC.Position := V.position;
  1515.     VDec.text := inttostr(V.position);
  1516.     VDecC.Position := V.position;
  1517.     VPro.Text := inttostr(round(V.position / 255 * 100));
  1518.     VProC.Position := round(V.position / 255 * 100);
  1519.   end;
  1520. end;
  1521.  
  1522. procedure TMainForm.Ladefarbe(col: tcolor);
  1523. begin
  1524.   r.Position := GetRValue(col);
  1525.   g.Position := GetGValue(col);
  1526.   b.Position := GetBValue(col);
  1527. end;
  1528.  
  1529. procedure TMainForm.Change(Sender: TObject);
  1530. begin
  1531.   if (sender = r) then
  1532.   begin
  1533.     DrawGrad(2);
  1534.     DrawGrad(3);
  1535.     DrawGrad(4);
  1536.     DrawGrad(5);
  1537.     DrawGrad(6);
  1538.   end;
  1539.   if (sender = g) then
  1540.   begin
  1541.     DrawGrad(1);
  1542.     DrawGrad(3);
  1543.     DrawGrad(4);
  1544.     DrawGrad(5);
  1545.     DrawGrad(6);
  1546.   end;
  1547.   if (sender = b) then
  1548.   begin
  1549.     DrawGrad(1);
  1550.     DrawGrad(2);
  1551.     DrawGrad(4);
  1552.     DrawGrad(5);
  1553.     DrawGrad(6);
  1554.   end;
  1555.   if (sender = h) then
  1556.   begin
  1557.     DrawGrad(1);
  1558.     DrawGrad(2);
  1559.     DrawGrad(3);
  1560.     DrawGrad(5);
  1561.     DrawGrad(6);
  1562.   end;
  1563.   if (sender = s) then
  1564.   begin
  1565.     DrawGrad(1);
  1566.     DrawGrad(2);
  1567.     DrawGrad(3);
  1568.     DrawGrad(4);
  1569.     DrawGrad(6);
  1570.   end;
  1571.   if (sender = v) then
  1572.   begin
  1573.     DrawGrad(1);
  1574.     DrawGrad(2);
  1575.     DrawGrad(3);
  1576.     DrawGrad(4);
  1577.     DrawGrad(5);
  1578.   end;
  1579.  
  1580.   AktualisiereWert(sender);
  1581.   AktualisiereFarben((sender = R) or (sender = G) or (sender = B));
  1582. end;
  1583.  
  1584. procedure TMainForm.PickBtnClick(Sender: TObject);
  1585. begin
  1586.   SetCapture(MainForm.Handle);
  1587.   PickBtn.Enabled := false;
  1588.   //PickTimer.Enabled := true;
  1589.   Caption := Application.Title + ' ['+getlangentry('capture')+']';
  1590. end;
  1591.  
  1592. procedure TMainForm.PickTimerTimer(Sender: TObject);
  1593. var
  1594.   CursorPos: TPoint;
  1595.   PixelCol: TColor;
  1596.   AverageR, AverageG, AverageB: integer;
  1597.   x, y: shortint;
  1598. begin
  1599.   if PageControl1.ActivePage <> TabSheet3 then exit;
  1600.  
  1601.   GetCursorPos(CursorPos);
  1602.   CoordsLbl.Caption := Format('%d,' + #13 + '%d', [CursorPos.x, CursorPos.y]);
  1603.  
  1604.   AverageR := 0;
  1605.   AverageG := 0;
  1606.   Averageb := 0;
  1607.   for y := -floor((AverageY.Value-1)/2) to ceil((AverageY.Value-1)/2) do
  1608.     for x := -floor((AverageX.Value-1)/2) to ceil((AverageX.Value-1)/2) do
  1609.     begin
  1610.       PixelCol := GetPixel(ScreenDC, CursorPos.x + x, CursorPos.y + y);
  1611.       AverageR := AverageR + GetRValue(PixelCol);
  1612.       AverageG := AverageG + GetGValue(PixelCol);
  1613.       AverageB := AverageB + GetBValue(PixelCol);
  1614.     end;
  1615.   if AverageX.Value*AverageY.Value > 0 then
  1616.     AverageR := AverageR div (AverageX.Value*AverageY.Value);
  1617.   if AverageX.Value*AverageY.Value > 0 then
  1618.     AverageG := AverageG div (AverageX.Value*AverageY.Value);
  1619.   if AverageX.Value*AverageY.Value > 0 then
  1620.     AverageB := AverageB div (AverageX.Value*AverageY.Value);
  1621.  
  1622.   PixelCol := RGB(Lo(AverageR), Lo(AverageG), Lo(AverageB));
  1623.  
  1624.   BitBlt(MemPix.Canvas.Handle,
  1625.      0, 0,
  1626.      AverageX.Value, AverageY.Value,
  1627.      ScreenDC,
  1628.      CursorPos.x - floor(AverageX.Value/2), CursorPos.y - floor(AverageY.Value/2),
  1629.      SRCCOPY);
  1630.   StretchBlt(MagBox.Canvas.Handle,
  1631.      0, 0,
  1632.      MagBox.Width, MagBox.Height,
  1633.      MemPix.Canvas.Handle,
  1634.      0, 0,
  1635.      AverageX.Value, AverageY.Value,
  1636.      SRCCOPY);
  1637.  
  1638.   if not PickBtn.Enabled then
  1639.     Ladefarbe(PixelCol);
  1640. end;
  1641.  
  1642. procedure TMainForm.RandomBtnClick(Sender: TObject);
  1643. begin
  1644.   R.Position := Random(255);
  1645.   G.Position := Random(255);
  1646.   B.Position := Random(255);
  1647. end;
  1648.  
  1649. procedure TMainForm.BerechneMixColor();
  1650. var
  1651.   r, g, b: integer;
  1652. begin
  1653.   r := round(Color1Upd.Position / 100 * getrvalue(color1.Color) + Color2Upd.Position / 100 * getrvalue(color2.Color));
  1654.   g := round(Color1Upd.Position / 100 * getgvalue(color1.Color) + Color2Upd.Position / 100 * getgvalue(color2.Color));
  1655.   b := round(Color1Upd.Position / 100 * getbvalue(color1.Color) + Color2Upd.Position / 100 * getbvalue(color2.Color));
  1656.  
  1657.   mixedcolor.Color := rgb(r, g, b);
  1658.   mixedcolor.font.color := BlackWhiteContrastColor(mixedcolor.color);
  1659. end;
  1660.  
  1661. procedure TMainForm.MenuClick(Sender: TObject);
  1662. begin
  1663.   if sender = mAktuell then
  1664.     tpanel(PopupmenuSender).Color := colorpanel.Color;
  1665.   if sender = mKomplementaer then
  1666.     tpanel(PopupmenuSender).Color := komplementaercolor.Color;
  1667.   if sender = mWebsafe then
  1668.     tpanel(PopupmenuSender).Color := websafe1.Color;
  1669.   if sender = mWebsafeInv then
  1670.     tpanel(PopupmenuSender).Color := websafe2.Color;
  1671.   if sender = mMixColor then
  1672.     tpanel(PopupmenuSender).Color := mixedcolor.Color;
  1673.   if sender = mUmkehren then
  1674.     tpanel(PopupmenuSender).Color :=  tpanel(PopupmenuSender).Color xor $FFFFFF;
  1675.   tpanel(PopupmenuSender).Font.Color := BlackWhiteContrastColor(tpanel(PopupmenuSender).Color);
  1676.   BerechneMixColor;
  1677.  
  1678.   if (PopupmenuSender = favo1) or (PopupmenuSender = favo2) or (PopupmenuSender = favo3) or
  1679.      (PopupmenuSender = favo4) or (PopupmenuSender = favo5) or (PopupmenuSender = favo6) or
  1680.      (PopupmenuSender = favo7) or (PopupmenuSender = favo8) or (PopupmenuSender = favo9) or
  1681.      (PopupmenuSender = favo10) or (PopupmenuSender = favo11) or (PopupmenuSender = favo12) or
  1682.      (PopupmenuSender = favo13) or (PopupmenuSender = favo14) or (PopupmenuSender = favo15) or
  1683.      (PopupmenuSender = favo16) or (PopupmenuSender = favo17) or (PopupmenuSender = favo18) or
  1684.      (PopupmenuSender = favo19) or (PopupmenuSender = favo20) then
  1685.     WriteIntSetting(tpanel(PopupmenuSender).GetNamePath, colortorgb(tpanel(PopupmenuSender).color));
  1686. end;
  1687.  
  1688. procedure TMainForm.Menu2Click(Sender: TObject);
  1689. begin
  1690.   if sender = mAktuell2 then
  1691.     Ladefarbe(tpanel(PopupmenuSender).Color);
  1692.   if sender = mKomplementaer2 then
  1693.     Ladefarbe(tpanel(PopupmenuSender).Color xor $FFFFFF);
  1694. end;
  1695.  
  1696. procedure TMainForm.GreyscaleBtnClick(Sender: TObject);
  1697. var
  1698.   i: integer;
  1699. begin
  1700.   //S.Position := 0;
  1701.  
  1702.   i := Round((R.Position*0.2126) + (G.Position*0.7152) + (B.Position*0.0722));
  1703.  
  1704.   R.OnChange := nil;
  1705.   G.OnChange := nil;
  1706.   B.OnChange := nil;
  1707.  
  1708.   R.Position := i;
  1709.   G.Position := i;
  1710.   B.Position := i;
  1711.  
  1712.   AktualisiereWert(r);
  1713.   AktualisiereWert(g);
  1714.   AktualisiereWert(b);
  1715.  
  1716.   R.OnChange := Change;
  1717.   G.OnChange := Change;
  1718.   B.OnChange := Change;
  1719.  
  1720.   AktualisiereFarben(true);
  1721. end;
  1722.  
  1723. procedure TMainForm.DefColorClick(Sender: TObject);
  1724. begin
  1725.   LadeFarbe(tpanel(sender).Color);
  1726. end;
  1727.  
  1728. procedure TMainForm.DelphiBoxClick(Sender: TObject);
  1729. var
  1730.   tmp: string;
  1731. begin
  1732.   tmp := inttohex(colortorgb(delphibox.Selected), 6); // Systemfarben umwandeln
  1733.  
  1734.   R.OnChange := nil;
  1735.   G.OnChange := nil;
  1736.   B.OnChange := nil;
  1737.  
  1738.   R.Position := hextoint(copy(tmp, 5, 2), r);
  1739.   G.Position := hextoint(copy(tmp, 3, 2), g);
  1740.   B.Position := hextoint(copy(tmp, 1, 2), b);
  1741.  
  1742.   AktualisiereWert(r);
  1743.   AktualisiereWert(g);
  1744.   AktualisiereWert(b);
  1745.  
  1746.   R.OnChange := Change;
  1747.   G.OnChange := Change;
  1748.   B.OnChange := Change;
  1749.  
  1750.   // DelphiBox muss nicht mehr ignoriert werden, da wir nun "CheckDelphiFarben"
  1751.   // verwenden und nichts mehr in der DelphiBox markieren
  1752.   // AktualisiereFarben(true, 1);
  1753.   AktualisiereFarben(true);
  1754. end;
  1755.  
  1756. procedure TMainForm.TakeClick(Sender: TObject);
  1757. begin
  1758.   Ladefarbe(tpanel(sender).color);
  1759. end;
  1760.  
  1761. procedure TMainForm.InvertBtnClick(Sender: TObject);
  1762. begin
  1763.   TakeClick(KomplementaerColor);
  1764. end;
  1765.  
  1766. procedure TMainForm.WebsafeLblClick(Sender: TObject);
  1767. begin
  1768.   TakeClick(websafe1);
  1769. end;
  1770.  
  1771. procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
  1772. begin
  1773.   ReleaseDC(0, ScreenDC);
  1774.   FreeAndNil(MemPix);
  1775.   FreeAndNil(BoxBuf);
  1776.   FreeAndNil(Box2Buf);
  1777. end;
  1778.  
  1779. procedure TMainForm.OutboxPaint(Sender: TObject);
  1780. begin
  1781.   DrawGrad(TPaintbox(Sender).Tag);
  1782. end;
  1783.  
  1784. procedure TMainForm.ZeigeRichtigePalette;
  1785. begin
  1786.   WinPanel.Visible := Pal.ItemIndex = 0;
  1787.   JskPanel.Visible := Pal.ItemIndex = 1;
  1788. end;
  1789.  
  1790. procedure TMainForm.PalClick(Sender: TObject);
  1791. begin
  1792.   ZeigeRichtigePalette;
  1793.   WriteIntSetting('Palette', Pal.ItemIndex);
  1794. end;
  1795.  
  1796. procedure TMainForm.WinDialogClick(Sender: TObject);
  1797. begin
  1798.   WinColorDialog.Color := ColorPanel.Color;
  1799.   if WinColorDialog.Execute then
  1800.     LadeFarbe(WinColorDialog.Color);
  1801. end;
  1802.  
  1803. procedure TMainForm.WebcolorBoxClick(Sender: TObject);
  1804. begin
  1805.   html.Text := UpperCase(webfarben[webcolorbox.ItemIndex]);
  1806.  
  1807.   R.OnChange := nil;
  1808.   G.OnChange := nil;
  1809.   B.OnChange := nil;
  1810.  
  1811.   R.Position := hextoint(copy(html.text, 2, 2), r);
  1812.   G.Position := hextoint(copy(html.text, 4, 2), g);
  1813.   B.Position := hextoint(copy(html.text, 6, 2), b);
  1814.  
  1815.   R.OnChange := Change;
  1816.   G.OnChange := Change;
  1817.   B.OnChange := Change;
  1818.  
  1819.   DrawGrad(1);
  1820.   DrawGrad(2);
  1821.   DrawGrad(3);
  1822.   DrawGrad(4);
  1823.   DrawGrad(5);
  1824.   DrawGrad(6);
  1825.  
  1826.   AktualisiereWert(r);
  1827.   AktualisiereWert(g);
  1828.   AktualisiereWert(b);
  1829.  
  1830.   // WebcolorBox muss nicht mehr ignoriert werden, da wir nun "CheckWebfarben"
  1831.   // verwenden und nichts mehr in der WebcolorBox markieren
  1832.   // AktualisiereFarben(true, 2);
  1833.   AktualisiereFarben(true);
  1834. end;
  1835.  
  1836. procedure TMainForm.CheckWebfarben;
  1837. var
  1838.   i: integer;
  1839. begin
  1840.   WebZutreffend.Clear;
  1841.   if webcolorbox.itemindex <> -1 then
  1842.     if not SameText(html.text, webfarben[webcolorbox.itemindex]) then
  1843.       webcolorbox.itemindex := -1;
  1844.   for i := 0 to high(webfarben) do
  1845.   begin
  1846.     if SameText(html.text, webfarben[i]) then
  1847.       WebZutreffend.Items.add(webcolorbox.Items.Strings[i]); // Geht nicht mit mehreren Übereinstimmungen: webcolorbox.ItemIndex := i;
  1848.   end;
  1849. end;
  1850.  
  1851. procedure TMainForm.CheckDelphiFarben;
  1852. var
  1853.   i: integer;
  1854. begin
  1855.   DelphiZutreffend.Clear;
  1856.   if colortorgb(delphibox.selected) <> colortorgb(colorpanel.Color) then
  1857.     delphibox.ItemIndex := -1;
  1858.   for i := 0 to delphibox.Items.Count - 1 do
  1859.   begin
  1860.     if colortorgb(delphibox.Colors[i]) = colortorgb(colorpanel.Color) then
  1861.       DelphiZutreffend.Items.add(delphibox.ColorNames[i]); // Geht nicht mit mehreren Übereinstimmungen: delphibox.ItemIndex := i;
  1862.   end;
  1863. end;
  1864.  
  1865. procedure TMainForm.DelphiZutreffendClick(Sender: TObject);
  1866. begin
  1867.   if delphizutreffend.ItemIndex <> -1 then
  1868.     delphibox.ItemIndex := delphibox.Items.IndexOf(delphizutreffend.Items.Strings[delphizutreffend.ItemIndex]);
  1869. end;
  1870.  
  1871. procedure TMainForm.WebZutreffendClick(Sender: TObject);
  1872. begin
  1873.   if webzutreffend.ItemIndex <> -1 then
  1874.     webcolorbox.ItemIndex := webcolorbox.Items.IndexOf(webzutreffend.Items.Strings[webzutreffend.ItemIndex]);
  1875. end;
  1876.  
  1877. procedure TMainForm.LinkClick(Sender: TObject);
  1878. begin
  1879.   if sender = info7 then
  1880.     ShellExecute(Application.Handle, 'open', pchar('mailto:'+tlabel(sender).caption+'?subject=ColorManager 2.1'), nil, nil, SW_SHOW);
  1881.   if (sender = Info9) or (sender = Info13) then
  1882.     ShellExecute(Application.Handle, 'open', pchar(Info9.caption), nil, nil, SW_SHOW);
  1883.   if (sender = Info14) then
  1884.     ShellExecute(Application.Handle, 'open', 'https://www.viathinksoft.de/', nil, nil, SW_SHOW);
  1885.   if (sender = Info15) then
  1886.     ShellExecute(Application.Handle, 'open', 'https://www.viathinksoft.de/projects/colormanager', nil, nil, SW_SHOW);
  1887. end;
  1888.  
  1889. var
  1890.   ColorTmrDurchlauf: integer;
  1891.  
  1892. procedure TMainForm.ColorTmrTimer(Sender: TObject);
  1893. begin
  1894.   ColorTmrDurchlauf :=ColorTmrDurchlauf + 10;
  1895.   if ColorTmrDurchlauf >= 360 then
  1896.     ColorTmrDurchlauf := ColorTmrDurchlauf - 360;
  1897.   if panel4.Visible then
  1898.     Info1.Font.Color := hsvtorgb(ColorTmrDurchlauf, 255, 200);
  1899. end;
  1900.  
  1901. procedure TMainForm.WriteIntSetting(name: string; wert: integer);
  1902. var
  1903.   reg: TRegistry;
  1904. begin
  1905.   reg := tregistry.Create;
  1906.   try
  1907.     Reg.RootKey := HKEY_CURRENT_USER;
  1908.     Reg.OpenKey('SOFTWARE\ViaThinkSoft\ColorManager\', true);
  1909.     Reg.WriteInteger(name, wert);
  1910.     Reg.CloseKey;
  1911.   finally
  1912.     Reg.Free;
  1913.   end;
  1914. end;
  1915.  
  1916. function TMainForm.ReadIntSetting(name: string): integer;
  1917. var
  1918.   reg: TRegistry;
  1919. begin
  1920.   result := 0;
  1921.   reg := tregistry.Create;
  1922.   try
  1923.     Reg.RootKey := HKEY_CURRENT_USER;
  1924.     Reg.OpenKey('SOFTWARE\ViaThinkSoft\ColorManager\', true);
  1925.     if Reg.ValueExists(name) then
  1926.       result := Reg.ReadInteger(name);
  1927.     Reg.CloseKey;
  1928.   finally
  1929.     Reg.Free;
  1930.   end;
  1931. end;
  1932.  
  1933. procedure TMainForm.SaveEditChange(Sender: TObject);
  1934. begin
  1935.   WriteIntSetting(tedit(sender).GetNamePath, strtoint(tedit(sender).text));
  1936. end;
  1937.  
  1938. procedure TMainForm.ColorClick(Sender: TObject; Button: TMouseButton;
  1939.   Shift: TShiftState; X, Y: Integer);
  1940. var
  1941.   MausPos: TPoint;
  1942. begin
  1943.   PopupMenuSender := sender;
  1944.   GetCursorPos(MausPos);
  1945.   Popupmenu.Items.Items[0].Enabled := sender <> MixedColor;
  1946.   Popupmenu.Items.Items[2].Enabled := sender <> MixedColor;
  1947.   popupmenu.Popup(MausPos.x, MausPos.y);
  1948. end;
  1949.  
  1950. end.
  1951.  
  1952.