1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
Type
//Enumération qui permet de prévoir si il y aura 1, 2 ou 3 bouttons dans la messagebox le choix Mb_OK ou autre est totalement arbitraire
enumTypeHackBox=
(
Ok=MB_OK,
Oui_Non=MB_YESNO,
Oui_Non_Annuler=MB_YESNOCANCEL,
Erreur= - 1
);
// Erreur sera pour tout les box qui ne sont pas lancer par mes soins (error)
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Déclarations privées }
procedure WMHackBox(var message: TMessage); message WM_USER + 600;
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
CaptionHackbox, MessageHackBox: String;
HackboxCaptionBtn1,HackboxCaptionBtn2,HackboxCaptionBtn3: String;
TypeHackBox: enumTypeHackBox;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Var
TL : TstringList;
begin
PostMessage(Handle, WM_USER + 600, 0, 0);
TL.Add('ff'); // sa va faire mal...
end;
procedure TForm1.WMHackBox(var message: TMessage);
var
h: HWND;
begin
// La Boite de dialogue est show on récupèere son Handle
h := FindWindow(WC_DIALOG,nil); // nil sera plus approprié on aura toute les messages box
// Si la fenêtre est la Message Box on la modifie (on pourrais faire plus simple mas bon.... je sjuis fainéant sur le coup là.... lol
if (TypeHackBox <> Ok) or (TypeHackBox <> Oui_Non) or (TypeHackBox <> Oui_Non_Annuler) then TypeHackBox := Erreur;
if (GetParent(h) = Handle) then
begin
Case TypeHackBox of
Erreur:
Begin
// Cas des messages box hors contexte de programmation
SetDlgItemText(h, ID_CANCEL, 'ok_Ko'); // On change le text bouton
End;
Ok:SetDlgItemText(h, ID_OK, PWideChar(HackboxCaptionBtn1)); // On change le text bouton
Oui_Non:
Begin
SetDlgItemText(h, ID_YES, PWideChar(HackboxCaptionBtn1)); // On change le text premier bouton
SetDlgItemText(h, ID_NO, PWidechar(HackboxCaptionBtn2)); // On change le text deuxième bouton
end;
Oui_Non_Annuler:
Begin
SetDlgItemText(h, ID_YES, PWideChar(HackboxCaptionBtn1)); // On change le text premier bouton
SetDlgItemText(h, ID_NO, PWidechar(HackboxCaptionBtn2)); // On change le text deuxième bouton
SetDlgItemText(h, ID_CANCEL, PWideChar(HackboxCaptionBtn3)); // On change le text troisieme bouton
end;
end;
end;
end;
end. |
Partager