|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
COMPOSANT : TDBPDEFAULTBUTTON
Information sur la source
Description
Hello, ceci est mon 17eme compsoant realisé sous delphi7. NONONON ce n'est pas 'encore' un bouton de plus :D il s'agit d'un composant invisible qui sera utilisé sur un TButton, TBitBtn ou encore un TSpeedButton. Grace au "Delay" et au "CaptionSuffix" vous pourrez determiner votre bouton comme bouton par defaut, c a dire ke à la fin du délai, le compo clikera automatikement sur le bouton a la place de la personne. De plus le caption est modifié chaque seconde. ex : caption du bouton : "Quitter le programme" CaptionSuffix du composant : " = " Délai : 5 le bouton (apres avoir fait Enabled := true sur le compo) sera : "Quitter le programme = 5" puis "Quitter le programme = 4" puis "Quitter le programme = 3" puis "Quitter le programme = 2" puis "Quitter le programme = 1" puis "Quitter le programme = 0" puis le programme quiterra :D (si telle est l'action sur le bouton) Le compte a rebours est annulable en faisant enabled := false; Bon assez parlé, prenez le zip, lancez la démo.exe ;D
Source
- {
- ################################################################################
- # DBPDEFAULTBUTTON #
- ################################################################################
- # #
- # VERSION : 1.1 #
- # FICHIERS : dbpDefaultButton.pas,.dcu,.dcr,.bmp,ReadMe.htm #
- # AUTEUR : Julio P. (Diabloporc) #
- # CREATION : 13 dec 2004 #
- # MODIFIEE : 14 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 dbpDefaultButton;
-
- interface
-
- uses
- buttons, stdCtrls, SysUtils, Classes, ExtCtrls, controls, forms;
-
- type
- TdbpDelay = 1..3600;
- TdbpDefaultButton = class(TComponent)
- private
- fDelay: TdbpDelay;
- fAbout,fCaptionSuffix, fCaption: string;
- fTButton: TButton;
- fTSpeedButton: TSpeedButton;
- fEnable, fActive: boolean;
- fTimer: TTimer;
- fTimeDelay: word;
-
- procedure SetAbout(v: string);
- procedure SetFButton(compo: TButton);
- procedure SetFSpeedButton(compo: TSpeedButton);
- procedure SetEnable(Value: boolean);
- procedure SetDelay(Value: TdbpDelay);
- procedure SetCaptionSuffix(value: string);
- procedure ProcOnTimer(Sender: TObject);
- protected
- { Protected declarations }
- public
- constructor Create(AOwner: TComponent); override;
- Destructor Destroy; override;
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- published
- property About: string read fAbout write SetAbout;
- property Enabled: boolean read fEnable write SetEnable default false;
- property TButton: Tbutton read fTButton write SetFButton;
- property TButtonActive: boolean read fActive write fActive default true;
- property TSpeedButton: TSpeedbutton read fTSpeedButton write SetFSpeedButton;
- property Delay: TdbpDelay read fDelay write SetDelay default 5;
- property CaptionSuffix: string read fCaptionSuffix write SetCaptionSuffix;
- end;
-
- procedure Register;
-
- implementation
-
- {$R *.dcr}
-
- procedure TdbpDefaultButton.SetAbout(v: string);
- begin
- //
- end;
-
- procedure TdbpDefaultButton.Notification(AComponent: TComponent; Operation: TOperation);
- begin
- if (aComponent = fTButton) and (Operation = opRemove) then fTButton := nil;
- if (aComponent = fTSpeedButton) and (Operation = opRemove) then fTSpeedButton := nil;
- end;
-
- procedure TdbpDefaultButton.SetDelay(Value: TdbpDelay);
- begin
- if (fenable) or (Value=fDelay) then exit;
- fTimeDelay := Value;
- fDelay := Value;
- end;
-
- procedure TdbpDefaultButton.SetCaptionSuffix(Value: string);
- begin
- if (fEnable) or (Value=fCaptionSuffix) then exit;
- fCaptionSuffix := Value;
- end;
-
- procedure TdbpDefaultButton.SetFButton(compo: TButton);
- begin
- if fenable then exit;
- if fTButton<>compo then fTButton := Compo;
- fTSpeedButton := nil;
- end;
-
- procedure TdbpDefaultButton.SetFSpeedButton(compo: TSpeedButton);
- begin
- if fenable then exit;
- if fTSpeedButton<>compo then fTSpeedButton := Compo;
- fTButton := nil;
- end;
-
- procedure TdbpDefaultButton.SetEnable(Value: boolean);
- begin
- if (csDesigning in ComponentState) or (fEnable=Value) or ((not Assigned(fTButton)) and (not Assigned(fTSpeedButton))) then exit;
- fEnable := Value;
- fTimer.Enabled := value;
- if (assigned(TButton)) and fActive and fEnable then TButton.SetFocus;
- if not fEnable then fTimeDelay := fDelay;
- if Assigned(fTButton) then
- begin
- if fEnable then
- begin
- fCaption := fTButton.Caption;
- fTButton.Caption := Format('%s%s%d',[fCaption,fCaptionSuffix,fTimeDelay]);
- end
- else
- begin
- fTButton.Caption := fCaption;
- end;
- end
- else
- begin
- if fEnable then
- begin
- fCaption := fTSpeedButton.Caption;
- fTSpeedButton.Caption := Format('%s%s%d',[fCaption,fCaptionSuffix,fTimeDelay]);
- end
- else
- begin
- fTSpeedButton.Caption := fCaption;
- end;
- end;
- end;
-
- constructor TdbpDefaultButton.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- FAbout := 'v1.0 par Julio P. (Diabloporc)';
- fDelay := 5;
- fActive := true;
- fEnable := false;
- fTimeDelay := 5;
- fTimer := TTimer.Create(self);
- fTimer.Enabled := false;
- fTimer.Interval := 999;
- fTimer.OnTimer := ProcOnTimer;
- fCaption := '';
- end;
-
- destructor TdbpDefaultButton.destroy;
- begin
- inherited destroy;
- fTimer.Enabled := false;
- fTimer := nil;
- end;
-
- procedure TdbpDefaultButton.ProcOnTimer(Sender: TObject);
- begin
- if (csDesigning in ComponentState) then exit;
- dec(fTimeDelay);
- if assigned(fTButton) then
- begin
- fTButton.caption := format('%s%s%d',[fCaption,fCaptionSuffix,fTimeDelay]);
- sleep(1);
- if (fTimeDelay=0) then
- begin
- SetEnable(false);
- fTButton.click;
- end;
- end
- else
- if assigned(fTSpeedButton) then
- begin
- fTSpeedButton.caption := format('%s%s%d',[fCaption,fCaptionSuffix,fTimeDelay]);
- sleep(1);
- if (fTimeDelay=0) then
- begin
- SetEnable(false);
- fTSpeedButton.Click;
- end;
- end;
- end;
-
- procedure Register;
- begin
- RegisterComponents('Diabloporc', [TdbpDefaultButton]);
- end;
-
- end.
{
################################################################################
# DBPDEFAULTBUTTON #
################################################################################
# #
# VERSION : 1.1 #
# FICHIERS : dbpDefaultButton.pas,.dcu,.dcr,.bmp,ReadMe.htm #
# AUTEUR : Julio P. (Diabloporc) #
# CREATION : 13 dec 2004 #
# MODIFIEE : 14 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 dbpDefaultButton;
interface
uses
buttons, stdCtrls, SysUtils, Classes, ExtCtrls, controls, forms;
type
TdbpDelay = 1..3600;
TdbpDefaultButton = class(TComponent)
private
fDelay: TdbpDelay;
fAbout,fCaptionSuffix, fCaption: string;
fTButton: TButton;
fTSpeedButton: TSpeedButton;
fEnable, fActive: boolean;
fTimer: TTimer;
fTimeDelay: word;
procedure SetAbout(v: string);
procedure SetFButton(compo: TButton);
procedure SetFSpeedButton(compo: TSpeedButton);
procedure SetEnable(Value: boolean);
procedure SetDelay(Value: TdbpDelay);
procedure SetCaptionSuffix(value: string);
procedure ProcOnTimer(Sender: TObject);
protected
{ Protected declarations }
public
constructor Create(AOwner: TComponent); override;
Destructor Destroy; override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
published
property About: string read fAbout write SetAbout;
property Enabled: boolean read fEnable write SetEnable default false;
property TButton: Tbutton read fTButton write SetFButton;
property TButtonActive: boolean read fActive write fActive default true;
property TSpeedButton: TSpeedbutton read fTSpeedButton write SetFSpeedButton;
property Delay: TdbpDelay read fDelay write SetDelay default 5;
property CaptionSuffix: string read fCaptionSuffix write SetCaptionSuffix;
end;
procedure Register;
implementation
{$R *.dcr}
procedure TdbpDefaultButton.SetAbout(v: string);
begin
//
end;
procedure TdbpDefaultButton.Notification(AComponent: TComponent; Operation: TOperation);
begin
if (aComponent = fTButton) and (Operation = opRemove) then fTButton := nil;
if (aComponent = fTSpeedButton) and (Operation = opRemove) then fTSpeedButton := nil;
end;
procedure TdbpDefaultButton.SetDelay(Value: TdbpDelay);
begin
if (fenable) or (Value=fDelay) then exit;
fTimeDelay := Value;
fDelay := Value;
end;
procedure TdbpDefaultButton.SetCaptionSuffix(Value: string);
begin
if (fEnable) or (Value=fCaptionSuffix) then exit;
fCaptionSuffix := Value;
end;
procedure TdbpDefaultButton.SetFButton(compo: TButton);
begin
if fenable then exit;
if fTButton<>compo then fTButton := Compo;
fTSpeedButton := nil;
end;
procedure TdbpDefaultButton.SetFSpeedButton(compo: TSpeedButton);
begin
if fenable then exit;
if fTSpeedButton<>compo then fTSpeedButton := Compo;
fTButton := nil;
end;
procedure TdbpDefaultButton.SetEnable(Value: boolean);
begin
if (csDesigning in ComponentState) or (fEnable=Value) or ((not Assigned(fTButton)) and (not Assigned(fTSpeedButton))) then exit;
fEnable := Value;
fTimer.Enabled := value;
if (assigned(TButton)) and fActive and fEnable then TButton.SetFocus;
if not fEnable then fTimeDelay := fDelay;
if Assigned(fTButton) then
begin
if fEnable then
begin
fCaption := fTButton.Caption;
fTButton.Caption := Format('%s%s%d',[fCaption,fCaptionSuffix,fTimeDelay]);
end
else
begin
fTButton.Caption := fCaption;
end;
end
else
begin
if fEnable then
begin
fCaption := fTSpeedButton.Caption;
fTSpeedButton.Caption := Format('%s%s%d',[fCaption,fCaptionSuffix,fTimeDelay]);
end
else
begin
fTSpeedButton.Caption := fCaption;
end;
end;
end;
constructor TdbpDefaultButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FAbout := 'v1.0 par Julio P. (Diabloporc)';
fDelay := 5;
fActive := true;
fEnable := false;
fTimeDelay := 5;
fTimer := TTimer.Create(self);
fTimer.Enabled := false;
fTimer.Interval := 999;
fTimer.OnTimer := ProcOnTimer;
fCaption := '';
end;
destructor TdbpDefaultButton.destroy;
begin
inherited destroy;
fTimer.Enabled := false;
fTimer := nil;
end;
procedure TdbpDefaultButton.ProcOnTimer(Sender: TObject);
begin
if (csDesigning in ComponentState) then exit;
dec(fTimeDelay);
if assigned(fTButton) then
begin
fTButton.caption := format('%s%s%d',[fCaption,fCaptionSuffix,fTimeDelay]);
sleep(1);
if (fTimeDelay=0) then
begin
SetEnable(false);
fTButton.click;
end;
end
else
if assigned(fTSpeedButton) then
begin
fTSpeedButton.caption := format('%s%s%d',[fCaption,fCaptionSuffix,fTimeDelay]);
sleep(1);
if (fTimeDelay=0) then
begin
SetEnable(false);
fTSpeedButton.Click;
end;
end;
end;
procedure Register;
begin
RegisterComponents('Diabloporc', [TdbpDefaultButton]);
end;
end.
Conclusion
bug ou ameliorations ? MP ou mail !
Fichier Zip
Pour les "Membres Club", vous pouvez télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !
Télécharger le zip
Historique
- 14 décembre 2004 00:28:46 :
- euh rien :D
- 14 décembre 2004 21:17:55 :
- ajout d'une propriété TbuttonActive qui permet de donner le focus au Tbutton, TBitbtn choisi au moment du Enabled := true;
Sources du même auteur
Sources de la même categorie
Sources en rapport avec celle ci
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Probleme p-ê ben stupide mais ... [ par stage ]
Bon ok j'explique ( sa risque d'être difficile lol ):PJe me suis créer un composant de type TPanel et il ce nomme Tmp.ce compsant fait des petits bout
Clignotement bouton [ par oullafff ]
Bonjour TLM,J'ai télécharger un composant du nom de TIAeverButton, celui-ci est très bien... mais j'aimerais enlever le clignotement du bouton lorsque
Créer un composant bouton [ par ludm ]
Bonjour,J'ai créé un bouton avec un label fond transparent au dessus de 2 images, lorsque la souris est enfoncée, je cache l'image 1 et lorsque la sou
CLIC automatique,comment faire? [ par NOTAFAIL ]
Bonjour,Voilà ma question et mon problème.Ma copine est sur un site où elle a une fiche !Les internautes peuvent noter cette ficheEt il
Cliquer sur un bouton dont le nom est dans un variable [ par azertyloris ]
Bonjour, Tout est dans le titre, en fait je souhaiterai cliquer sur un combobox donc le nom est Combo+VARIABLE mais la fontion Combo+variable.Click;
Apres clic sur un bouton, metrte le programme en barre des taches et faire apparaitre un message. [ par Yil2201 ]
Salut, tout d'abord, merci.Je cherche à savoir comment, apres clic sur un bouton que l'on va appeler Button1, le programme pourrrait se mettre da
changer le text a chaque clic [ par hitman94440 ]
Bonjour a tous.... Je suis nouveau donc je suis le nul des nuls. Voila je veux faire sa: j'ai une texte1 et un bouton puis moi je veux que chaque fois
simuler un clic bouton [ par RV07 ]
bonjour à tous et très bonne année 2007 j'aimerai simuler le clic d'un bouton de mon appli. pour cela je pense qu'il faut utiliser sendmessage ou post
Créer un ini qui s'autosauvegardera après clic sur bouton [ par Yil2201 ]
Salut! J'aurais voulu savoir comment faire pour rajouter un fihcier ini a l'application qui s'autosauvegarderait a la fermeture de la Form2 par exempl
Bouton et incrémentation [ par patou248 ]
Salut à tous,Est-ce possible d'avoir un bout de code qui montre qu'en cliquant un Bouton une valeur incrémentée de 1 s'affiche dans un TEdit.Ainsi au
|
Téléchargements
Logiciels à télécharger sur le même thème :
|