Accueil > > > COMPOSANT : TDBPDEFAULTBUTTON
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 !
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
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
|
Derniers Blogs
[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES par gpommier
Suite à la session que j'ai présenté sur WebMatrix 2, vous pouvez trouver les slides ici, ainsi que les démos en packages nuget : démos1 et démos2 J'en profite pour remercier chaleureusement tous ceux qui sont venus très nombreux à cette sess...
Cliquez pour lire la suite de l'article par gpommier [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
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
|