if FormStyle = fsMDIChild then WindowClass.lpfnWndProc := @DefMDIChildProc;Donc à part intercepter traiter les messages qui t'intéresse et renvoyer les autres à la fonction initiale ... ça ne fonctionnera pas ... et du coup je suis pas certain que le code que je cite plus haut fonctionne ... il faudrait tester
{ eoAllowEdit : permet d'activer ou non la saisie au clavier eoAllowContextMenu : permet d'activer ou non le menu contextuel par defaut eoAllowCopy : permet d'activer ou non le raccourcis CTRL+C (copier) eoAllowPaste: permet d'activer ou non le raccourcis CTRL+V (coller) eoAllowCut : permet d'activer ou non le raccourcis CTRL+X (couper) eoAllowUndo: permet d'activer ou non le raccourcis CTRL+Z (annuler) eoAllowEditClpBrd: permet "d'éditer" le contenu du ClipBoard eoAllowGetText: permet d'activer ou non la copie de Texte par message depuis une autre Application eoAllowSetText: permet d'activer ou non le Collage de Texte par message depuis une autre Application }
EditOptions := [eoAllowEdit, eoAllowContextMenu, eoAllowCopy, eoAllowPaste, eoAllowCut, eoAllowUndo, eoAllowGetText, eoAllowSetText];
Edit1.EditOptions := [eoAllowEdit];
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionunit Ext_LabeledEdit; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, stdctrls, ExtCtrls; type { TEdit overclass ---------------------------- } TEditOption = (eoAllowEdit, eoAllowContextMenu, eoAllowCopy, eoAllowPaste, eoAllowCut, eoAllowUndo); { eoAllowEdit : permet d'activer ou non la saisie au clavier eoAllowContextMenu : permet d'activer ou non le menu contextuel par defaut eoAllowCopy : permet d'activer ou non le raccourcis CTRL+C (copier) eoAllowPaste: permet d'activer ou non le raccourcis CTRL+V (coller) eoAllowCut : permet d'activer ou non le raccourcis CTRL+X (couper) eoAllowUndo: permet d'activer ou non le raccourcis CTRL+Z (annuler) } TEditOptions = set of TEditOption; TExt_LabeledEdit = class(TLabeledEdit) private { Private declarations } FNombre_de_Decimal : Integer; FEditOptions : TEditOptions; FOnlyNumeric : Boolean; procedure WMChar(var Message: TWMChar); message WM_CHAR; procedure WMContextMenu(var Message: TWMContextMenu); message WM_CONTEXTMENU; procedure WMPaste(var Message); message WM_PASTE; procedure WMCopy(var Message); message WM_COPY; procedure WMCut(var Message); message WM_CUT; procedure WMUndo(var Message); message WM_UNDO; public { Public declarations } constructor Create(AOwner : TComponent); override; published { Déclarations publiées } //ajout de la propriété property Only_Numeric : Boolean read FOnlyNumeric write FOnlyNumeric Default False; //ajout de la propriété Nombre_de_Decimal property Nombre_de_Decimal : Integer read FNombre_de_Decimal write FNombre_de_Decimal default 2; Property EditOptions : TEditOptions Read FEditOptions Write FEditOptions default [eoAllowEdit, eoAllowContextMenu, eoAllowCopy, eoAllowPaste, eoAllowCut, eoAllowUndo]; end; { --------------------------------- } procedure Register; implementation procedure Register; begin RegisterComponents('MesComposants', [TExt_LabeledEdit]); end; constructor TExt_LabeledEdit.Create(AOwner: TComponent); begin inherited; FEditOptions := [eoAllowEdit, eoAllowContextMenu, eoAllowCopy, eoAllowPaste, eoAllowCut, eoAllowUndo]; end; procedure TExt_LabeledEdit.WMChar(var Message: TWMChar); begin if eoAllowEdit in FEditOptions Then Inherited; end; procedure TExt_LabeledEdit.WMContextMenu(var Message: TWMContextMenu); begin if eoAllowContextMenu in FEditOptions Then Inherited; end; procedure TExt_LabeledEdit.WMCopy(var Message); begin if eoAllowCopy in FEditOptions Then Inherited; end; procedure TExt_LabeledEdit.WMPaste(var Message); begin if eoAllowPaste in FEditOptions Then Inherited; end; procedure TExt_LabeledEdit.WMCut(var Message); begin if eoAllowCut in FEditOptions Then Inherited; end; procedure TExt_LabeledEdit.WMUndo(var Message); begin if eoAllowUndo in FEditOptions Then Inherited; end; end.
property Nombre_de_Decimal : Integer read FNombre_de_Decimal write FNombre_de_Decimal default 2;
Procedure Edit_With_Float1(Edit: TExt_LabeledEdit; Nombre_de_Decimal : Integer; var Key: Char); begin if not (Key in '0'..'9', DecimalSeparator) then Key := #0 else begin //si le point est deja present et qu'on appuie encore sur le point alors on ne fait rien if (Key = DecimalSeparator) and (Pos(Key, Edit.Text) > 0) then Key := #0 else Key := Key; //si la touche est un chiffre alors if (Key in ['0'..'9']) then begin //si le point n'est pas encore entre alors la touche est acceptee if pos(DecimalSeparator,Edit.Text)=0 then Key := Key; //si le point est deja present alors if (pos(DecimalSeparator,Edit.Text)>0) then begin //on verifie la position du curseur //si le curseur est avant le '.' alors on accepte le chiffre if (Edit.SelStart < pos(DecimalSeparator,Edit.Text)) then Key := Key else //sinon on verifie le nombre de decimal if length(Edit.Text)-(Nombre_de_Decimal-1) > pos(DecimalSeparator,Edit.Text) then Key := #0 else Key := Key; end; end; if (Key = #8) then Key := #8; end; end;
protected procedure CreateParams(var Params: TCreateParams); override;