Accueil > > > COMPOSANT : TDBPCOLORPIKKER
COMPOSANT : TDBPCOLORPIKKER
Information sur la source
Description
Hello ! voici mon 18eme composant réalisé avec Delphi7 Le colorPikker est connu, il s'agit de la pipette ki chope le code RGB et HEXA de la pixel située sous le curseur de la souris. Elle contient le source de BLG, je lui ai ajouté des propriétés tres utile, on peut meintenant refaire le source de BLG avec 4 composants (donc 3 de base +1 le mien) et 0 ligne de code, je vous file la demo (projet + exe) pour vous en convaincre :) la fonction contenu dans le ActTimer est de BLG, merci a lui de m'avoir "expliqué" (lol) que c'etait le handle qui faisait office de refresh automatique :D PS : CECI EST UN COMPOSANT NON VISIBLE :) source de BLG : http://www.delphifr.com/code.aspx?ID=28414
Source
- {
- ################################################################################
- # DBPCOLORPIKKER #
- ################################################################################
- # #
- # VERSION : 1.3 #
- # FICHIERS : dbpColorPikker.pas,.dcu,.dcr,.bmp,ReadMe.htm #
- # AUTEUR : Julio P. (Diabloporc) #
- # CREATION : 31 dec 2004 #
- # MODIFIEE : 02 dec 2004 #
- # SITE WEB : http://diabloporc.free.fr #
- # MAIL : juliobox@free.fr #
- # LEGAL : Free sous Licence GNU/GPL #
- # INFOS : Retrouvez moi sur www.delphifr.com : "JulioDelphi" #
- # #
- ################################################################################
- }
- unit dbpcolorpikker;
-
- interface
-
- uses
- controls, windows, SysUtils, Classes, graphics, extctrls, stdctrls;
-
- type
- TdbpInterval = 10..60000;
-
- TdbpColorPikker = class(TComponent)
- private
- FAbout: string;
- FBValue: Word;
- FCanvas: TCanvas;
- FColor: TColor;
- FColorInverted: TColor;
- FEnabled: Boolean;
- FFontColor: TColor;
- FGValue: Word;
- FHexa: Cardinal;
- FHexaString: string;
- FLabelHexa: TLabel;
- FLabelRGB: TLabel;
- FRGBString: string;
- FRValue: Word;
- FShape: TShape;
- FTimer: TTimer;
- FTimerEvent: TNotifyEvent;
- FTimerInterval: TdbpInterval;
- FUseInvertedFont: Boolean;
- procedure SetAbout(const s: string);
- procedure SetEnabled(Value: Boolean);
- procedure SetInterval(Value: TdbpInterval);
- protected
- procedure ActTimer(Sender: TObject);
- procedure Notification(AComponent: TComponent; Operation: TOperation);
- override;
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- property BlueValue: Word read FBValue;
- property Color: TColor read FColor;
- property ColorInverted: TColor read FColorInverted;
- property GreenValue: Word read FGValue;
- property HexaString: string read FHexaString;
- property HexaValue: Cardinal read FHexa;
- property RedValue: Word read FRValue;
- property RGBString: string read FRGBString;
- published
- property About: string read FAbout write SetAbout;
- property DefaultFontColor: TColor read FFontColor write FFontColor;
- property Enabled: Boolean read FEnabled write SetEnabled default False;
- property Interval: TdbpInterval read FTimerInterval write SetInterval default 10;
- property LabelHexa: TLabel read FLabelHexa write FLabelHexa;
- property LabelRGB: TLabel read FLabelRGB write FLabelRGB;
- property OnTimer: TNotifyEvent read FTimerEvent write FTimerEvent;
- property Shape: TShape read FShape write FShape;
- property UseInvertedFont: Boolean read FUseInvertedFont write
- FUseInvertedFont default false;
- end;
-
- procedure Register;
-
- implementation
-
- {
- ******************************* TdbpColorPikker ********************************
- }
-
- constructor TdbpColorPikker.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- fCanvas := TCanvas.Create;
- fCanvas.Handle := GetWindowDC(GetDesktopWindow);
- fAbout := 'v1.3 par Julio P. (diabloporc)';
- fEnabled := False;
- fColor := clBlack;
- fRValue := 0;
- fGValue := 0;
- fBValue := 0;
- fHexa := 0;
- fTimerInterval := 10;
- fRGBString := 'RGB(0,0,0)';
- fHexaString := '#000000';
- fUseInvertedFont := false;
- fFontColor := clBlack;
-
- fTimer := TTimer.Create(self);
- fTimer.Enabled := fEnabled;
- fTimer.Interval := fTimerInterval;
- fTimer.OnTimer := ActTimer;
- end;
-
- destructor TdbpColorPikker.Destroy;
- begin
- fTimer.free;
- fCanvas.Free;
- inherited destroy;
- end;
-
- procedure TdbpColorPikker.ActTimer(Sender: TObject);
- begin
- if (csDesigning in ComponentState) then
- exit;
- fColor := fCanvas.Pixels[Mouse.CursorPos.X, Mouse.CursorPos.Y];
- fColorInverted := $00FFFFFF - fColor;
- fRValue := GetRValue(fColor);
- fGValue := GetGValue(fColor);
- fBValue := GetBValue(fColor);
- fHexa := StrToInt(format('$%s%s%s', [IntToHex(GetRValue(fColor), 2),
- IntToHex(GetGValue(fColor), 2), IntToHex(GetBValue(fColor), 2)]));
- fRGBString := format('RGB(%d,%d,%d)', [fRValue, fGValue, FBValue]);
- {fHExaString := format('#%s%s%s', [IntToHex(GetRValue(fColor), 2),
- IntToHex(GetGValue(fColor), 2), IntToHex(GetBValue(fColor), 2)]);}
-
- FHexaString := Format('#%.2x%.2x%.2x', [FRValue, FGValue, FBValue]);
-
- if assigned(FShape) then
- FShape.Brush.Color := fColor;
-
- if FUseInvertedFont then
- begin
- if Assigned(FLabelRGB) then
- fLabelRgb.Font.Color := fColorInverted;
- if Assigned(FLabelHexa) then
- FLabelHexa.Font.Color := FColorInverted;
- end
- else
- begin
- if Assigned(FLabelRgb) then
- FLabelRGB.Font.Color := fFontColor;
- if Assigned(FLabelHexa) then
- FLabelHexa.Font.Color := FFontColor;
- end;
-
- if assigned(fLabelRGB) then
- fLabelRGB.caption := fRGBString;
-
- if assigned(fLabelHexa) then
- fLabelHexa.caption := fHexaString;
-
- if Assigned(FTimerEvent) then
- FTimerEvent(Self);
- end;
-
- procedure TdbpColorPikker.Notification(AComponent: TComponent; Operation:
- TOperation);
- begin
- if Operation = opRemove then
- begin
- if aComponent = FShape then
- FShape := nil;
-
- if aComponent = fLabelRGB then
- fLabelRGB := nil;
-
- if aComponent = fLabelHexa then
- fLabelHexa := nil;
- end;
- end;
-
- procedure TdbpColorPikker.SetAbout(const s: string);
- begin
- //
- end;
-
- procedure TdbpColorPikker.SetEnabled(Value: Boolean);
- begin
- if Value = fEnabled then
- exit;
- fEnabled := value;
- fTimer.Enabled := Value;
- end;
-
- procedure TdbpColorPikker.SetInterval(Value: TdbpInterval);
- begin
- fTimer.interval := value;
- fTimerInterval := Value;
- end;
-
- procedure Register;
- begin
- RegisterComponents('Diabloporc', [TdbpColorPikker]);
- end;
-
- end.
-
{
################################################################################
# DBPCOLORPIKKER #
################################################################################
# #
# VERSION : 1.3 #
# FICHIERS : dbpColorPikker.pas,.dcu,.dcr,.bmp,ReadMe.htm #
# AUTEUR : Julio P. (Diabloporc) #
# CREATION : 31 dec 2004 #
# MODIFIEE : 02 dec 2004 #
# SITE WEB : http://diabloporc.free.fr #
# MAIL : juliobox@free.fr #
# LEGAL : Free sous Licence GNU/GPL #
# INFOS : Retrouvez moi sur www.delphifr.com : "JulioDelphi" #
# #
################################################################################
}
unit dbpcolorpikker;
interface
uses
controls, windows, SysUtils, Classes, graphics, extctrls, stdctrls;
type
TdbpInterval = 10..60000;
TdbpColorPikker = class(TComponent)
private
FAbout: string;
FBValue: Word;
FCanvas: TCanvas;
FColor: TColor;
FColorInverted: TColor;
FEnabled: Boolean;
FFontColor: TColor;
FGValue: Word;
FHexa: Cardinal;
FHexaString: string;
FLabelHexa: TLabel;
FLabelRGB: TLabel;
FRGBString: string;
FRValue: Word;
FShape: TShape;
FTimer: TTimer;
FTimerEvent: TNotifyEvent;
FTimerInterval: TdbpInterval;
FUseInvertedFont: Boolean;
procedure SetAbout(const s: string);
procedure SetEnabled(Value: Boolean);
procedure SetInterval(Value: TdbpInterval);
protected
procedure ActTimer(Sender: TObject);
procedure Notification(AComponent: TComponent; Operation: TOperation);
override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property BlueValue: Word read FBValue;
property Color: TColor read FColor;
property ColorInverted: TColor read FColorInverted;
property GreenValue: Word read FGValue;
property HexaString: string read FHexaString;
property HexaValue: Cardinal read FHexa;
property RedValue: Word read FRValue;
property RGBString: string read FRGBString;
published
property About: string read FAbout write SetAbout;
property DefaultFontColor: TColor read FFontColor write FFontColor;
property Enabled: Boolean read FEnabled write SetEnabled default False;
property Interval: TdbpInterval read FTimerInterval write SetInterval default 10;
property LabelHexa: TLabel read FLabelHexa write FLabelHexa;
property LabelRGB: TLabel read FLabelRGB write FLabelRGB;
property OnTimer: TNotifyEvent read FTimerEvent write FTimerEvent;
property Shape: TShape read FShape write FShape;
property UseInvertedFont: Boolean read FUseInvertedFont write
FUseInvertedFont default false;
end;
procedure Register;
implementation
{
******************************* TdbpColorPikker ********************************
}
constructor TdbpColorPikker.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fCanvas := TCanvas.Create;
fCanvas.Handle := GetWindowDC(GetDesktopWindow);
fAbout := 'v1.3 par Julio P. (diabloporc)';
fEnabled := False;
fColor := clBlack;
fRValue := 0;
fGValue := 0;
fBValue := 0;
fHexa := 0;
fTimerInterval := 10;
fRGBString := 'RGB(0,0,0)';
fHexaString := '#000000';
fUseInvertedFont := false;
fFontColor := clBlack;
fTimer := TTimer.Create(self);
fTimer.Enabled := fEnabled;
fTimer.Interval := fTimerInterval;
fTimer.OnTimer := ActTimer;
end;
destructor TdbpColorPikker.Destroy;
begin
fTimer.free;
fCanvas.Free;
inherited destroy;
end;
procedure TdbpColorPikker.ActTimer(Sender: TObject);
begin
if (csDesigning in ComponentState) then
exit;
fColor := fCanvas.Pixels[Mouse.CursorPos.X, Mouse.CursorPos.Y];
fColorInverted := $00FFFFFF - fColor;
fRValue := GetRValue(fColor);
fGValue := GetGValue(fColor);
fBValue := GetBValue(fColor);
fHexa := StrToInt(format('$%s%s%s', [IntToHex(GetRValue(fColor), 2),
IntToHex(GetGValue(fColor), 2), IntToHex(GetBValue(fColor), 2)]));
fRGBString := format('RGB(%d,%d,%d)', [fRValue, fGValue, FBValue]);
{fHExaString := format('#%s%s%s', [IntToHex(GetRValue(fColor), 2),
IntToHex(GetGValue(fColor), 2), IntToHex(GetBValue(fColor), 2)]);}
FHexaString := Format('#%.2x%.2x%.2x', [FRValue, FGValue, FBValue]);
if assigned(FShape) then
FShape.Brush.Color := fColor;
if FUseInvertedFont then
begin
if Assigned(FLabelRGB) then
fLabelRgb.Font.Color := fColorInverted;
if Assigned(FLabelHexa) then
FLabelHexa.Font.Color := FColorInverted;
end
else
begin
if Assigned(FLabelRgb) then
FLabelRGB.Font.Color := fFontColor;
if Assigned(FLabelHexa) then
FLabelHexa.Font.Color := FFontColor;
end;
if assigned(fLabelRGB) then
fLabelRGB.caption := fRGBString;
if assigned(fLabelHexa) then
fLabelHexa.caption := fHexaString;
if Assigned(FTimerEvent) then
FTimerEvent(Self);
end;
procedure TdbpColorPikker.Notification(AComponent: TComponent; Operation:
TOperation);
begin
if Operation = opRemove then
begin
if aComponent = FShape then
FShape := nil;
if aComponent = fLabelRGB then
fLabelRGB := nil;
if aComponent = fLabelHexa then
fLabelHexa := nil;
end;
end;
procedure TdbpColorPikker.SetAbout(const s: string);
begin
//
end;
procedure TdbpColorPikker.SetEnabled(Value: Boolean);
begin
if Value = fEnabled then
exit;
fEnabled := value;
fTimer.Enabled := Value;
end;
procedure TdbpColorPikker.SetInterval(Value: TdbpInterval);
begin
fTimer.interval := value;
fTimerInterval := Value;
end;
procedure Register;
begin
RegisterComponents('Diabloporc', [TdbpColorPikker]);
end;
end.
Conclusion
description du screen : - 1 TShape aux coins arrondis - 2 TLabel - 1 TdbpColorPikker (le reste c du vent pour faire mignon : 1 TImage, 2 TBevel, et 2 label)
le shape, et les label changent de couleur et de caption grace au compo, le projet contient 0 ligne de code dans unit1.pas :)
bugs ? ameliorations ? MP ou mail !
http://diabloporc.free.fr
Historique
- 31 décembre 2004 17:56:33 :
- c'est un composant non visible !!
- 02 janvier 2005 01:08:48 :
- correction de delphiprog mises a jour, merci a toi :)
- 02 janvier 2005 01:23:10 :
- :)
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Couleur RGB 24bits vers RGB 16bits [ par balgrim ]
Vonjour, j'aimerais savoir si il existe une procedure pour convertir les couleur 24bits en couleur 16bits... merci :)
De l'aide !!!! svp !!!! [ par zywx ]
Voila c'est à cause de mon moteur physik !!! J'aarive pas à obtenir la couleur d'un pixel d'un Trect !!
couleur pixel à partir d'un jpeg [ par kacola ]
Bonjour, est-il possible de récupérer la couleur du pixel de coordonnées (X;Y) d'une image jpeg?Merci.
Couleur Hexa [ par lan0sic ]
Savez vous comment convertir une variable Tcolor en couleur hexa html?Merci ;)Lanosic
couleur d'un pixel d'une video webcam [ par serbon ]
BonjourJe suis en train de faire un orgue lazer: le principe est simple, des lazer tombes du plafond, et se réfléchissent vers un écran, lequel est fi
Couleur Pixel écran [ par cedricbi ]
Bonjour,Je cherche une fonction permettant de récuperer la couleur d'un pixel de l'écran. Il y a la fonction GetPixel mais, elle est trop lente pour c
RGB To Color?? [ par TIPECie ]
Bonjour à tous,Je cherche depuis quelque temps à changer la couleur d'un pixel par une couleur dont je connais le code RGB.J'ai essayé plusieurs trucs
DBListBox Couleur [ par lessin0 ]
salut a tousj'ai posé un DBListBox sur ma fiche , et je voudrai que l'utilisateur l'utilise pour sélectionné une couleur , qui lui permetra de défini
Changement de couleur dynamique dans un Composant [ par mikevkb ]
Bonjour, je dois créer un composant sous delphi, donc j'avais pensé créer une EditBox "Customisé", mais j'ai un petit souci:J'aimerais changer la coul
Recuperer le text d'un RichEdit via SendMessage avec la couleur et la font [ par L_art_ment ]
Bien le bonsoir ,Voili voilou mon petit soucis, j'essaie de récupérer le text d'un richedit d'une autre application grâce aux fonctions sendmessage, a
|
Derniers Blogs
[MIX10] KEYNOTE DEUXIèME JOURNéE - INTERNET EXPLORER 9, HTML5, VISUAL STUDIO 2010, ODATA[MIX10] KEYNOTE DEUXIèME JOURNéE - INTERNET EXPLORER 9, HTML5, VISUAL STUDIO 2010, ODATA par cyril
Le deuxième keynote du mix fut très riche en contenu. Internet Explorer 9 Juste un après le lancement de Internet Explorer 8, Microsoft a dévoilé les nouveautés de Internet Explorer 9. Désormais, IE supportera HTML5, SVG et CSS3. L'élément ...
Cliquez pour lire la suite de l'article par cyril CERTIFICATIONS BETA .NET 4CERTIFICATIONS BETA .NET 4 par KooKiz
Les inscriptions pour les certifications beta .NET 4 ont commencé. L'inscription est offerte pour les examens suivants : - 71-511, TS: Windows Applications Development with Microsoft .NET Framework 4 - 71-515, TS: Web Applications Development with...
Cliquez pour lire la suite de l'article par KooKiz [MIX 2010] - MICROSOFT TRANSLATOR TECHNOLOGY PREVIEW V2[MIX 2010] - MICROSOFT TRANSLATOR TECHNOLOGY PREVIEW V2 par redo
J'imagine que la plupart d'entre vous connaissent bien et utilisent le service de traduction de Google, mais connaissez-vous celui de Microsoft . Microsoft Translator ? Effectivement, Microsoft nous annoncé le lancement version 2 de la Technologie Preview...
Cliquez pour lire la suite de l'article par redo LANCEMENT EN PREVIEW DE CYCLONE LORS DES TECHDAYS 2010!LANCEMENT EN PREVIEW DE CYCLONE LORS DES TECHDAYS 2010! par MPOWARE
Toutes les vidéos de ce lancement sont en ligne!
Partie I - Intro
http://www.youtube.com/watch?v=LkQzTQ8T6CA
Partie II - Démo 1
http://www.youtube.com/watch?v=drAhYQ7lqvo
Partie III - Démo 2
http://www.youtube.com/watch?v=c8KM_1Gqybc...
Cliquez pour lire la suite de l'article par MPOWARE [WP7] JE NE VEUX PAS D'UN NOUVEL IPHONE[WP7] JE NE VEUX PAS D'UN NOUVEL IPHONE par FREMYCOMPANY
Je pense qu'ils ont besoin d'une piqure de rappel chez Microsoft : c'est bien gentil d'avoir une interface jolie, mais si c'est pour avoir un truc qui ne convainct pas dedans, c'est peine perdue.
---->
Système ouvert ----> Fermé ?
P...
Cliquez pour lire la suite de l'article par FREMYCOMPANY
Logiciels
Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods Konvertor (4.00)KONVERTOR (4.00)Le logiciel est un gestionnaire multimedia affichant, jouant et convertissant plus de 2000 format... Cliquez pour télécharger Konvertor
|