-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainDialogs.pas
119 lines (107 loc) · 5.87 KB
/
MainDialogs.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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
{
Project: FindDupFar http://code.google.com/p/findupfar/
Author: Alexey Suhinin http://x-alexey.narod.ru
License: GPL v.2
}
unit MainDialogs;
Interface
{$I PRJDefines.inc}
uses
Windows,
PluginLng,
FarApi,
Plugin;
type
// TInitDialogItemArray = array of TInitDialogItem;
TFARDialog = class
private
class function ClassDlgProc(hDlg: THandle; Msg: integer; Param1: integer; Param2: integer): integer; stdcall; static;
function DlgProc(hDlg: THandle; Msg: integer; Param1: integer; Param2: integer): integer; virtual; abstract;
end;
TMainDialog = class(TFARDialog)
private
function DlgProc(hDlg: THandle; Msg: integer; Param1: integer; Param2: integer): integer; override;
public
function Show: Integer;
end;
Implementation
type
TMainDialogItemID = (idFrame, idProcessText, idProcessFiles, idProcessDirs, idSeparator1, idAllDisks, idWithoutNetDisks,
idCurrentDisk, idCustom, idCurrentPanel, idAnotherPanel, idCustomList, idCustomListBtn, idSeparator2,
idOKBtn);
const
DialogWidth = 54;
DialogHeight = 15;
class function TFARDialog.ClassDlgProc(hDlg: THandle; Msg: integer; Param1: integer; Param2: integer): integer; stdcall; static;
var
vDialog :TFARDialog;
begin
if Msg = DN_INITDIALOG then
FARAPI.SendDlgMessage(hDlg, DM_SETDLGDATA, 0, Param2)
else
begin
vDialog := TFARDialog(FARAPI.SendDlgMessage(hDlg, DM_GETDLGDATA, 0, 0));
Result := vDialog.DlgProc(hDlg, Msg, Param1, Param2);
end;
end;
function TMainDialog.DlgProc(hDlg: THandle; Msg: integer; Param1: integer; Param2: integer): integer;
begin
Result:=DefDlgProc(hDlg, Msg, Param1, Param2);
case Msg of
DN_BTNCLICK:
case TMainDialogItemID(Param1) of
idCustom:
if SendDlgMessage(hDlg, DM_GETCHECK, Ord(idCustom), 0)=BSTATE_CHECKED then
begin
SendDlgMessage(hDlg, DM_ENABLE, Ord(idCurrentPanel), Integer(True));
SendDlgMessage(hDlg, DM_ENABLE, Ord(idAnotherPanel), Integer(True));
SendDlgMessage(hDlg, DM_ENABLE, Ord(idCustomList), Integer(True));
if SendDlgMessage(hDlg, DM_GETCHECK, Ord(idCustomList), 0)=BSTATE_CHECKED then
SendDlgMessage(hDlg, DM_ENABLE, Ord(idCustomListBtn), Integer(True));
end
else
begin
SendDlgMessage(hDlg, DM_ENABLE, Ord(idCurrentPanel), Integer(False));
SendDlgMessage(hDlg, DM_ENABLE, Ord(idAnotherPanel), Integer(False));
SendDlgMessage(hDlg, DM_ENABLE, Ord(idCustomList), Integer(False));
SendDlgMessage(hDlg, DM_ENABLE, Ord(idCustomListBtn), Integer(False));
end;
idCustomList:
if SendDlgMessage(hDlg, DM_GETCHECK, Ord(idCustomList), 0)=BSTATE_CHECKED then
SendDlgMessage(hDlg, DM_ENABLE, Ord(idCustomListBtn), Integer(True))
else
SendDlgMessage(hDlg, DM_ENABLE, Ord(idCustomListBtn), Integer(False));
end;
end;
end;
function TMainDialog.Show: Integer;
var
items: PFarDialogItemArray;
const
itemsnum=Ord(High(TMainDialogItemID))+1;
initarray: packed array [0..itemsnum-1] of TInitDialogItem = (
(ItemType:DI_DOUBLEBOX; X1: 3; Y1: 1; X2:DialogWidth-4; Y2:DialogHeight-2; Focus: 0; Selected: False; Flags:0; DefaultButton:False; Data: (MsgID: Cardinal(msgFind))),
(ItemType:DI_TEXT; X1: 5; Y1: 2; X2: 0; Y2: 0; Focus: 0; Selected: False; Flags:0; DefaultButton:False; Data: (MsgID: Cardinal(msgFindChoise))),
(ItemType:DI_RADIOBUTTON; X1: 15; Y1: 2; X2: 0; Y2: 0; Focus: 0; Selected: True; Flags:DIF_GROUP; DefaultButton:False; Data: (MsgID: Cardinal(msgFindFiles))),
(ItemType:DI_RADIOBUTTON; X1: 30; Y1: 2; X2: 0; Y2: 0; Focus: 0; Selected: False; Flags:0; DefaultButton:False; Data: (MsgID: Cardinal(msgFindDirs))),
(ItemType:DI_TEXT; X1: 0; Y1: 3; X2: 0; Y2: 0; Focus: 0; Selected: False; Flags:DIF_SEPARATOR; DefaultButton:False; Data: (Message: '')),
(ItemType:DI_RADIOBUTTON; X1: 5; Y1: 4; X2: 0; Y2: 0; Focus: 0; Selected: True; Flags:DIF_GROUP; DefaultButton:False; Data: (MsgID: Cardinal(msgFindAllDisks))),
(ItemType:DI_RADIOBUTTON; X1: 5; Y1: 5; X2: 0; Y2: 0; Focus: 0; Selected: False; Flags:0; DefaultButton:False; Data: (MsgID: Cardinal(msgFindAllDisksWithoutNet))),
(ItemType:DI_RADIOBUTTON; X1: 5; Y1: 6; X2: 0; Y2: 0; Focus: 0; Selected: False; Flags:0; DefaultButton:False; Data: (MsgID: Cardinal(msgFindCurrentDrive))),
(ItemType:DI_RADIOBUTTON; X1: 5; Y1: 7; X2: 0; Y2: 0; Focus: 0; Selected: False; Flags:0; DefaultButton:False; Data: (MsgID: Cardinal(msgFindCheck))),
(ItemType:DI_CHECKBOX; X1: 7; Y1: 8; X2: 0; Y2: 0; Focus: 0; Selected: False; Flags:DIF_DISABLE; DefaultButton:False; Data: (MsgID: Cardinal(msgFindCurrentPanel))),
(ItemType:DI_CHECKBOX; X1: 7; Y1: 9; X2: 0; Y2: 0; Focus: 0; Selected: False; Flags:DIF_DISABLE; DefaultButton:False; Data: (MsgID: Cardinal(msgFindAnotherPanel))),
(ItemType:DI_CHECKBOX; X1: 7; Y1: 10; X2: 0; Y2: 0; Focus: 0; Selected: False; Flags:DIF_DISABLE; DefaultButton:False; Data: (MsgID: Cardinal(msgFindLists))),
(ItemType:DI_BUTTON; X1: 35; Y1: 10; X2: 0; Y2: 0; Focus: 0; Selected: False; Flags:DIF_DISABLE; DefaultButton:False; Data: (MsgID: Cardinal(msgEDIT))),
(ItemType:DI_TEXT; X1: 0; Y1: 11; X2: 0; Y2: 0; Focus: 0; Selected: False; Flags:DIF_SEPARATOR; DefaultButton:False; Data: (Message: '')),
(ItemType:DI_BUTTON; X1: 7; Y1: 12; X2: 0; Y2: 0; Focus: 0; Selected: False; Flags:0; DefaultButton:True; Data: (MsgID: Cardinal(msgOK)))
);
begin
GetMem(items, SizeOf(TFarDialogItem)*itemsnum);
ZeroMemory(items, SizeOf(TFarDialogItem)*itemsnum);
InitDialogItems(@initarray, items, itemsnum);
Result:=DialogEx(-1,-1, DialogWidth, DialogHeight,
'Config', items, itemsnum, 0, 0, @TFARDialog.ClassDlgProc, PtrInt(Self));
FreeMem(items);
end;
End.