summaryrefslogtreecommitdiff
path: root/plugins/Watrack/i_opt_0.inc
blob: ab17d6ec0da6126dd2c8d16e8468516c7363092a (plain)
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
{special tab: parts settings}

function DlgProcOptions0(Dialog:HWnd;hMessage:UINT;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall;
const
  hasApply:boolean=false;
var
  i:integer;
  ptr:pwModule;
  wnd:HWND;
  rc:TRECT;
begin
  result:=0;
  case hMessage of
    WM_DESTROY: begin
      if hasApply then
      begin
        ptr:=ModuleLink;
        while ptr<>nil do
        begin
          if ptr^.ModuleName<>nil then
          begin
            i:=SendMessageW(ptr^.Button,BM_GETCHECK,0,0);
            if (i=BST_CHECKED) xor (ptr^.ModuleStat<>0) then
            begin
              if i=BST_CHECKED then
              begin
                ptr^.ModuleStat:=1;
                if @ptr^.Init<>nil then
                  if ptr^.Init(false)=0 then
                    ptr^.ModuleStat:=0;
              end
              else
              begin
                ptr^.ModuleStat:=0;
                if @ptr^.DeInit<>nil then
                  ptr^.DeInit(true);
              end;
            end;
//            if ptr^.ModuleStat then
          end;
          ptr:=ptr^.Next;
        end;
      end;
    end;

    WM_INITDIALOG: begin

      hasApply:=false;

      ptr:=ModuleLink;
      i:=0;
      while ptr<>nil do
      begin
        if ptr^.ModuleName<>nil then
        begin
          ptr^.Button:=CreateWindowW('BUTTON',TranslateW(ptr^.ModuleName),
              WS_CHILD+WS_VISIBLE+BS_AUTOCHECKBOX,
              14,20+i*20,150,14,Dialog,0,hInstance,nil);
          SendMessageW(ptr^.Button,WM_SETFONT,GetStockObject(DEFAULT_GUI_FONT),0);
          if ptr^.ModuleStat<>0 then
            SendMessageW(ptr^.Button,BM_SETCHECK,BST_CHECKED,0);
          inc(i);
        end;
        ptr:=ptr^.Next;
      end;
      if i>0 then
      begin
        wnd:=GetDlgItem(Dialog,IDC_MODULEGROUP);
        GetWindowRect(wnd,rc);
        SetWindowPos (wnd,0,0,0,rc.Right-rc.Left,(i+1)*20,
            SWP_NOMOVE+SWP_NOZORDER+SWP_NOACTIVATE);
      end;

      TranslateDialogDefault(Dialog);
    end;

    WM_COMMAND: begin
      if (wParam shr 16)=BN_CLICKED then
        SendMessage(GetParent(Dialog),PSM_CHANGED,0,0);
    end;

    WM_NOTIFY: begin
      if integer(PNMHdr(lParam)^.code)=PSN_APPLY then
      begin
        hasApply:=true;
      end;
    end;
  else
    {result:=}DefWindowProc(Dialog,hMessage,wParam,lParam);
  end;
end;