-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathudConfirmReplace.pas
61 lines (50 loc) · 1.93 KB
/
udConfirmReplace.pas
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
{****************************************************************
$Id: udConfirmReplace.pas,v 1.2 2006-11-30 10:30:41 dale Exp $
****************************************************************}
unit udConfirmReplace;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
type
TdConfirmReplace = class(TForm)
btnCancel: TButton;
btnReplace: TButton;
btnReplaceAll: TButton;
btnSkip: TButton;
iIcon: TImage;
lMain: TLabel;
protected
procedure DoDestroy; override;
end;
function AskConfirmReplace(AEditorRect: TRect; X, Y1, Y2: Integer; const AReplaceText: String): Integer;
implementation
{$R *.DFM}
var
dConfirmReplace: TdConfirmReplace = nil;
function AskConfirmReplace(AEditorRect: TRect; X, Y1, Y2: Integer; const AReplaceText: String): Integer;
var iW, iH: integer;
begin
if dConfirmReplace=nil then begin
dConfirmReplace := TdConfirmReplace.Create(Application);
dConfirmReplace.iIcon.Picture.Icon.Handle := LoadIcon(0, IDI_QUESTION);
end;
with dConfirmReplace do begin
lMain.Caption := Format('Replace this occurence of "%s"?', [AReplaceText]);
iW := AEditorRect.Right-AEditorRect.Left;
iH := AEditorRect.Bottom-AEditorRect.Top;
if iW <= Width then X := AEditorRect.Left - (Width-iW) div 2
else if X+Width>AEditorRect.Right then X := AEditorRect.Right-Width;
if Y2>AEditorRect.Top+MulDiv(iH, 2, 3) then Y2 := Y1-Height-4 else Inc(Y2, 4);
SetBounds(X, Y2, Width, Height);
Result := ShowModal;
end;
end;
//===================================================================================================================
// TdConfirmReplace
//===================================================================================================================
procedure TdConfirmReplace.DoDestroy;
begin
dConfirmReplace := nil;
inherited DoDestroy;
end;
end.