ReplaceQuerry.pas 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. unit ReplaceQuerry;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5. Dialogs, StdCtrls, ExtCtrls;
  6. type
  7. TfrmReplaceQuerry = class(TForm)
  8. lblConfirmation: TLabel;
  9. imgIcon: TImage;
  10. btnReplace: TButton;
  11. btnSkip: TButton;
  12. btnCancel: TButton;
  13. btnReplaceAll: TButton;
  14. private
  15. { Private declarations }
  16. public
  17. { Public declarations }
  18. procedure Prepare(EditorRect: TRect; X, Y1, Y2: Integer; sReplaceText: string);
  19. end;
  20. var
  21. frmReplaceQuerry: TfrmReplaceQuerry;
  22. const
  23. sAskReplaceText = 'Replace this occurence of "%s"?';
  24. implementation
  25. {$R *.dfm}
  26. procedure TfrmReplaceQuerry.Prepare(EditorRect: TRect; X, Y1, Y2: Integer; sReplaceText: string);
  27. var
  28. nW, nH: integer;
  29. begin
  30. imgIcon.Picture.Icon.Handle := LoadIcon(0, IDI_QUESTION);
  31. lblConfirmation.Caption := Format(SAskReplaceText, [sReplaceText]);
  32. nW := EditorRect.Right - EditorRect.Left;
  33. nH := EditorRect.Bottom - EditorRect.Top;
  34. if nW <= Width then
  35. X := EditorRect.Left - (Width - nW) div 2
  36. else
  37. begin
  38. if X + Width > EditorRect.Right then
  39. X := EditorRect.Right - Width;
  40. end;
  41. if Y2 > EditorRect.Top + MulDiv(nH, 2, 3) then
  42. Y2 := Y1 - Height - 4
  43. else
  44. Inc(Y2, 4);
  45. SetBounds(X, Y2, Width, Height);
  46. end;
  47. end.