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
[SHAREPOINT] LES SESSIONS TECHDAYS 2012.[SHAREPOINT] LES SESSIONS TECHDAYS 2012. par Patrick Guimonet
Voici donc pour ceux qui n'ont pas pu venir, ou ceux qui n'ont pas pu toutes les suivre la liste des sessions SharePoint aux TechDays 2012, que je mettrais à jour dès que les liens des vidéo seront disponibles. Ou ici : http...
Cliquez pour lire la suite de l'article par Patrick Guimonet TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE !MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE ! par Vko
Hier durant une session dédiée aux Techdays 2012, j'ai eu le plaisir d'annoncer la sortie de la Béta 2 de Mishra Reader. C'est quoi ? Pour les utilisateurs, c'est une vraie expérience de lecture de flux RSS sur Windows. Rien à voir avec les produit...
Cliquez pour lire la suite de l'article par Vko [FRAMEWORK 4] LES TASKS ET LE THREAD UI[FRAMEWORK 4] LES TASKS ET LE THREAD UI par fathi
Je viens de passer quelques temps au TechDay's et j'ai pu voir pas mal de session intéressante. Par contre une chose m'a un peu étonné lors de certaines de ces sessions qui abordaient les améliorations du framework .NET (donc le 4.5) : en gros, bea...
Cliquez pour lire la suite de l'article par fathi WORKFLOW FOUNDATION 3 A UN PIED DANS LA TOMBEWORKFLOW FOUNDATION 3 A UN PIED DANS LA TOMBE par JeremyJeanson
Depuis déjà un an, je conseille vivement les utilisateurs de Workflow Foundation 3 à migrer vers la version 4. L'information qui va suivre ne devrait donc pas trop prendre au dépourvu les personnes qui m'ont suivi. Je profite de ce poste, pour faire le re...
Cliquez pour lire la suite de l'article par JeremyJeanson
Logiciels
Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|