// http://akelpad.sourceforge.net/forum/viewtopic.php?p=22567#22567
// Version: 2016-07-19
// Author: KDJ
//
// *** GUI for manual settings ***
//
// Usage:
//   Call("Scripts::Main", 1, "AkelPadManualSettings.js")
//
// Note:
//   The script should be saved in Unicode format

var oSys        = AkelPad.SystemFunction();
var hMainWnd    = AkelPad.GetMainWnd();
var hEditWnd    = AkelPad.GetEditWnd();
var hInstDLL    = AkelPad.GetInstanceDll();
var sClassName  = "AkelPad::Scripts::" + WScript.ScriptName + "::" + hInstDLL;
var sScriptName = "AkelPad 手动设置";
var nHistMax    = 20;
var bSaveHist;
var bChanged;
var bCloseCB;
var hFocus;
var i;

var nTextLen = 8192;
var lpText   = AkelPad.MemAlloc(nTextLen * 2);
var lpLVITEM = AkelPad.MemAlloc(_X64 ? 72 : 60); //sizeof(LVITEM)
AkelPad.MemCopy(lpLVITEM, 0x0001 /*LVIF_TEXT*/, 3 /*DT_DWORD*/);
AkelPad.MemCopy(_PtrAdd(lpLVITEM, _X64 ? 24 : 20), lpText, 2 /*DT_QWORD*/);
AkelPad.MemCopy(_PtrAdd(lpLVITEM, _X64 ? 32 : 24), nTextLen, 3 /*DT_DWORD*/);

//.ini settings
var nDlgX = 100;
var nDlgY = 120;
var nSel  = 0;
var nLang = 0;
var aAkelUpdaterOptions = [];
var aCmdLineBegin       = [];
var aCmdLineEnd         = [];
var aDateInsertFormat   = [];
var aDateLogFormat      = [];
var aStatusUserFormat   = [];
var aTabNameFind        = [];
var aTabNameRep         = [];
var aUrlCommand         = [];
ReadIni();

//0x50000000=WS_VISIBLE|WS_CHILD
//0x50000001=WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON
//0x50000009=WS_VISIBLE|WS_CHILD|BS_AUTORADIOBUTTON
//0x50010003=WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_AUTOCHECKBOX
//0x50012403=WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_MULTILINE|BS_TOP|BS_AUTOCHECKBOX
//0x50010009=WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_AUTORADIOBUTTON
//0x50010042=WS_VISIBLE|WS_CHILD|WS_TABSTOP|CBS_AUTOHSCROLL|CBS_DROPDOWN
//0x50210003=WS_VISIBLE|WS_CHILD|WS_VSCROLL|WS_TABSTOP|CBS_DROPDOWNLIST
//0x50010800=WS_VISIBLE|WS_CHILD|WS_TABSTOP|ES_READONLY
//0x50310804=WS_VISIBLE|WS_CHILD|WS_HSCROLL|WS_VSCROLL|WS_TABSTOP|ES_READONLY|ES_MULTILINE
//0x5081800D=WS_VISIBLE|WS_CHILD|WS_BORDER|WS_TABSTOP|LVS_NOSORTHEADER|LVS_SHOWSELALWAYS|LVS_SINGLESEL|LVS_REPORT

var oAkelAdminResident =
{
  Def   :1,
  Wnd   :[],
  IDTXT :2001,
  IDBUT1:2002,
  IDBUT2:2003,
  IDDEF :2004,

  Initialize:function()
  {
    this.Val = SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 126 /*MI_AKELADMINRESIDENT*/, 0);
    this.Ini = this.Val;

    this.Wnd[this.IDTXT ]={C:'STATIC', S:0x50000000, X:140, Y:15, W:640, H:13, Txt:'定义“AkelAdmin.exe”的居住:',
                                                                               Rus:''};
    this.Wnd[this.IDBUT1]={C:'BUTTON', S:0x50010009, X:140, Y:35, W:640, H:16, Txt:'0 - AkelAdmin.exe 被从内存中卸载。在每次更改受保护文件时都将会提示输入密码。',
                                                                               Rus:''};
    this.Wnd[this.IDBUT2]={C:'BUTTON', S:0x50010009, X:140, Y:55, W:640, H:16, Txt:'1 - AkelAdmin.exe 停留在内存中。仅在第一次更改受保护文件时会提示输入密码。',
                                                                               Rus:''};
    this.Wnd[this.IDDEF ]={C:'BUTTON', S:0x50010003, X:140, Y:81, W:640, H:16, Txt:'默认值: 1',
                                                                               Rus:''};
  },

  Apply:function()
  {
    SendMessage(hMainWnd, 1219 /*AKD_SETMAININFO*/, 126 /*MIS_AKELADMINRESIDENT*/, this.Val);
  },

  SetVal:function()
  {
    for (var i = this.IDBUT1; i <= this.IDBUT2; ++i)
      SendMessage(this.Wnd[i].HWND, 241 /*BM_SETCHECK*/, this.Val == i - this.IDBUT1, 0);
    SendMessage(this.Wnd[this.IDDEF].HWND, 241 /*BM_SETCHECK*/, this.Val == this.Def, 0);
  },

  Command:function(nID, nCode, hWnd)
  {
    if ((nID >= this.IDBUT1) && (nID <= this.IDBUT2))
    {
      bChanged = 1;
      this.Val = nID - this.IDBUT1;
      this.SetVal();
      SendMessage(aDlg[IDENGB + nLang].HWND, 241 /*BM_SETCHECK*/, 1, 0);
    }
    else if ((nID == this.IDDEF) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
    {
      bChanged = 1;
      this.Val = this.Def;
      this.SetVal();
    }
    else if ((nID == IDENGB) ||(nID == IDRUSB))
      this.SetVal();
  }
};

var oAkelUpdaterOptions =
{
  Val  :'',
  Def  :'',
  Wnd  :[],
  IDTXT:2001,
  IDVAL:2002,
  IDDEF:2003,
  IDED :2004,

  Initialize:function()
  {
    if (SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 131 /*MI_AKELUPDATEROPTIONS*/, lpText))
      this.Val = AkelPad.MemRead(lpText, 1 /*DT_UNICODE*/);

    this.Ini = this.Val;

    this.Wnd[this.IDTXT]={C:'STATIC',    S:0x50000000, X:140, Y:15, W:640, H: 13, Txt:'定义从菜单“帮助/更新...”启动“AkelUpdater.exe”时的命令行选项:',
                                                                                  Rus:''};
    this.Wnd[this.IDVAL]={C:'COMBOBOX',  S:0x50010042, X:140, Y:35, W:640, H: 21};
    this.Wnd[this.IDDEF]={C:'BUTTON',    S:0x50010003, X:140, Y:66, W:640, H: 16, Txt:'默认值: ""',
                                                                                  Rus:''};
    this.Wnd[this.IDED ]={C:'AkelEditW', S:0x50310804, X:140, Y:91, W:640, H:344, Txt:'/PROXY=IP:PORT\n\t当前代理服务器设置。默认情况将会使用 IE 设置。\n/AUTH=LOGIN:PASSWORD\n\t代理服务器登录和密码(仅 http)。\n/NOPROXY\n\t对于本次连接禁用代理服务器设置(如果有的话)。\n/LANG=[eng|rus]\n\t选择语言。\n/ONTOP\n\t设置对话框总在最前。\n/BIT=[32|64]\n\t更新为 32 位或 64 位版本。若无指定将自动检测。\n/SAVEDIR=[路径]\n\t保存下载到目录。\n/DLONLY\n\t不更新，仅下载。\n/AUTO\n\t如果允许的话就自动选择升级，否则取消/关闭。\n/NORUN\n\t关闭 "Run AkelPad" 复选框。\n/NOCOPIES\n\t不加载 DLLs 来查找原始插件名称。\n/UNZIP=[options]\n\tnsUnzip 选项。\n\n例: /PROXY=192.168.0.1:3128 /SAVEDIR="%a\\AkelFiles\\Updates"'};
  },

  Apply:function()
  {
    SendMessage(hMainWnd, 1219 /*AKD_SETMAININFO*/, 131 /*MIS_AKELUPDATEROPTIONS*/, this.Val);
  },

  SetVal:function()
  {
    oSys.Call("User32::SetWindowTextW", this.Wnd[this.IDVAL].HWND, this.Val);
    SendMessage(this.Wnd[this.IDDEF].HWND, 241 /*BM_SETCHECK*/, this.Val == this.Def, 0);
  },

  Command:function(nID, nCode, hWnd)
  {
    if (nID == this.IDVAL)
      ProcessCB(hWnd, nCode);
    else if ((nID == this.IDDEF) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
    {
      bChanged = 1;
      this.Val = this.Def;
      this.SetVal();
    }
  }
};

var oCmdLineBegin =
{
  Val  :'',
  Def  :'',
  Wnd  :[],
  IDTXT:2001,
  IDVAL:2002,
  IDDEF:2003,
  IDED1:2004,
  IDED2:2005,

  Initialize:function()
  {
    if (SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 105 /*MI_CMDLINEBEGIN*/, lpText))
      this.Val = AkelPad.MemRead(lpText, 1 /*DT_UNICODE*/);

    this.Ini = this.Val;

    this.Wnd[this.IDTXT]={C:'STATIC',    S:0x50000000, X:140, Y: 15, W:640, H: 13, Txt:'指定在执行命令行之前添加到它开始处的代码:',
                                                                                   Rus:''};
    this.Wnd[this.IDVAL]={C:'COMBOBOX',  S:0x50010042, X:140, Y: 35, W:640, H: 21};
    this.Wnd[this.IDDEF]={C:'BUTTON',    S:0x50010003, X:140, Y: 66, W:640, H: 16, Txt:'默认值: ""',
                                                                                   Rus:''};
    this.Wnd[this.IDED1]={C:'AkelEditW', S:0x50010800, X:140, Y: 91, W:640, H: 21, Txt:'例: /C+',
                                                                                   Rus:''};
    this.Wnd[this.IDED2]={C:'AkelEditW', S:0x50310804, X:140, Y:122, W:640, H:358, Txt:'*** 命令行参数 ***\n\nAkelPad.exe [参数] "file1.ext" [参数] "file2.ext" [参数] ...\n\n/x\t\t- 当解析命令行参数时不使用 MS Notepad 兼容模式。\n/p\t\t- 打印下一个文件，然后关闭。\n/C+\t\t- 如果文件不存在就静默创建新文件。\n/C-\t\t- 如果文件不存在也不要创建新文件。\n/C\t\t- 如果文件不存在就询问是否创建新文件(默认值)。\n/B+\t\t- 如果文件是二进制文件就静默打开文件。\n/B-\t\t- 如果文件是二进制文件就不要打开文件。\n/B\t\t- 如果文件是二进制文件就询问是否打开文件(默认值)。\n/L+\t\t- 即使在指定编码下符号将会丢失也要静默保存文件。\n/L-\t\t- 如果在指定编码下符号将会丢失就不保存文件。\n/L\t\t- 如果在指定编码下符号将会丢失就询问是否保存文件(默认值)。\n/Z\t\t- 忽略下一个命令行参数。\n/NewInstance\n\t- 强制新建程序例程。\n/MainClass("MyAkelPad4")\n\t\t- 给新程序例程设置一个类名。名称可以包含变量 %d, 表示进程 ID。\n/Reassoc\t- 重新关联先前指定的文件类型。\n/Deassoc\t- 取消关联先前指定的文件类型。\n/Quit\t- 停止传递命令行参数并退出程序。\n/End\t- 停止传递命令行参数\n\n方法:\n/Show(主窗口样式)\n\t主窗口样式\n\t\t0 隐藏窗口。\n\t\t1 窗口默认值。\n\t\t2 最小化窗口。\n\t\t3 最大化窗口。\n\t\t6 最小化、非活动窗口。\n\t\t9 无最大化窗口。\n\t/Show(2)\n\t\t以最小化样式显示主窗口的方法。\n/OpenFile("文件"[, 使用代码页][, 使用BOM])\n\t"文件"\n\t\t要打开的文件。\n\t使用代码页\n\t\t打开代码页。如果 -1 或未指定表示自动检测。\n\t使用BOM\n\t\t文件字节顺序标记。如果 -1 或未指定表示自动检测。\n\t/OpenFile("C:\\File.txt", 65001, -1)\n\t\t方法将使用 UTF-8 代码页打开文件。\n/SaveFile("文件", [使用代码页], [使用BOM])\n\t"文件"\n\t\t保存当前的文档到指定的文件名。\n\t使用代码页\n\t\t如果 -1 或未指定表示将会使用当前的代码页。\n\t使用BOM\n\t\t字节顺序标记。1 表示存在，0 表示不存在，-1 表示未指定将会使用当前的 BOM。\n\t/SaveFile("C:\\File.txt", 65001, 0)\n\t\t方法将使用无 BOM 的 UTF-8 代码页保存文件。\n/Command(内部命令, [参数])\n\t/Command(4162)\n\t方法将调用 内部命令 4162。\n/Call("插件::函数", [附加参数])\n\t/Call("Scripts::Main")\n\t\t方法将调用 脚本 插件的主函数。\n/Exec("命令行"[, "工作目录"][, 等待][, 窗口样式])\n\t"命令行"\n\t\t命令行字符串。\n\t"工作目录"\n\t\t工作目录字符串。默认值为 ""。\n\t等待\n\t\t等待直到程序完成。1 - 等待，0 - 立即返回(默认值)。\n\窗口样式\n\t\t请参阅 MainWindowStyle 的 /Show() 方法的说明。注意: 程序可能会忽略这个参数。\n\t/Exec("notepad.exe")\n\t\t方法将调用 记事本。\n\t/Exec(`notepad.exe`)\n\t\t方法将调用 记事本。\n\t/Exec(\'notepad.exe\')\n\t\t方法将调用 记事本。\n\t/Exec(\'%windir%\\notepad.exe\')\n\t\t方法将调用 记事本。\n\t/Exec(`rundll32.exe shell32,ShellExec_RunDLL "%f"`, "%d")\n\t\t方法将传递用 Windows 关联程序来打开活动文件。\n/Font("字体", 字形, 大小)\n\t"字体"\n\t\t字体名称，如："Courier". "" 表示不改变。\n\t字形 (下列之一):\n\t\t0 忽略。\n\t\t1 常规。\n\t\t2 粗体。\n\t\t3 斜体。\n\t\t4 粗斜体。\n\t大小\n\t\t字体的大小。0 表示不改变。\n\t/Font("Courier", 4, 10)\n\t\t方法将设置 Courier 粗斜体，大小 10 号。\n/Recode(源编码, 目标编码)\n\t源编码\n\t\t来源代码页。值为 -1 表示自动检测。\n\t目标编码\n\t\t目标代码页。值为 -1 表示自动检测。\n\t/Recode(1252, 437)\n\t\t文字的代码页从 1252 到 437。\n/Insert("文字", [转义符序列])\n\t"文字"\n\t\t要插入的文字。\n\t转义符序列:\n\t\t0 - "文字" 不包含转义符序列 (默认值)。\n\t\t1 - "文字" 包含转义符序列。转义符序列集与程序的查找/替换对话框的相同，并且:\n\t\t\t"\\s" - 将替换为编辑窗口中的选定区域的文字；\n\t\t\t"\\|" - 设置插入点的位置在插入文本之后。\n\t/Insert("一些字符串")\n\t\t方法将用指定的文字替换选定区域。\n\t/Insert("<B>\\s</B>", 1)\n\t\t方法将围起选定区域。\n\t/Insert("\\[0031 0032 0033]", 1)\n\t\t方法将替换选定区域为 "123"。\n/If("表达式", "IfTrue", "IfFalse")\n\t"表达式"\n\t\t表达式可以由下列组成:\n\t\t- 数学运算符: +, -, *, /, %, &, |, ^.\n\t\t- 逻辑运算符: >, <, ==, !=, >=, <=, &&, ||, x?y:z.\n\t\t- 注释: /*注释*/\n\t\t- 方法:\n\t\t\tSendMain(nMessage, wParam, lParam)\n\t\t\t\tnMessage\n\t\t\t\t\t指定要发送给主窗口的消息。\n\t\t\t\twParam\n\t\t\t\t\t指定额外消息特定信息。\n\t\t\t\tlParam\n\t\t\t\t\t指定额外消息特定信息。\n\t\t\tSendEdit(nMessage, wParam, lParam)\n\t\t\t\tnMessage\n\t\t\t\t\t指定要发送给当前编辑窗口的消息。\n\t\t\t\twParam\n\t\t\t\t\t指定额外消息特定信息。\n\t\t\t\tlParam\n\t\t\t\t\t指定额外消息特定信息。\n\t\t\tCall("Plugin::Function"[, 额外参数])\n\t\t\t\t- 如果调用一个插件，那么通过指定的参数 &nResult 传递退出代码。&nResult 必须放在外部调用语法请求指向一个整数的指针的位置。\n\t\t\t\t/If(`Call("Coder::CodeFold", 1, &nResult)`, `/Call("Coder::CodeFold", 1)`, ``)\n\t\t\t\t\t若 CodeFold 窗口已打开就关闭它。\n\t\t\t\t- 如果调用一个脚本，那么就有必要使用外部调用 2 或 4，并且还可以通过 AkelPad.ScriptExitCode 从脚本传递退出代码。\n\t\t\t\t/If(`Call("Scripts::Main", 4, "EvalCmd.js", \'if (AkelPad.GetEditFile(0)) AkelPad.ScriptExitCode(1);\')`, ``, `/Quit`)\n\t\t\t\t\t若当前文档无名称就退出。\n\t\t\t\t- 可以直接调用 Scripts 插件的方法。\n\t\t\t\t/If(`AkelPad.Constants._X64 == 1`, `/Quit`, ``)\n\t\t\t\t\t如果程序为 x64 就退出。\n\t"IfTrue"\n\t\t命令行，如果表达式结果为“真” (不等于 0)。\n\t"IfFalse"\n\t\t命令行，如果表达式结果为“假” (等于 0)。\n\t/If(`SendMain(1222 /*AKD_GETMAININFO*/, 5 /*MI_SAVESETTINGS*/, 0) == 2 /*SS_INI*/`, `/OpenFile("%a\\AkelPad.ini")`, ``)\n\t\t如果设置是保存到 ini 文件的就打开 AkelPad.ini 的方法。\n/Var(Flags)\n\t在接下来的命令行方法中使用变量的标志。根据下列成员的和来设置:\n\t\t0 不展开变量。\n\t\t1 展开系统变量 (如: %windir%)。\n\t\t2 展开程序变量 %f,%d,%a. 若使用，符号 % 应写为 %%。\n\t\t默认值: 1+2=3。\n\t/Var(0) /OpenFile("1%a%2.txt")\n\t\t打开文件 "1%a%2.txt"。\n\n方法中可使用的变量:\n\t标准用法:\n\t\t%f - 活动文件\n\t\t%d - 活动文件所在的目录\n\t\t%a - AkelPad 目录 (即 包含有 AkelPad.exe 的目录)\n\t\t%% - % 符号\n\t\t%系统变量%(即环境变量)\n\t批处理文件 (bat,cmd):\n\t\t%%f - 活动文件\n\t\t%%d - 活动文件所在的目录\n\t\t%%a - AkelPad 目录 (即 包含有 AkelPad.exe 的目录)\n\t\t%%%% - % 符号\n\t\t%系统变量%(即环境变量)\n\t\t^& - & 符号\n\n\n*** 内部命令 ***\n\n可以在命令行 /Command() 方法、ContextMenu、ToolBar、Hotkeys 和 Scripts 插件中使用。\n\n4101\t创建新的编辑窗口\n4102\t创建新的程序实例\n4103\t打开文件对话框. 可选参数:\n\t\t1 - 强制使用最近目录。\n4104\t重新打开文件\n4105\t保存文件\n4106\t保存文件对话框。可选参数:\n\t\t1 - 强制使用最近目录。\n4107\t打印设置对话框\n4108\t打印对话框\n4109\t退出程序\n4110\t保存所有文档\n4111\t全部另存为对话框\n4113\t无对话框打印\n4114\t打印预览对话框\n4121\t重新检测当前文件的代码页\n4122\t重新打开文件时使用编码 ANSI\n4123\t重新打开文件时使用编码 OEM\n4124\t重新打开文件时使用编码 KOI-R\n4125\t重新打开文件时使用编码 UTF16LE\n4126\t重新打开文件时使用编码 UTF16BE\n4127\t重新打开文件时使用编码 UTF8\n4131\t另存为文件时使用编码 ANSI\n4132\t另存为文件时使用编码 OEM\n4133\t另存为文件时使用编码 KOI-R\n4134\t另存为文件时使用编码 UTF16LE\n4135\t另存为文件时使用编码 UTF16BE\n4136\t另存为文件时使用编码 UTF8\n4137\t另存为文件时使用编码 UTF8 无 BOM\n4140\t显示代码页上下文菜单\n4151\t撤消最后的操作\n4152\t恢复最后的操作\n4153\t剪切\n4154\t复制\n4155\t粘贴\n4156\t删除\n4157\t全选\n4158\t查找对话框\n4159\t向下查找最近字串\n4160\t向上查找最近字串\n4161\t替换对话框\n4162\t转到行对话框\n4163\t运行 charmap.exe\n4164\t插入制表符\n4165\t仅当选定几行时插入制表符\n4166\t删除制表符 若选择多行时删除制表符，否则插入制表符。可选参数:\n\t\t1 - 删除选择单一行的制表符。\n4167\t仅当选定几行时删除制表符\n4168\t插入空格\n4169\t仅当选定几行时插入空格\n4170\t若选择多行时删除空格，否则插入空格。可选参数:\n\t\t1 - 删除选择单一行的空格。\n4171\t仅当选定几行时删除空格\n4172\t删除第一个字符\n4173\t仅当选定的不为空时删除第一个字符\n4174\t删除尾部空格\n4175\tConvert text to "UPPERCASE". 可选参数:\n\t\t1 - 如果没有选定文本就改变整个文档的大小写。\n4176\t小写 选定的文本。可选参数:\n\t\t1 - 如果没有选定文本就改变整个文档的大小写。\n4177\t句子大小写 选定的文本。可选参数:\n\t\t1 - 如果没有选定文本就改变整个文档的大小写。\n4178\t标题大小写 选定的文本。可选参数:\n\t\t1 - 如果没有选定文本就改变整个文档的大小写。\n4179\t反转大小写 选定的文本。可选参数:\n\t\t1 - 如果没有选定文本就改变整个文档的大小写。\n4180\t循环大小写。可选参数:\n\t\t1 - 如果没有选定文本就改变整个文档的大小写。\n4182\t重编码对话框\n4183\t插入日期\n4184\t换行符格式 Windows\n4185\t换行符格式 Unix\n4186\t换行符格式 Mac\n4190\t插入/覆盖模式\n4191\t以 ANSI 文本粘贴\n4192\t粘贴到列选\n4193\t粘贴文本到插入点之后\n4194\t根据选择区域的大小写来粘贴文本\n4195\t删除选定区域中的所有空白字符\n4196\t如果“保留左边空格”为关，插入换行时保留左边空格。\n\t\t如果“保留左边空格”为开，插入换行时不保留左边空格。\n4197\t删除当前行。可选参数:\n\t\t1 - 删除所有自动换行。\n4198\t移动插入点到选定区域的另一端\n4199\t移动插入点到上一个位置\n4200\t移动插入点到下一个位置\n4201\t字体对话框\n4202\t颜色方案对话框\n4204\t字号增加 1pt\n4205\t字号减小 1pt\n4206\t恢复到启动时的字号\n4209\t自动换行 (开\关)\n4210\t总在最前 (开\关)\n4211\t显示状态栏 (开\关)\n4212\t拆分窗口为四个窗格\n4213\t拆分窗口为两个垂直窗格\n4214\t拆分窗口为两个水平窗格\n4215\t拆分窗口 (开\关)\n4216\t只读 (开\关)\n4251\t执行命令\n4252\t保存文件时间 (开\关)\n4253\t监视文件更改 (开\关)\n4254\t保留左边空格 (开\关)\n4255\t单一打开文件 (开\关)\n4256\t单一打开程序 (开\关)\n4259\t插件对话框\n4260\t选项对话框\n4261\t单窗口\n4262\t多窗口\n4263\t伪多窗口\n4301\t标签列表窗口在主窗口的顶部\n4302\t标签列表窗口在主窗口的底部\n4303\t隐藏 标签列表\n4304\t标准 标签列表风格\n4305\t按钮 标签列表风格\n4306\t平坦按钮 标签列表风格\n4307\tMDI 窗口 - 水平平铺\n4308\tMDI 窗口 - 垂直平铺\n4309\tMDI 窗口 - 层叠\n4310\t切换标签: 下一个-上一个。\n4311\t切换标签: 右-左。\n4316\t激活下一个标签\n4317\t激活上一个标签\n4318\t关闭当前标签\n4319\t关闭所有标签\n4320\t关闭除活动外的所有标签\n4321\t关闭所有未被修改的标签\n4322\t克隆当前标签\n4323\t复制当前标签的文件路径。可选参数:\n\t\t0 - 复制完整路径 (默认值);\n\t\t1 - 复制目录;\n\t\t2 - 复制文件名称;\n\t\t3 - 复制文件名称 (不带扩展名);\n\t\t4 - 复制文件扩展名。\n4324\t关闭文件\n4325\t关闭文件并退出程序 (SDI) 或关闭一个文件的标签 (MDI/PMDI)。\n4327\t选择窗口对话框 (MDI/PMDI)。与 10019 相同。\n4331\t恢复/最大化主窗口\n4332\t激活下一个对话框窗口\n4333\t激活上一个对话框窗口\n4341\t激活下一个窗格 (拆分窗口)\n4342\t激活上一个窗格 (拆分窗口)\n4351\t关于对话框\n4352\t打开用户手册 (即 本文档)\n4353\t检查更新 (AkelUpdater)，使用 AkelUpdaterOptions 字串\n5001\t从最近文件列表中删除失效的文件\n5001+n\t打开最近文件 n\n6001\t激活内部语言\n6001+n\t激活语言 n\n7001\t使用代码页列表的第一个代码页来重新打开文件\n7001+n\t使用代码页列表的第 n 个代码页来重新打开文件\n8001\t使用代码页列表的第一个代码页来保存文件\n8001+n\t使用代码页列表的第 n 个代码页来保存文件\n10019\t选择窗口对话框 (MDI/PMDI)。与 4327 相同。',
                                                                                   Rus:''};
  },

  Apply:function()
  {
    SendMessage(hMainWnd, 1219 /*AKD_SETMAININFO*/, 105 /*MIS_CMDLINEBEGIN*/, this.Val);
  },

  SetVal:function()
  {
    oSys.Call("User32::SetWindowTextW", this.Wnd[this.IDVAL].HWND, this.Val);
    SendMessage(this.Wnd[this.IDDEF].HWND, 241 /*BM_SETCHECK*/, this.Val == this.Def, 0);
  },

  Command:function(nID, nCode, hWnd)
  {
    if (nID == this.IDVAL)
      ProcessCB(hWnd, nCode);
    else if ((nID == this.IDDEF) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
    {
      bChanged = 1;
      this.Val = this.Def;
      this.SetVal();
    }
  }
};

var oCmdLineEnd =
{
  Val  :'',
  Def  :'',
  Wnd  :[],
  IDTXT:2001,
  IDVAL:2002,
  IDDEF:2003,
  IDED1:2004,
  IDED2:2005,

  Initialize:function()
  {
    if (SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 106 /*MI_CMDLINEEND*/, lpText))
      this.Val = AkelPad.MemRead(lpText, 1 /*DT_UNICODE*/);

    this.Ini = this.Val;

    this.Wnd[this.IDTXT]={C:'STATIC',    S:0x50000000, X:140, Y: 15, W:640, H: 13, Txt:'指定在执行命令行之前添加到它末尾处的代码::',
                                                                                   Rus:''};
    this.Wnd[this.IDVAL]={C:'COMBOBOX',  S:0x50010042, X:140, Y: 35, W:640, H: 21};
    this.Wnd[this.IDDEF]={C:'BUTTON',    S:0x50010003, X:140, Y: 66, W:640, H: 16, Txt:'默认值: ""',
                                                                                   Rus:''};
    this.Wnd[this.IDED1]={C:'AkelEditW', S:0x50010800, X:140, Y: 91, W:640, H: 21, Txt:'例: /Call("Scripts::Main", 1, "InsertDate.js", "") /C /B /L',
                                                                                   Rus:''};
    this.Wnd[this.IDED2]={C:'AkelEditW', S:0x50310804, X:140, Y:122, W:640, H:358, Txt:oCmdLineBegin.Wnd[oCmdLineBegin.IDED2].Txt,
                                                                                   Rus:oCmdLineBegin.Wnd[oCmdLineBegin.IDED2].Rus};
  },

  Apply:function()
  {
    SendMessage(hMainWnd, 1219 /*AKD_SETMAININFO*/, 106 /*MIS_CMDLINEEND*/, this.Val);
  },

  SetVal:function()
  {
    oSys.Call("User32::SetWindowTextW", this.Wnd[this.IDVAL].HWND, this.Val);
    SendMessage(this.Wnd[this.IDDEF].HWND, 241 /*BM_SETCHECK*/, this.Val == this.Def, 0);
  },

  Command:function(nID, nCode, hWnd)
  {
    if (nID == this.IDVAL)
      ProcessCB(hWnd, nCode);
    else if ((nID == this.IDDEF) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
    {
      bChanged = 1;
      this.Val = this.Def;
      this.SetVal();
    }
  }
};

var oDateInsertFormat =
{
  Val  :'',
  Def  :'',
  Wnd  :[],
  IDTXT:2001,
  IDVAL:2002,
  IDDEF:2003,
  IDED :2004,

  Initialize:function()
  {
    if (SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 130 /*MI_DATEINSERTFORMAT*/, lpText))
      this.Val = AkelPad.MemRead(lpText, 1 /*DT_UNICODE*/);

    this.Ini = this.Val;

    this.Wnd[this.IDTXT]={C:'STATIC',    S:0x50000000, X:140, Y:15, W:640, H: 13, Txt:'定义插入日期和时间格式:',
                                                                                  Rus:''};
    this.Wnd[this.IDVAL]={C:'COMBOBOX',  S:0x50010042, X:140, Y:35, W:640, H: 21};
    this.Wnd[this.IDDEF]={C:'BUTTON',    S:0x50010003, X:140, Y:66, W:640, H: 16, Txt:'默认值: "" - 程序已定义的日期和时间格式。',
                                                                                  Rus:''};
    this.Wnd[this.IDED ]={C:'AkelEditW', S:0x50310804, X:140, Y:91, W:640, H:357, Txt:'时间:\nh\t无前导零的单位数的小时；12 小时制。\nhh\t带前导零的单位数的小时；12 小时制。\nH\t无前导零的单位数的小时；24 小时制。\nHH\t带前导零的单位数的小时；24 小时制。\nm\t无前导零的单位数的分钟。\nmm\t带前导零的单位数的分钟。\ns\t无前导零的单位数的秒。\nss\t带前导零的单位数的秒。\nt\t单字符时间标识字串，如 A 或 P。\ntt\t多字符时间标识字串，如 AM 或 PM。\n\n日期:\nd\t无前导零的单位数的日。\ndd\t带前导零的单位数的日。\nddd\t三个字母缩写的星期。\ndddd\t完整名称的星期。\nM\t无前导零的单位数的月。\nMM\t带前导零的单位数的月。\nMMM\t三个字母缩写的月。\nMMMM\t完整名称的月。\ny\t最后两位数的年，但少于 10 时无前导零。\nyy\t最后两位数的年，但少于 10 时带前导零。\nyyyy\t完整四位数的年。\ngg\t周期/年代字串 (如：B.C.、A.D.)。\n\n例: "H:mm:ss dd MMMM yyyy" -> "12:50:24 01 September 2010"',
                                                                                  Rus:''};
  },

  Apply:function()
  {
    SendMessage(hMainWnd, 1219 /*AKD_SETMAININFO*/, 130 /*MIS_DATEINSERTFORMAT*/, this.Val);
  },

  SetVal:function()
  {
    oSys.Call("User32::SetWindowTextW", this.Wnd[this.IDVAL].HWND, this.Val);
    SendMessage(this.Wnd[this.IDDEF].HWND, 241 /*BM_SETCHECK*/, this.Val == this.Def, 0);
  },

  Command:function(nID, nCode, hWnd)
  {
    if (nID == this.IDVAL)
      ProcessCB(hWnd, nCode);
    else if ((nID == this.IDDEF) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
    {
      bChanged = 1;
      this.Val = this.Def;
      this.SetVal();
    }
  }
};

var oDateLogFormat =
{
  Val     :'',
  Def     :'',
  Wnd     :[],
  IDTXT   :2001,
  IDVAL   :2002,
  IDDEF   :2003,
  IDENABLE:2004,
  IDED    :2005,

  Initialize:function()
  {
    if (SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 129 /*MI_DATELOGFORMAT*/, lpText))
      this.Val = AkelPad.MemRead(lpText, 1 /*DT_UNICODE*/);

    this.Ini       = this.Val;
    this.Enable    = SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 217 /*MI_DATELOG*/, 0);
    this.EnableIni = this.Enable;

    this.Wnd[this.IDTXT   ]={C:'STATIC',    S:0x50000000, X:140, Y: 15, W:640, H: 13, Txt:'为在开头包含 ".LOG" 的文件定义日期和时间格式:',
                                                                                      Rus:''};
    this.Wnd[this.IDVAL   ]={C:'COMBOBOX',  S:0x50010042, X:140, Y: 35, W:640, H: 21};
    this.Wnd[this.IDDEF   ]={C:'BUTTON',    S:0x50010003, X:140, Y: 66, W:640, H: 16, Txt:oDateInsertFormat.Wnd[oDateInsertFormat.IDDEF].Txt,
                                                                                      Rus:oDateInsertFormat.Wnd[oDateInsertFormat.IDDEF].Rus};
    this.Wnd[this.IDENABLE]={C:'BUTTON',    S:0x50010003, X:140, Y: 86, W:640, H: 16, Txt:'仅当启用设置 "如果文件以“.LOG”开头时插入日期" (DateLog=1) 时可用。',
                                                                                      Rus:''};
    this.Wnd[this.IDED    ]={C:'AkelEditW', S:0x50310804, X:140, Y:112, W:640, H:357, Txt:oDateInsertFormat.Wnd[oDateInsertFormat.IDED].Txt,
                                                                                      Rus:oDateInsertFormat.Wnd[oDateInsertFormat.IDED].Rus};
  },

  Apply:function()
  {
    SendMessage(hMainWnd, 1219 /*AKD_SETMAININFO*/, 129 /*MIS_DATELOGFORMAT*/, this.Val);
    SendMessage(hMainWnd, 1219 /*AKD_SETMAININFO*/, 217 /*MIS_DATELOG*/, this.Enable);
  },

  SetVal:function()
  {
    oSys.Call("User32::SetWindowTextW", this.Wnd[this.IDVAL].HWND, this.Val);
    SendMessage(this.Wnd[this.IDDEF   ].HWND, 241 /*BM_SETCHECK*/, this.Val == this.Def, 0);
    SendMessage(this.Wnd[this.IDENABLE].HWND, 241 /*BM_SETCHECK*/, this.Enable, 0);
  },

  Command:function(nID, nCode, hWnd)
  {
    if (nID == this.IDVAL)
      ProcessCB(hWnd, nCode);
    else if ((nID == this.IDDEF) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
    {
      bChanged = 1;
      this.Val = this.Def;
      this.SetVal();
    }
    else if (nID == this.IDENABLE)
    {
      bChanged = 1;
      this.Enable = SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0);
    }
  }
};

var oEditStyle =
{
  Def   :0,
  Wnd   :[],
  IDTXT :2001,
  IDBUT1:2002,
  IDDEF :2003,
  IDSUM :2004,

  Initialize:function()
  {
    this.Val = SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 122 /*MI_EDITSTYLE*/, 0);
    this.Ini = this.Val;

    this.Wnd[this.IDTXT ]={C:'STATIC', S:0x50000000, X:140, Y:15, W:640, H:13,                            Txt:'定义一些编辑窗口创建标记。根据下面数字之和来设置:',
                                                                                                          Rus:''};
    this.Wnd[this.IDBUT1]={C:'BUTTON', S:0x50012403, X:140, Y:35, W:640, H:26, Type:1 /*EDS_GLOBALUNDO*/, Txt:'1 - 对撤消缓冲区使用进程堆而不是窗口堆。这个标记应用于 AEM_DETACHUNDO 和 AEM_ATTACHUNDO 消息，但关闭编辑窗口时，内存释放速度会慢一点。',
                                                                                                          Rus:''};
    this.Wnd[this.IDDEF ]={C:'BUTTON', S:0x50010003, X:140, Y:93, W:640, H:16,                            Txt:'默认值: 0',
                                                                                                          Rus:''};
    this.Wnd[this.IDSUM ]={C:'STATIC', S:0x50000000, X:150, Y:67, W: 70, H:13};
  },

  Apply:function()
  {
    SendMessage(hMainWnd, 1219 /*AKD_SETMAININFO*/, 122 /*MIS_EDITSTYLE*/, this.Val);
  },

  SetVal:function()
  {
    for (var i = this.IDBUT1; i <= this.IDBUT1; ++i)
      SendMessage(this.Wnd[i].HWND, 241 /*BM_SETCHECK*/, this.Val & this.Wnd[i].Type, 0);
    oSys.Call("User32::SetWindowTextW", this.Wnd[this.IDSUM].HWND, '=' + this.Val);
    SendMessage(this.Wnd[this.IDDEF].HWND, 241 /*BM_SETCHECK*/, this.Val == this.Def, 0);
  },

  Command:function(nID, nCode, hWnd)
  {
    if ((nID >= this.IDBUT1) && (nID <= this.IDBUT1))
    {
      bChanged = 1;
      this.Val = 0;
      for (var i = this.IDBUT1; i <= this.IDBUT1; ++i)
      {
        if (SendMessage(this.Wnd[i].HWND, 240 /*BM_GETCHECK*/, 0, 0))
          this.Val |= this.Wnd[i].Type;
      }
      this.SetVal();
    }
    else if ((nID == this.IDDEF) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
    {
      bChanged = 1;
      this.Val = this.Def;
      this.SetVal();
    }
  }
};

var oFixedCharWidth =
{
  Def   :0,
  Wnd   :[],
  IDTXT :2001,
  IDVAL :2002,
  IDDEF :2003,
  IDNOTE:2004,

  Initialize:function()
  {
    this.Val = SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 120 /*MI_FIXEDCHARWIDTH*/, 0);

    if ((this.Val < -1) && (this.Val != -4) && (this.Val != -6))
      this.Val = 0;

    this.Ini = this.Val;

    this.Wnd[this.IDTXT ]={C:'STATIC',   S:0x50000000, X:140, Y: 15, W:640, H:78, Txt:'定义固定字符宽度。包括比例字体在内的所有符号将会以这个宽度来绘制。\n特殊值:\n-1 - 字体拉丁字符平均宽度。\n-4 - 字体空格宽度。\n-6 - 字体拉丁字符最大宽度。\n0 - 0 - 禁用固定宽度。',
                                                                                  Rus:''};
    this.Wnd[this.IDVAL ]={C:'COMBOBOX', S:0x50210003, X:140, Y:100, W: 50, H:21};
    this.Wnd[this.IDDEF ]={C:'BUTTON',   S:0x50010003, X:140, Y:131, W:640, H:16, Txt:'默认值: 0',
                                                                                  Rus:''};
    this.Wnd[this.IDNOTE]={C:'STATIC',   S:0x50000000, X:140, Y:157, W:640, H:13, Txt:'注意: 更改将应用到新建的编辑窗口。',
                                                                                  Rus:''};
  },

  Apply:function()
  {
    SendMessage(hMainWnd, 1219 /*AKD_SETMAININFO*/, 120 /*MIS_FIXEDCHARWIDTH*/, this.Val);
  },

  SetVal:function()
  {
    SendMessage(this.Wnd[this.IDVAL].HWND, 0x014E /*CB_SETCURSEL*/, SendMessage(this.Wnd[this.IDVAL].HWND, 0x0158 /*CB_FINDSTRINGEXACT*/, -1, this.Val.toString()), 0);
    SendMessage(this.Wnd[this.IDDEF].HWND, 241 /*BM_SETCHECK*/, this.Val == this.Def, 0);
  },

  InitDialog:function()
  {
    SendMessage(this.Wnd[this.IDVAL].HWND, 0x0143 /*CB_ADDSTRING*/, 0, "-6");
    SendMessage(this.Wnd[this.IDVAL].HWND, 0x0143 /*CB_ADDSTRING*/, 0, "-4");
    SendMessage(this.Wnd[this.IDVAL].HWND, 0x0143 /*CB_ADDSTRING*/, 0, "-1");
    for (var i = 0; i < 201; ++i)
      SendMessage(this.Wnd[this.IDVAL].HWND, 0x0143 /*CB_ADDSTRING*/, 0, i.toString());
    if (this.Ini > 200)
      SendMessage(this.Wnd[this.IDVAL].HWND, 0x0143 /*CB_ADDSTRING*/, 0, this.Ini.toString());
  },

  Command:function(nID, nCode, hWnd)
  {
    if (nID == this.IDVAL)
    {
      if (nCode == 1 /*CBN_SELCHANGE*/)
      {
        bChanged = 1;
        SendMessage(hWnd, 0x0148 /*CB_GETLBTEXT*/, SendMessage(hWnd, 0x0147 /*CB_GETCURSEL*/, 0, 0), lpText);
        this.Val = parseInt(AkelPad.MemRead(lpText, 1 /*DT_UNICODE*/));
        SendMessage(this.Wnd[this.IDDEF].HWND, 241 /*BM_SETCHECK*/, this.Val == this.Def, 0);
      }
      else if (nCode == 8 /*CBN_CLOSEUP*/)
        bCloseCB = 0;
    }
    else if ((nID == this.IDDEF) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
    {
      bChanged = 1;
      this.Val = this.Def;
      this.SetVal();
    }
  }
};

var oMouseOptions =
{
  Def    :7,
  Wnd    :[],
  IDTXT  :2001,
  IDBUT1 :2002,
  IDBUT2 :2003,
  IDBUT3 :2004,
  IDBUT4 :2005,
  IDBUT5 :2006,
  IDBUT6 :2007,
  IDBUT7 :2008,
  IDBUT8 :2009,
  IDBUT9 :2010,
  IDBUT10:2011,
  IDDEF  :2012,
  IDSUM  :2013,

  Initialize:function()
  {
    if (! hEditWnd)
      SendMessage(hMainWnd, 273 /*WM_COMMAND*/, 4101 /*wParam=MAKEWPARAM(0,IDM_FILE_NEW)*/, 1 /*lParam=TRUE*/);

    this.Val = SendMessage(hMainWnd, 1223 /*AKD_GETFRAMEINFO*/, 87 /*FI_MOUSEOPTIONS*/, 0);
    this.Ini = this.Val;

    if (! hEditWnd)
      AkelPad.Command(4318 /*IDM_WINDOW_FRAMECLOSE*/);

    this.Wnd[this.IDTXT  ]={C:'STATIC', S:0x50000000, X:140, Y: 15, W:640, H:13,                                       Txt:'定义鼠标设置。根据下列成员的和来设置:',
                                                                                                                       Rus:''};
    this.Wnd[this.IDBUT1 ]={C:'BUTTON', S:0x50010003, X:140, Y: 35, W:640, H:16, Type:  1 /*MO_LEFTMARGINSELECTION*/,  Txt:'1 - GUI (左键点击空白处选定行)。',
                                                                                                                       Rus:''};
    this.Wnd[this.IDBUT2 ]={C:'BUTTON', S:0x50010003, X:140, Y: 55, W:640, H:16, Type:  2 /*MO_RICHEDITMOUSE*/,        Txt:'2 - GUI (使用 RichEdit 鼠标选择)。',
                                                                                                                       Rus:''};
    this.Wnd[this.IDBUT3 ]={C:'BUTTON', S:0x50010003, X:140, Y: 75, W:640, H:16, Type:  4 /*MO_MOUSEDRAGGING*/,        Txt:'4 - GUI (启用鼠标拖放)。',
                                                                                                                       Rus:''};
    this.Wnd[this.IDBUT4 ]={C:'BUTTON', S:0x50010003, X:140, Y: 95, W:640, H:16, Type:  8 /*MO_RCLICKMOVECARET*/,      Txt:'8 - GUI (右键点击移动插入点)。',
                                                                                                                       Rus:''};
    this.Wnd[this.IDBUT5 ]={C:'BUTTON', S:0x50010003, X:140, Y:115, W:640, H:16, Type: 16 /*MO_NONEWLINEMOUSESELECT*/, Txt:'16 - 三击和左边空白点击选择行的内容时不包含换行符。',
                                                                                                                       Rus:''};
    this.Wnd[this.IDBUT6 ]={C:'BUTTON', S:0x50010003, X:140, Y:135, W:640, H:16, Type: 32 /*MO_NOWHEELFONTCHANGE*/,    Txt:'32 - 禁用通过 Ctrl + 滚动鼠标滚轮来更改字号。',
                                                                                                                       Rus:''};
    this.Wnd[this.IDBUT7 ]={C:'BUTTON', S:0x50010003, X:140, Y:155, W:640, H:16, Type: 64 /*MO_SELUNWRAPLINE*/,        Txt:'64 - 使用鼠标选择行时则选定所有自动换行的行。',
                                                                                                                       Rus:''};
    this.Wnd[this.IDBUT8 ]={C:'BUTTON', S:0x50010003, X:140, Y:175, W:640, H:16, Type:128 /*MO_MBUTTONDOWNNOSCROLL*/,  Txt:'128 - 鼠标中键点击之后不滚动。',
                                                                                                                       Rus:''};
    this.Wnd[this.IDBUT9 ]={C:'BUTTON', S:0x50010003, X:140, Y:195, W:640, H:16, Type:256 /*MO_INVERTHORZWHEEL*/,      Txt:'256 - 反转鼠标水平滚轮。',
                                                                                                                       Rus:''};
    this.Wnd[this.IDBUT10]={C:'BUTTON', S:0x50010003, X:140, Y:215, W:640, H:16, Type:512 /*MO_INVERTVERTWHEEL*/,      Txt:'512 - 反转鼠标垂直滚轮。',
                                                                                                                       Rus:''};
    this.Wnd[this.IDDEF  ]={C:'BUTTON', S:0x50010003, X:140, Y:261, W:640, H:16,                                       Txt:'默认值: 1+2+4=7',
                                                                                                                       Rus:''};
    this.Wnd[this.IDSUM  ]={C:'STATIC', S:0x50000000, X:150, Y:235, W: 70, H:13};
  },

  Apply:function()
  {
    if (! hEditWnd)
      SendMessage(hMainWnd, 273 /*WM_COMMAND*/, 4101 /*wParam=MAKEWPARAM(0,IDM_FILE_NEW)*/, 1 /*lParam=TRUE*/);

    AkelPad.SetFrameInfo(0, 34 /*FIS_MOUSEOPTIONS*/, this.Val);

    if (! hEditWnd)
      AkelPad.Command(4318 /*IDM_WINDOW_FRAMECLOSE*/);
  },

  SetVal:function()
  {
    for (var i = this.IDBUT1; i <= this.IDBUT10; ++i)
      SendMessage(this.Wnd[i].HWND, 241 /*BM_SETCHECK*/, this.Val & this.Wnd[i].Type, 0);
    oSys.Call("User32::SetWindowTextW", this.Wnd[this.IDSUM].HWND, '=' + this.Val);
    SendMessage(this.Wnd[this.IDDEF].HWND, 241 /*BM_SETCHECK*/, this.Val == this.Def, 0);
  },

  Command:function(nID, nCode, hWnd)
  {
    if ((nID >= this.IDBUT1) && (nID <= this.IDBUT10))
    {
      bChanged = 1;
      this.Val = 0;
      for (var i = this.IDBUT1; i <= this.IDBUT10; ++i)
      {
        if (SendMessage(this.Wnd[i].HWND, 240 /*BM_GETCHECK*/, 0, 0))
          this.Val |= this.Wnd[i].Type;
      }
      this.SetVal();
    }
    else if ((nID == this.IDDEF) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
    {
      bChanged = 1;
      this.Val = this.Def;
      this.SetVal();
    }
  }
};

var oPaintOptions =
{
  Def   :0,
  Wnd   :[],
  IDTXT :2001,
  IDBUT1:2002,
  IDBUT2:2003,
  IDBUT3:2004,
  IDBUT4:2005,
  IDBUT5:2006,
  IDBUT6:2007,
  IDBUT7:2008,
  IDBUT8:2009,
  IDBUT9:2010,
  IDDEF :2011,
  IDSUM :2012,
  IDNOTE:2013,

  Initialize:function()
  {
    this.Val = SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 121 /*MI_PAINTOPTIONS*/, 0);
    this.Ini = this.Val;

    this.Wnd[this.IDTXT ]={C:'STATIC', S:0x50000000, X:140, Y: 15, W:640, H:13,                                            Txt:'定义一些文本绘制设置。根据下面数字之和来设置:',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT1]={C:'BUTTON', S:0x50012403, X:140, Y: 35, W:640, H:52, Type:   1 /*PAINT_PAINTGROUP*/,            Txt:'1 - 根据字符组来绘制文本 (默认值是根据字符)。使用这个标记，一些文本识别程序可以正常工作，打印机可以打得更快，但高亮显示符号和组合式 unicode 符号可能绘制有差异，编辑它们时可能变得不舒服。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT2]={C:'BUTTON', S:0x50010003, X:140, Y: 93, W:640, H:16, Type:   2 /*PAINT_NONEWLINEDRAW*/,         Txt:'2 - 禁止绘制选择的换行符为空格符。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT3]={C:'BUTTON', S:0x50010003, X:140, Y:113, W:640, H:16, Type:   4 /*PAINT_ENTIRENEWLINEDRAW*/,     Txt:'4 - 在文本区域右边边缘绘制选择的换行符。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT4]={C:'BUTTON', S:0x50010003, X:140, Y:133, W:640, H:16, Type:   8 /*PAINT_HIDESEL*/,               Txt:'8 - 当控件失去输入焦点时隐藏选定区域。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT5]={C:'BUTTON', S:0x50010003, X:140, Y:153, W:640, H:16, Type:  16 /*PAINT_NOMARKERAFTERLASTLINE*/, Txt:'16 - 在最后行之后禁用标尺线绘制。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT6]={C:'BUTTON', S:0x50010003, X:140, Y:173, W:640, H:16, Type: 128 /*PAINT_VSCROLLBYLINE*/,         Txt:'128 - 以行为单位的垂直滚动 (默认值为像素)。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT7]={C:'BUTTON', S:0x50010003, X:140, Y:193, W:640, H:16, Type: 256 /*PAINT_HIDENOSCROLL*/,          Txt:'256 - 仅当需要时显示滚动条。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT8]={C:'BUTTON', S:0x50010003, X:140, Y:213, W:640, H:16, Type: 512 /*PAINT_STATICEDGE*/,            Txt:'512 - 绘制窄的编辑窗口边框。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT9]={C:'BUTTON', S:0x50010003, X:140, Y:233, W:640, H:16, Type:1024 /*PAINT_NOEDGE*/,                Txt:'1024 - 绘制无编辑窗口边框。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDDEF ]={C:'BUTTON', S:0x50010003, X:140, Y:279, W:640, H:16,                                            Txt:'默认值: 0',
                                                                                                                           Rus:''};
    this.Wnd[this.IDSUM ]={C:'STATIC', S:0x50000000, X:150, Y:253, W: 70, H:13};
    this.Wnd[this.IDNOTE]={C:'STATIC', S:0x50000000, X:140, Y:305, W:640, H:13,                                            Txt:oFixedCharWidth.Wnd[oFixedCharWidth.IDNOTE].Txt,
                                                                                                                           Rus:oFixedCharWidth.Wnd[oFixedCharWidth.IDNOTE].Rus};
  },

  Apply:function()
  {
    SendMessage(hMainWnd, 1219 /*AKD_SETMAININFO*/, 121 /*MIS_PAINTOPTIONS*/, this.Val);
  },

  SetVal:function()
  {
    for (var i = this.IDBUT1; i <= this.IDBUT9; ++i)
      SendMessage(this.Wnd[i].HWND, 241 /*BM_SETCHECK*/, this.Val & this.Wnd[i].Type, 0);
    oSys.Call("User32::SetWindowTextW", this.Wnd[this.IDSUM].HWND, '=' + this.Val);
    SendMessage(this.Wnd[this.IDDEF].HWND, 241 /*BM_SETCHECK*/, this.Val == this.Def, 0);
  },

  Command:function(nID, nCode, hWnd)
  {
    if ((nID >= this.IDBUT1) && (nID <= this.IDBUT9))
    {
      bChanged = 1;
      this.Val = 0;
      for (var i = this.IDBUT1; i <= this.IDBUT9; ++i)
      {
        if (SendMessage(this.Wnd[i].HWND, 240 /*BM_GETCHECK*/, 0, 0))
          this.Val |= this.Wnd[i].Type;
      }
      this.SetVal();
    }
    else if ((nID == this.IDDEF) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
    {
      bChanged = 1;
      this.Val = this.Def;
      this.SetVal();
    }
  }
};

var oRichEditClass =
{
  Def   :0,
  Wnd   :[],
  IDTXT :2001,
  IDBUT1:2002,
  IDBUT2:2003,
  IDDEF :2004,
  IDNOTE:2005,

  Initialize:function()
  {
    this.Val = SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 125 /*MI_RICHEDITCLASS*/, 0);
    this.Ini = this.Val;

    this.Wnd[this.IDTXT ]={C:'STATIC', S:0x50000000, X:140, Y: 15, W:640, H:13, Txt:'定义编辑控件类名:',
                                                                                Rus:''};
    this.Wnd[this.IDBUT1]={C:'BUTTON', S:0x50010009, X:140, Y: 35, W:640, H:16, Txt:'0 - "AkelEdit".'};
    this.Wnd[this.IDBUT2]={C:'BUTTON', S:0x50010009, X:140, Y: 55, W:640, H:16, Txt:'1 - "RichEdit20".'};
    this.Wnd[this.IDDEF ]={C:'BUTTON', S:0x50010003, X:140, Y: 81, W:640, H:16, Txt:'默认值: 0',
                                                                                Rus:''};
    this.Wnd[this.IDNOTE]={C:'STATIC', S:0x50000000, X:140, Y:110, W:640, H:13, Txt:oFixedCharWidth.Wnd[oFixedCharWidth.IDNOTE].Txt,
                                                                                Rus:oFixedCharWidth.Wnd[oFixedCharWidth.IDNOTE].Rus};
  },

  Apply:function()
  {
    SendMessage(hMainWnd, 1219 /*AKD_SETMAININFO*/, 125 /*MIS_RICHEDITCLASS*/, this.Val);
  },

  SetVal:function()
  {
    for (var i = this.IDBUT1; i <= this.IDBUT2; ++i)
      SendMessage(this.Wnd[i].HWND, 241 /*BM_SETCHECK*/, this.Val == i - this.IDBUT1, 0);
    SendMessage(this.Wnd[this.IDDEF].HWND, 241 /*BM_SETCHECK*/, this.Val == this.Def, 0);
  },

  Command:function(nID, nCode, hWnd)
  {
    if ((nID >= this.IDBUT1) && (nID <= this.IDBUT2))
    {
      bChanged = 1;
      this.Val = nID - this.IDBUT1;
      this.SetVal();
      SendMessage(aDlg[IDENGB + nLang].HWND, 241 /*BM_SETCHECK*/, 1, 0);
    }
    else if ((nID == this.IDDEF) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
    {
      bChanged = 1;
      this.Val = this.Def;
      this.SetVal();
    }
    else if ((nID == IDENGB) ||(nID == IDRUSB))
      this.SetVal();
  }
};

var oShowModify =
{
  Def    :9,
  ShowAll:15,
  Wnd    :[],
  IDTXT  :2001,
  IDBUT1 :2002,
  IDBUT2 :2003,
  IDBUT3 :2004,
  IDBUT4 :2005,
  IDDEF  :2006,
  IDALL  :2007,
  IDSUM  :2008,

  Initialize:function()
  {
    this.Val = SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 110 /*MI_SHOWMODIFY*/, 0);
    this.Ini = this.Val;

    this.Wnd[this.IDTXT ]={C:'STATIC', S:0x50000000, X:140, Y: 15, W:640, H:13,                               Txt:'决定 文档已更改 状态将会在哪里显示。根据下列成员的和来设置:',
                                                                                                              Rus:''};
    this.Wnd[this.IDBUT1]={C:'BUTTON', S:0x50010003, X:140, Y: 35, W:640, H:16, Type:1 /*SM_STATUSBAR*/,      Txt:'1 - 在状态栏显示 "已修改"。',
                                                                                                              Rus:''};
    this.Wnd[this.IDBUT2]={C:'BUTTON', S:0x50010003, X:140, Y: 55, W:640, H:16, Type:2 /*SM_MAINTITLE_SDI*/,  Txt:'2 - 在主窗口标题栏 (SDI) 显示星号 *。',
                                                                                                              Rus:''};
    this.Wnd[this.IDBUT3]={C:'BUTTON', S:0x50010003, X:140, Y: 75, W:640, H:16, Type:4 /*SM_FRAMETITLE_MDI*/, Txt:'4 - 在主窗口和帧窗口的标题 (MDI/PMDI) 显示星号 *。',
                                                                                                              Rus:''};
    this.Wnd[this.IDBUT4]={C:'BUTTON', S:0x50010003, X:140, Y: 95, W:640, H:16, Type:8 /*SM_TABTITLE_MDI*/,   Txt:'8 - 在标签按钮名称 (MDI/PMDI) 显示星号 *。',
                                                                                                              Rus:''};
    this.Wnd[this.IDDEF ]={C:'BUTTON', S:0x50010003, X:140, Y:141, W:640, H:16,                               Txt:'默认值: 1+8=9',
                                                                                                              Rus:''};
    this.Wnd[this.IDALL ]={C:'BUTTON', S:0x50010003, X:140, Y:161, W:640, H:16,                               Txt:'全部显示: 1+2+4+8=15',
                                                                                                              Rus:''};
    this.Wnd[this.IDSUM ]={C:'STATIC', S:0x50000000, X:150, Y:115, W: 70, H:13};
  },

  Apply:function()
  {
    SendMessage(hMainWnd, 1219 /*AKD_SETMAININFO*/, 110 /*MIS_SHOWMODIFY*/, this.Val);
  },

  SetVal:function()
  {
    for (var i = this.IDBUT1; i <= this.IDBUT4; ++i)
      SendMessage(this.Wnd[i].HWND, 241 /*BM_SETCHECK*/, this.Val & this.Wnd[i].Type, 0);
    oSys.Call("User32::SetWindowTextW", this.Wnd[this.IDSUM].HWND, '=' + this.Val);
    SendMessage(this.Wnd[this.IDDEF].HWND, 241 /*BM_SETCHECK*/, this.Val == this.Def, 0);
    SendMessage(this.Wnd[this.IDALL].HWND, 241 /*BM_SETCHECK*/, this.Val == this.ShowAll, 0);
  },

  Command:function(nID, nCode, hWnd)
  {
    if ((nID >= this.IDBUT1) && (nID <= this.IDBUT4))
    {
      bChanged = 1;
      this.Val = 0;
      for (var i = this.IDBUT1; i <= this.IDBUT4; ++i)
      {
        if (SendMessage(this.Wnd[i].HWND, 240 /*BM_GETCHECK*/, 0, 0))
          this.Val |= this.Wnd[i].Type;
      }
      this.SetVal();
    }
    else if (((nID == this.IDDEF) || (nID == this.IDALL)) && (SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0)))
    {
      bChanged = 1;
      this.Val = (nID == this.IDDEF) ? this.Def : this.ShowAll;
      this.SetVal();
    }
  }
};

var oSingleOpenProgram =
{
  Def   :1,
  Wnd   :[],
  IDTXT :2001,
  IDBUT1:2002,
  IDBUT2:2003,
  IDDEF :2004,
  IDSUM :2005,

  Initialize:function()
  {
    this.Val = SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 153 /*MI_SINGLEOPENPROGRAM*/, 0);
    this.Ini = this.Val;

    this.Wnd[this.IDTXT ]={C:'STATIC', S:0x50000000, X:140, Y: 15, W:640, H:13,                         Txt:'MDI/PMDI模式下的选项“同一程序只打开一次”。根据下面数字之和来设置:',
                                                                                                        Rus:''};
    this.Wnd[this.IDBUT1]={C:'BUTTON', S:0x50010003, X:140, Y: 35, W:640, H:16, Type:1 /*SOP_ON*/,      Txt:'1 -  (选项为“开”)。',
                                                                                                        Rus:''};
    this.Wnd[this.IDBUT2]={C:'BUTTON', S:0x50010003, X:140, Y: 55, W:640, H:16, Type:2 /*SOP_SAMEEXE*/, Txt:'2 - 选项仅适用于相同的 exe 文件。需要管理员权限来运行 (UAC)。',
                                                                                                        Rus:''};
    this.Wnd[this.IDDEF ]={C:'BUTTON', S:0x50010003, X:140, Y:101, W:640, H:16,                         Txt:'默认值: 1',
                                                                                                        Rus:''};
    this.Wnd[this.IDSUM ]={C:'STATIC', S:0x50000000, X:150, Y: 75, W: 70, H:13};
  },

  Apply:function()
  {
    SendMessage(hMainWnd, 1219 /*AKD_SETMAININFO*/, 153 /*MIS_SINGLEOPENPROGRAM*/, this.Val);
  },

  SetVal:function()
  {
    for (var i = this.IDBUT1; i <= this.IDBUT2; ++i)
      SendMessage(this.Wnd[i].HWND, 241 /*BM_SETCHECK*/, this.Val & this.Wnd[i].Type, 0);
    oSys.Call("User32::SetWindowTextW", this.Wnd[this.IDSUM].HWND, '=' + this.Val);
    SendMessage(this.Wnd[this.IDDEF].HWND, 241 /*BM_SETCHECK*/, this.Val == this.Def, 0);
  },

  Command:function(nID, nCode, hWnd)
  {
    if ((nID >= this.IDBUT1) && (nID <= this.IDBUT2))
    {
      bChanged = 1;
      this.Val = 0;
      for (var i = this.IDBUT1; i <= this.IDBUT2; ++i)
      {
        if (SendMessage(this.Wnd[i].HWND, 240 /*BM_GETCHECK*/, 0, 0))
          this.Val |= this.Wnd[i].Type;
      }
      this.SetVal();
    }
    else if ((nID == this.IDDEF) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
    {
      bChanged = 1;
      this.Val = this.Def;
      this.SetVal();
    }
  }
};

var oStatusPosType =
{
  Def   :0,
  Wnd   :[],
  IDTXT :2001,
  IDBUT1:2002,
  IDBUT2:2003,
  IDDEF :2004,
  IDSUM :2005,

  Initialize:function()
  {
    this.Val = SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 111 /*MI_STATUSPOSTYPE*/, 0);
    this.Ini = this.Val;

    this.Wnd[this.IDTXT ]={C:'STATIC', S:0x50000000, X:140, Y: 15, W:640, H:13,                          Txt:'定义状态栏统计将会如何显示。根据下面成员的和来设置:',
                                                                                                         Rus:''};
    this.Wnd[this.IDBUT1]={C:'BUTTON', S:0x50010003, X:140, Y: 35, W:640, H:16, Type:1 /*SPT_COLUMN*/,   Txt:'1 - "行号:列号". 默认值："行号:符号"。',
                                                                                                         Rus:''};
    this.Wnd[this.IDBUT2]={C:'BUTTON', S:0x50010003, X:140, Y: 55, W:640, H:16, Type:2 /*SPT_LINEWRAP*/, Txt:'2 - 自动换行数。默认值：非自动换行数。',
                                                                                                         Rus:''};
    this.Wnd[this.IDDEF ]={C:'BUTTON', S:0x50010003, X:140, Y:101, W:640, H:16,                          Txt:'默认值: 0',
                                                                                                         Rus:''};
    this.Wnd[this.IDSUM ]={C:'STATIC', S:0x50000000, X:150, Y: 75, W: 70, H:13};
  },

  Apply:function()
  {
    SendMessage(hMainWnd, 1219 /*AKD_SETMAININFO*/, 111 /*MIS_STATUSPOSTYPE*/, this.Val);
  },

  SetVal:function()
  {
    for (var i = this.IDBUT1; i <= this.IDBUT2; ++i)
      SendMessage(this.Wnd[i].HWND, 241 /*BM_SETCHECK*/, this.Val & this.Wnd[i].Type, 0);
    oSys.Call("User32::SetWindowTextW", this.Wnd[this.IDSUM].HWND, '=' + this.Val);
    SendMessage(this.Wnd[this.IDDEF].HWND, 241 /*BM_SETCHECK*/, this.Val == this.Def, 0);
  },

  Command:function(nID, nCode, hWnd)
  {
    if ((nID >= this.IDBUT1) && (nID <= this.IDBUT2))
    {
      bChanged = 1;
      this.Val = 0;
      for (var i = this.IDBUT1; i <= this.IDBUT2; ++i)
      {
        if (SendMessage(this.Wnd[i].HWND, 240 /*BM_GETCHECK*/, 0, 0))
          this.Val |= this.Wnd[i].Type;
      }
      this.SetVal();
    }
    else if ((nID == this.IDDEF) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
    {
      bChanged = 1;
      this.Val = this.Def;
      this.SetVal();
    }
  }
};

var oStatusUserFormat =
{
  Val  :'',
  Def  :'',
  Wnd  :[],
  IDTXT:2001,
  IDVAL:2002,
  IDDEF:2003,
  IDED :2004,

  Initialize:function()
  {
    if (SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 112 /*MI_STATUSUSERFORMAT*/, lpText))
      this.Val = AkelPad.MemRead(lpText, 1 /*DT_UNICODE*/).replace(/\t/g, '\\t');

    this.Ini = this.Val;

    this.Wnd[this.IDTXT]={C:'STATIC',    S:0x50000000, X:140, Y:15, W:640, H: 13, Txt:'定义用户状态栏格式:',
                                                                                  Rus:''};
    this.Wnd[this.IDVAL]={C:'COMBOBOX',  S:0x50010042, X:140, Y:35, W:640, H: 21};
    this.Wnd[this.IDDEF]={C:'BUTTON',    S:0x50010003, X:140, Y:66, W:640, H: 16, Txt:'默认值: "" - 未定义格式，不显示附加的状态栏区段。',
                                                                                  Rus:''};
    this.Wnd[this.IDED ]={C:'AkelEditW', S:0x50310804, X:140, Y:91, W:640, H:383, Txt:'%[width]\t添加状态栏分隔符。\n%Ch\t\t文件代码页中当前字符的小写 16 进制码。\n%CH\t\t文件代码页中当前字符的大写 16 进制码。\n%ch\t\t当前字符的小写 16 进制码。\n%cH\t\t当前字符的大写 16 进制码。\n%cd\t\t当前字符的 10 进制码。\n%cl\t\t当前字符字母。\n%or\t\t符号数偏移量。任何换行符都被视为一个符号 (RichEdit)\n%ob\t\t符号数偏移量。换行符: \\r\\r\\n - 三个符号，\\r\\n - 两个符号，\\r - 一个符号，\\n - 一个符号。\n%al\t\t文档中的行数。\n%ar\t\t文档中的符号数 (RichEdit)。\n%lb\t\t选定行的开始行号。\n%le\t\t选定行的结束行号。\n%ls\t\t选定范围中的行数。\n%f\t\t字体大小。\n%t\t\t制表符大小。\n%m\t\t标尺线位置。\n%cap[文字]\t当 CapsLock 为开时要显示的文字。\n%num[文字]\t当 NumLock 为开时要显示的文字。\n%se[文字]\t当搜索时到达文档的末尾时要显示的文字。\n%r\t\t“全部替换”之后的替换数。\n%dc\t\t所有文档数 (MDI/PMDI)。\n%dm\t\t已修改的文档数 (MDI/PMDI)。\n%ds\t\t未修改的文档数 (MDI/PMDI)。\n%di\t\t活动文档索引 (MDI/PMDI)。\n%%\t\t% 符号。\n制表符\t\t一个制表符文本居中，第二个制表符右对齐。\n\n例: "符号:0x%ch%[85]字号:%f%[48]Tab:%t%[38]标尺线:%m%[60]文档:%dm*/%dc"',
                                                                                  Rus:''};
  },

  Apply:function()
  {
    SendMessage(hMainWnd, 1219 /*AKD_SETMAININFO*/, 112 /*MIS_STATUSUSERFORMAT*/, this.Val.replace(/\\t/g, '\t'));
  },

  SetVal:function()
  {
    oSys.Call("User32::SetWindowTextW", this.Wnd[this.IDVAL].HWND, this.Val);
    SendMessage(this.Wnd[this.IDDEF].HWND, 241 /*BM_SETCHECK*/, this.Val == this.Def, 0);
  },

  Command:function(nID, nCode, hWnd)
  {
    if (nID == this.IDVAL)
      ProcessCB(hWnd, nCode);
    else if ((nID == this.IDDEF) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
    {
      bChanged = 1;
      this.Val = this.Def;
      this.SetVal();
    }
  }
};

var oTabNameFind =
{
  Val   :'',
  Def   :'',
  Wnd   :[],
  IDTXT :2001,
  IDVAL :2002,
  IDDEF :2003,
  IDED  :2004,
  IDNOTE:2005,
  IDLINK:2006,

  Initialize:function()
  {
    if (SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 133 /*MI_TABNAMEFIND*/, lpText))
      this.Val = AkelPad.MemRead(lpText, 1 /*DT_UNICODE*/);

    this.Ini = this.Val;

    this.Wnd[this.IDTXT ]={C:'STATIC',    S:0x50000000, X:140, Y: 15, W:640, H:26, Txt:'为 MDI/PMDI 模式下的标签页名称定义正则表达式搜索模式。\n如果没有搜索结果，文件名称显示无变化。与 TabNameRep 配合使用。',
                                                                                   Rus:''};
    this.Wnd[this.IDVAL ]={C:'COMBOBOX',  S:0x50010042, X:140, Y: 48, W:640, H:21};
    this.Wnd[this.IDDEF ]={C:'BUTTON',    S:0x50010003, X:140, Y: 79, W:640, H:16, Txt:'默认值: ""',
                                                                                   Rus:''};
    this.Wnd[this.IDED  ]={C:'AkelEditW', S:0x50010800, X:140, Y:104, W:640, H:21, Txt:'例: (.{20}).{3,}(?:\\.([^.]*))?',
                                                                                   Rus:''};
    this.Wnd[this.IDNOTE]={C:'STATIC',    S:0x50000000, X:140, Y:138, W:640, H:13, Txt:oFixedCharWidth.Wnd[oFixedCharWidth.IDNOTE].Txt,
                                                                                   Rus:oFixedCharWidth.Wnd[oFixedCharWidth.IDNOTE].Rus};
    this.Wnd[this.IDLINK]={C:'SysLink',   S:0x50000000, X:140, Y:164, W:640, H:13, Txt:'<a>TabNameRep</a>'};
  },

  Apply:function()
  {
    SendMessage(hMainWnd, 1219 /*AKD_SETMAININFO*/, 133 /*MIS_TABNAMEFIND*/, this.Val);
  },

  SetVal:function()
  {
    oSys.Call("User32::SetWindowTextW", this.Wnd[this.IDVAL].HWND, this.Val);
    SendMessage(this.Wnd[this.IDDEF].HWND, 241 /*BM_SETCHECK*/, this.Val == this.Def, 0);
  },

  Notify:function(wParam, lParam)
  {
    if ((wParam == this.IDLINK) && (AkelPad.MemRead(_PtrAdd(lParam, _X64 ? 16 : 8), 3 /*DT_DWORD*/) == -2 /*NM_CLICK*/))
    {
      SetCurSelLV(FindInArray(aParam, "TabNameRep"));
      oSys.Call("User32::SetFocus", oTabNameRep.Wnd[oTabNameRep.IDVAL].HWND);
    }
  },

  Command:function(nID, nCode, hWnd)
  {
    if (nID == this.IDVAL)
      ProcessCB(hWnd, nCode);
    else if ((nID == this.IDDEF) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
    {
      bChanged = 1;
      this.Val = this.Def;
      this.SetVal();
    }
  }
};

var oTabNameRep =
{
  Val   :'',
  Def   :'',
  Wnd   :[],
  IDTXT :2001,
  IDVAL :2002,
  IDDEF :2003,
  IDED  :2004,
  IDNOTE:2005,
  IDLINK:2006,

  Initialize:function()
  {
    if (SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 134 /*MI_TABNAMEREP*/, lpText))
      this.Val = AkelPad.MemRead(lpText, 1 /*DT_UNICODE*/);

    this.Ini = this.Val;

    this.Wnd[this.IDTXT ]={C:'STATIC',    S:0x50000000, X:140, Y: 15, W:640, H:26, Txt:'为 MDI/PMDI 模式下的标签页名称定义正则表达式替换模式。\n与 TabNameFind 配合使用。',
                                                                                   Rus:''};
    this.Wnd[this.IDVAL ]={C:'COMBOBOX',  S:0x50010042, X:140, Y: 48, W:640, H:21};
    this.Wnd[this.IDDEF ]={C:'BUTTON',    S:0x50010003, X:140, Y: 79, W:640, H:16, Txt:'默认值: ""',
                                                                                   Rus:''};
    this.Wnd[this.IDED  ]={C:'AkelEditW', S:0x50010800, X:140, Y:104, W:640, H:21, Txt:'例: \\1...\\2',
                                                                                   Rus:''};
    this.Wnd[this.IDNOTE]={C:'STATIC',    S:0x50000000, X:140, Y:138, W:640, H:13, Txt:oFixedCharWidth.Wnd[oFixedCharWidth.IDNOTE].Txt,
                                                                                   Rus:oFixedCharWidth.Wnd[oFixedCharWidth.IDNOTE].Rus};
    this.Wnd[this.IDLINK]={C:'SysLink',   S:0x50000000, X:140, Y:164, W:640, H:13, Txt:'<a>TabNameFind</a>'};
  },

  Apply:function()
  {
    SendMessage(hMainWnd, 1219 /*AKD_SETMAININFO*/, 134 /*MIS_TABNAMEREP*/, this.Val);
  },

  SetVal:function()
  {
    oSys.Call("User32::SetWindowTextW", this.Wnd[this.IDVAL].HWND, this.Val);
    SendMessage(this.Wnd[this.IDDEF].HWND, 241 /*BM_SETCHECK*/, this.Val == this.Def, 0);
  },

  Notify:function(wParam, lParam)
  {
    if ((wParam == this.IDLINK) && (AkelPad.MemRead(_PtrAdd(lParam, _X64 ? 16 : 8), 3 /*DT_DWORD*/) == -2 /*NM_CLICK*/))
    {
      SetCurSelLV(FindInArray(aParam, "TabNameFind"));
      oSys.Call("User32::SetFocus", oTabNameFind.Wnd[oTabNameFind.IDVAL].HWND);
    }
  },

  Command:function(nID, nCode, hWnd)
  {
    if (nID == this.IDVAL)
      ProcessCB(hWnd, nCode);
    else if ((nID == this.IDDEF) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
    {
      bChanged = 1;
      this.Val = this.Def;
      this.SetVal();
    }
  }
};

var oTabOptionsMDI =
{
  Def    :131330,
  Wnd    :[],
  IDTXT  :2001,
  IDBUT1 :2002,
  IDBUT2 :2003,
  IDBUT3 :2004,
  IDBUT4 :2005,
  IDBUT5 :2006,
  IDBUT6 :2007,
  IDBUT7 :2008,
  IDBUT8 :2009,
  IDBUT9 :2010,
  IDBUT10:2011,
  IDBUT11:2012,
  IDBUT12:2013,
  IDBUT13:2014,
  IDDEF  :2015,
  IDSUM  :2016,

  Initialize:function()
  {
    this.Val = SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 157 /*MI_TABOPTIONSMDI*/, 0);
    this.Ini = this.Val;

    this.Wnd[this.IDTXT  ]={C:'STATIC', S:0x50000000, X:140, Y: 15, W:640, H:13,                                           Txt:'定义 MDI/PMDI 模式下的标签设置。根据下面成员的和来设置:',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT1 ]={C:'BUTTON', S:0x50010003, X:140, Y: 35, W:640, H:16, Type:1       /*TAB_VIEW_NONE*/,           Txt:'1 - GUI (隐藏标签)。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT2 ]={C:'BUTTON', S:0x50010003, X:140, Y: 55, W:640, H:16, Type:2       /*TAB_VIEW_TOP*/,            Txt:'2 - GUI (标签显示在编辑窗口之上)。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT3 ]={C:'BUTTON', S:0x50010003, X:140, Y: 75, W:640, H:16, Type:4       /*TAB_VIEW_BOTTOM*/,         Txt:'4 - GUI (标签显示在编辑窗口之下)。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT4 ]={C:'BUTTON', S:0x50010003, X:140, Y: 95, W:640, H:16, Type:256     /*TAB_TYPE_STANDARD*/,       Txt:'256 - GUI (标签样式 - 标准)。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT5 ]={C:'BUTTON', S:0x50010003, X:140, Y:115, W:640, H:16, Type:512     /*TAB_TYPE_BUTTONS*/,        Txt:'512 - GUI (标签样式 - 按钮)。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT6 ]={C:'BUTTON', S:0x50010003, X:140, Y:135, W:640, H:16, Type:1024    /*TAB_TYPE_FLATBUTTONS*/,    Txt:'1024 - GUI (标签样式 - 平面按钮)。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT7 ]={C:'BUTTON', S:0x50010003, X:140, Y:155, W:640, H:16, Type:65536   /*TAB_SWITCH_NEXTPREV*/,     Txt:'65536 - GUI (热键传递焦点为 下个-上个)。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT8 ]={C:'BUTTON', S:0x50010003, X:140, Y:175, W:640, H:16, Type:131072  /*TAB_SWITCH_RIGHTLEFT*/,    Txt:'131072 - GUI (热键传递焦点为 右-左)。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT9 ]={C:'BUTTON', S:0x50010003, X:140, Y:195, W:640, H:16, Type:524288  /*TAB_ADD_AFTERCURRENT*/,    Txt:'524288 - 在当前标签之后创建新标签。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT10]={C:'BUTTON', S:0x50010003, X:140, Y:215, W:640, H:16, Type:1048576 /*TAB_NOADD_LBUTTONDBLCLK*/, Txt:'1048576 - 禁用鼠标左键在标签栏双击时创建新的标签。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT11]={C:'BUTTON', S:0x50010003, X:140, Y:235, W:640, H:16, Type:2097152 /*TAB_NOADD_MBUTTONDOWN*/,   Txt:'2097152 - 禁用鼠标中键在标签栏点击时创建新的标签。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT12]={C:'BUTTON', S:0x50010003, X:140, Y:255, W:640, H:16, Type:4194304 /*TAB_NODEL_LBUTTONDBLCLK*/, Txt:'4194304 - 禁用鼠标左键在标签上双击时关闭标签。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDBUT13]={C:'BUTTON', S:0x50010003, X:140, Y:275, W:640, H:16, Type:8388608 /*TAB_NODEL_MBUTTONDOWN*/,   Txt:'8388608 - 禁用鼠标左键在标签上点击时关闭标签。',
                                                                                                                           Rus:''};
    this.Wnd[this.IDDEF  ]={C:'BUTTON', S:0x50010003, X:140, Y:321, W:640, H:16,                                           Txt:'默认值: 2+256+131072=131330',
                                                                                                                           Rus:''};
    this.Wnd[this.IDSUM  ]={C:'STATIC', S:0x50000000, X:150, Y:295, W: 70, H:13};
  },

  Apply:function()
  {
    SendMessage(hMainWnd, 1219 /*AKD_SETMAININFO*/, 157 /*MIS_TABOPTIONSMDI*/, this.Val);
  },

  SetVal:function()
  {
    for (var i = this.IDBUT1; i <= this.IDBUT13; ++i)
      SendMessage(this.Wnd[i].HWND, 241 /*BM_SETCHECK*/, this.Val & this.Wnd[i].Type, 0);
    oSys.Call("User32::SetWindowTextW", this.Wnd[this.IDSUM].HWND, '=' + this.Val);
    SendMessage(this.Wnd[this.IDDEF].HWND, 241 /*BM_SETCHECK*/, this.Val == this.Def, 0);
  },

  Command:function(nID, nCode, hWnd)
  {
    if ((nID >= this.IDBUT1) && (nID <= this.IDBUT13))
    {
      if (nID == this.IDBUT1)
      {
        if (SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
        {
          SendMessage(this.Wnd[this.IDBUT2].HWND, 241 /*BM_SETCHECK*/, 0, 0);
          SendMessage(this.Wnd[this.IDBUT3].HWND, 241 /*BM_SETCHECK*/, 0, 0);
        }
        else
          SendMessage(this.Wnd[this.IDBUT2].HWND, 241 /*BM_SETCHECK*/, 1, 0);
      }
      else if (nID == this.IDBUT2)
      {
        if (SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
        {
          SendMessage(this.Wnd[this.IDBUT1].HWND, 241 /*BM_SETCHECK*/, 0, 0);
          SendMessage(this.Wnd[this.IDBUT3].HWND, 241 /*BM_SETCHECK*/, 0, 0);
        }
        else
          SendMessage(this.Wnd[this.IDBUT3].HWND, 241 /*BM_SETCHECK*/, 1, 0);
      }
      else if (nID == this.IDBUT3)
      {
        if (SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
        {
          SendMessage(this.Wnd[this.IDBUT1].HWND, 241 /*BM_SETCHECK*/, 0, 0);
          SendMessage(this.Wnd[this.IDBUT2].HWND, 241 /*BM_SETCHECK*/, 0, 0);
        }
        else
          SendMessage(this.Wnd[this.IDBUT2].HWND, 241 /*BM_SETCHECK*/, 1, 0);
      }

      else if (nID == this.IDBUT4)
      {
        if (SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
        {
          SendMessage(this.Wnd[this.IDBUT5].HWND, 241 /*BM_SETCHECK*/, 0, 0);
          SendMessage(this.Wnd[this.IDBUT6].HWND, 241 /*BM_SETCHECK*/, 0, 0);
        }
        else
          SendMessage(this.Wnd[this.IDBUT5].HWND, 241 /*BM_SETCHECK*/, 1, 0);
      }
      else if (nID == this.IDBUT5)
      {
        if (SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
        {
          SendMessage(this.Wnd[this.IDBUT4].HWND, 241 /*BM_SETCHECK*/, 0, 0);
          SendMessage(this.Wnd[this.IDBUT6].HWND, 241 /*BM_SETCHECK*/, 0, 0);
        }
        else
          SendMessage(this.Wnd[this.IDBUT6].HWND, 241 /*BM_SETCHECK*/, 1, 0);
      }
      else if (nID == this.IDBUT6)
      {
        if (SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
        {
          SendMessage(this.Wnd[this.IDBUT4].HWND, 241 /*BM_SETCHECK*/, 0, 0);
          SendMessage(this.Wnd[this.IDBUT5].HWND, 241 /*BM_SETCHECK*/, 0, 0);
        }
        else
          SendMessage(this.Wnd[this.IDBUT5].HWND, 241 /*BM_SETCHECK*/, 1, 0);
      }
      else if (nID == this.IDBUT7)
        SendMessage(this.Wnd[this.IDBUT8].HWND, 241 /*BM_SETCHECK*/, (! SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0)), 0);
      else if (nID == this.IDBUT8)
        SendMessage(this.Wnd[this.IDBUT7].HWND, 241 /*BM_SETCHECK*/, (! SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0)), 0);

      bChanged = 1;
      this.Val = 0;

      for (var i = this.IDBUT1; i <= this.IDBUT13; ++i)
      {
        if (SendMessage(this.Wnd[i].HWND, 240 /*BM_GETCHECK*/, 0, 0))
          this.Val |= this.Wnd[i].Type;
      }
      this.SetVal();
    }
    else if ((nID == this.IDDEF) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
    {
      bChanged = 1;
      this.Val = this.Def;
      this.SetVal();
    }
  }
};

var oUrlCommand =
{
  Val  :'',
  Def  :'',
  Wnd  :[],
  IDTXT:2001,
  IDVAL:2002,
  IDDEF:2003,
  IDED :2004,

  Initialize:function()
  {
    if (SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 132 /*MI_URLCOMMAND*/, lpText))
      this.Val = AkelPad.MemRead(lpText, 1 /*DT_UNICODE*/);

    this.Ini = this.Val;

    this.Wnd[this.IDTXT]={C:'STATIC',    S:0x50000000, X:140, Y:15, W:640, H:13, Txt:'为超链接定义命令。变量 %u 表示超链接文本:',
                                                                                 Rus:''};
    this.Wnd[this.IDVAL]={C:'COMBOBOX',  S:0x50010042, X:140, Y:35, W:640, H:21};
    this.Wnd[this.IDDEF]={C:'BUTTON',    S:0x50010003, X:140, Y:66, W:640, H:16, Txt:'默认值: "" - 超链接由操作系统打开。',
                                                                                 Rus:''};
    this.Wnd[this.IDED ]={C:'AkelEditW', S:0x50010800, X:140, Y:91, W:640, H:21, Txt:'例: Exec(`"%ProgramFiles%\\Mozilla Firefox\\firefox.exe" "%u"`)',
                                                                                 Rus:''};
  },

  Apply:function()
  {
    SendMessage(hMainWnd, 1219 /*AKD_SETMAININFO*/, 132 /*MIS_URLCOMMAND*/, this.Val);
  },

  SetVal:function()
  {
    oSys.Call("User32::SetWindowTextW", this.Wnd[this.IDVAL].HWND, this.Val);
    SendMessage(this.Wnd[this.IDDEF].HWND, 241 /*BM_SETCHECK*/, this.Val == this.Def, 0);
  },

  Command:function(nID, nCode, hWnd)
  {
    if (nID == this.IDVAL)
      ProcessCB(hWnd, nCode);
    else if ((nID == this.IDDEF) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
    {
      bChanged = 1;
      this.Val = this.Def;
      this.SetVal();
    }
  }
};

var oWordBreak =
{
  Def     :9,
  DefAE   :111,
  Wnd     :[],
  IDTXT   :2001,
  IDBUT1  :2002,
  IDBUT2  :2003,
  IDBUT3  :2004,
  IDBUT4  :2005,
  IDBUT5  :2006,
  IDBUT6  :2007,
  IDBUT7  :2008,
  IDBUT8  :2009,
  IDBUT9  :2010,
  IDDEF   :2011,
  IDDEFAE :2012,
  IDENABLE:2013,
  IDSUM   :2014,
  IDNOTE  :2015,

  Initialize:function()
  {
    if (! hEditWnd)
      SendMessage(hMainWnd, 273 /*WM_COMMAND*/, 4101 /*wParam=MAKEWPARAM(0,IDM_FILE_NEW)*/, 1 /*lParam=TRUE*/);

    this.Val       = SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 117 /*MI_WORDBREAKCUSTOM*/, 0);
    this.Ini       = this.Val;
    this.Enable    = SendMessage(hMainWnd, 1223 /*AKD_GETFRAMEINFO*/, 107 /*FI_WORDDELIMITERSENABLE*/, 0);
    this.EnableIni = this.Enable;

    if (! hEditWnd)
      AkelPad.Command(4318 /*IDM_WINDOW_FRAMECLOSE*/);

    this.Wnd[this.IDTXT   ]={C:'STATIC', S:0x50000000, X:140, Y: 15, W:640, H:13,                                   Txt:'定义插入点在按 Ctrl+左键/Ctrl+右键 时如何移动。根据下列成员的和来设置:',
                                                                                                                    Rus:''};
    this.Wnd[this.IDBUT1  ]={C:'BUTTON', S:0x50010003, X:140, Y: 35, W:640, H:16, Type:  1 /*AEWB_LEFTWORDSTART*/,  Txt:'1 - 当找到单词开始位置时停止左移。',
                                                                                                                    Rus:''};
    this.Wnd[this.IDBUT2  ]={C:'BUTTON', S:0x50010003, X:140, Y: 55, W:640, H:16, Type:  2 /*AEWB_LEFTWORDEND*/,    Txt:'2 - 当找到单词结束位置时停止左移。',
                                                                                                                    Rus:''};
    this.Wnd[this.IDBUT3  ]={C:'BUTTON', S:0x50010003, X:140, Y: 75, W:640, H:16, Type:  4 /*AEWB_RIGHTWORDSTART*/, Txt:'4 - 当找到单词开始位置时停止右移。',
                                                                                                                    Rus:''};
    this.Wnd[this.IDBUT4  ]={C:'BUTTON', S:0x50010003, X:140, Y: 95, W:640, H:16, Type:  8 /*AEWB_RIGHTWORDEND*/,   Txt:'8 - 当找到单词结束位置时停止右移。',
                                                                                                                    Rus:''};
    this.Wnd[this.IDBUT5  ]={C:'BUTTON', S:0x50010003, X:140, Y:115, W:640, H:16, Type: 16 /*AEWB_STOPSPACESTART*/, Txt:'16 - 当找到空格开始位置时停止移动。不能与 64 组合。',
                                                                                                                    Rus:''};
    this.Wnd[this.IDBUT6  ]={C:'BUTTON', S:0x50010003, X:140, Y:135, W:640, H:16, Type: 32 /*AEWB_STOPSPACEEND*/,   Txt:'32 - 当找到空格结束位置时停止移动。不能与 128 组合。',
                                                                                                                    Rus:''};
    this.Wnd[this.IDBUT7  ]={C:'BUTTON', S:0x50010003, X:140, Y:155, W:640, H:16, Type: 64 /*AEWB_SKIPSPACESTART*/, Txt:'64 - 当找到空格开始位置时继续移动。不能与 16 组合。',
                                                                                                                    Rus:''};
    this.Wnd[this.IDBUT8  ]={C:'BUTTON', S:0x50010003, X:140, Y:175, W:640, H:16, Type:128 /*AEWB_SKIPSPACEEND*/,   Txt:'128 - 当找到空格结束位置时继续移动。不能与 32 组合。',
                                                                                                                    Rus:''};
    this.Wnd[this.IDBUT9  ]={C:'BUTTON', S:0x50010003, X:140, Y:195, W:640, H:16, Type:256 /*AEWB_STOPNEWLINE*/,    Txt:'256 - 当找到换行符时停止移动。',
                                                                                                                    Rus:''};
    this.Wnd[this.IDDEF   ]={C:'BUTTON', S:0x50010003, X:140, Y:241, W:640, H:16,                                   Txt:'默认值: 1+8=9 (AkelPad)',
                                                                                                                    Rus:''};
    this.Wnd[this.IDDEFAE ]={C:'BUTTON', S:0x50010003, X:140, Y:261, W:640, H:16,                                   Txt:'默认值: 1+2+4+8+32+64=111 (AkelEdit)',
                                                                                                                    Rus:''};
    this.Wnd[this.IDENABLE]={C:'BUTTON', S:0x50010003, X:140, Y:281, W:640, H:16,                                   Txt:'仅当启用了设置中的 "单词分隔符" (WordDelimitersEnable=1)。',
                                                                                                                    Rus:''};
    this.Wnd[this.IDSUM   ]={C:'STATIC', S:0x50000000, X:150, Y:215, W: 70, H:13};
    this.Wnd[this.IDNOTE  ]={C:'STATIC', S:0x50000000, X:140, Y:310, W:640, H:13,                                   Txt:oFixedCharWidth.Wnd[oFixedCharWidth.IDNOTE].Txt,
                                                                                                                    Rus:oFixedCharWidth.Wnd[oFixedCharWidth.IDNOTE].Rus};
  },

  Apply:function()
  {
    if (! hEditWnd)
      SendMessage(hMainWnd, 273 /*WM_COMMAND*/, 4101 /*wParam=MAKEWPARAM(0,IDM_FILE_NEW)*/, 1 /*lParam=TRUE*/);

    SendMessage(hMainWnd, 1219 /*AKD_SETMAININFO*/, 117 /*MIS_WORDBREAKCUSTOM*/, this.Val);
    AkelPad.SetFrameInfo(0, 54 /*FIS_WORDDELIMITERSENABLE*/, this.Enable);

    if (! hEditWnd)
      AkelPad.Command(4318 /*IDM_WINDOW_FRAMECLOSE*/);
  },

  SetVal:function()
  {
    for (var i = this.IDBUT1; i <= this.IDBUT9; ++i)
      SendMessage(this.Wnd[i].HWND, 241 /*BM_SETCHECK*/, this.Val & this.Wnd[i].Type, 0);
    oSys.Call("User32::SetWindowTextW", this.Wnd[this.IDSUM].HWND, '=' + this.Val);
    SendMessage(this.Wnd[this.IDDEF   ].HWND, 241 /*BM_SETCHECK*/, this.Val == this.Def, 0);
    SendMessage(this.Wnd[this.IDDEFAE ].HWND, 241 /*BM_SETCHECK*/, this.Val == this.DefAE, 0);
    SendMessage(this.Wnd[this.IDENABLE].HWND, 241 /*BM_SETCHECK*/, this.Enable, 0);
  },

  Command:function(nID, nCode, hWnd)
  {
    if ((nID >= this.IDBUT1) && (nID <= this.IDBUT9))
    {
      if ((nID == this.IDBUT5) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
        SendMessage(this.Wnd[this.IDBUT7].HWND, 241 /*BM_SETCHECK*/, 0, 0);
      else if ((nID == this.IDBUT7) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
        SendMessage(this.Wnd[this.IDBUT5].HWND, 241 /*BM_SETCHECK*/, 0, 0);
      else if ((nID == this.IDBUT6) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
        SendMessage(this.Wnd[this.IDBUT8].HWND, 241 /*BM_SETCHECK*/, 0, 0);
      else if ((nID == this.IDBUT8) && SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0))
        SendMessage(this.Wnd[this.IDBUT6].HWND, 241 /*BM_SETCHECK*/, 0, 0);

      bChanged = 1;
      this.Val = 0;

      for (var i = this.IDBUT1; i <= this.IDBUT9; ++i)
      {
        if (SendMessage(this.Wnd[i].HWND, 240 /*BM_GETCHECK*/, 0, 0))
          this.Val |= this.Wnd[i].Type;
      }
      this.SetVal();
    }
    else if (((nID == this.IDDEF) || (nID == this.IDDEFAE)) && (SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0)))
    {
      bChanged = 1;
      this.Val = (nID == this.IDDEF) ? this.Def : this.DefAE;
      this.SetVal();
    }
    else if (nID == this.IDENABLE)
    {
      bChanged = 1;
      this.Enable = SendMessage(hWnd, 240 /*BM_GETCHECK*/, 0, 0);
    }
  }
};

var aParam =
[
  ["AkelAdminResident",  oAkelAdminResident],
  ["AkelUpdaterOptions", oAkelUpdaterOptions, aAkelUpdaterOptions],
  ["CmdLineBegin",       oCmdLineBegin,       aCmdLineBegin],
  ["CmdLineEnd",         oCmdLineEnd,         aCmdLineEnd],
  ["DateInsertFormat",   oDateInsertFormat,   aDateInsertFormat],
  ["DateLogFormat",      oDateLogFormat,      aDateLogFormat],
  ["EditStyle",          oEditStyle],
  ["FixedCharWidth",     oFixedCharWidth],
  ["MouseOptions",       oMouseOptions],
  ["PaintOptions",       oPaintOptions],
  ["RichEditClass",      oRichEditClass],
  ["ShowModify",         oShowModify],
  ["SingleOpenProgram",  oSingleOpenProgram],
  ["StatusPosType",      oStatusPosType],
  ["StatusUserFormat",   oStatusUserFormat,   aStatusUserFormat],
  ["TabNameFind",        oTabNameFind,        aTabNameFind],
  ["TabNameRep",         oTabNameRep,         aTabNameRep],
  ["TabOptionsMDI",      oTabOptionsMDI],
  ["UrlCommand",         oUrlCommand,         aUrlCommand],
  ["WordBreak",          oWordBreak]
];

for (i = 0; i < aParam.length; ++i)
  aParam[i][1].Initialize();

var Scale =
{
  Init:function()
  {
    var hDC = oSys.Call("User32::GetDC", hMainWnd);
    this.ScaleX = oSys.Call("Gdi32::GetDeviceCaps", hDC, 88 /*LOGPIXELSX*/);
    this.ScaleY = oSys.Call("Gdi32::GetDeviceCaps", hDC, 90 /*LOGPIXELSY*/);
    oSys.Call("User32::ReleaseDC", hMainWnd, hDC);
    //Align to 16 pixel
    this.ScaleX += (16 - this.ScaleX % 16) % 16;
    this.ScaleY += (16 - this.ScaleY % 16) % 16;
  },
  X:function(n) {return oSys.Call("Kernel32::MulDiv", n, this.ScaleX, 96);},
  Y:function(n) {return oSys.Call("Kernel32::MulDiv", n, this.ScaleY, 96);}
}
Scale.Init();

var aDlg     = [];
var IDNAMELV = 1001;
var IDENGB   = 1002;
var IDRUSB   = 1003;
var IDRESETB = 1004;
var IDUNDOB  = 1005;
var IDAPPLYB = 1006;
var IDOKB    = 1007;
var IDCLOSEB = 1008;

aDlg[IDNAMELV]={C:'SysListView32', S:0x5081800D, X: 5, Y:  5, W:120, H:327};
aDlg[IDENGB  ]={C:'BUTTON',        S:0x50000009, X: 5, Y:342, W: 55, H: 16, Txt:'&English'};
aDlg[IDRUSB  ]={C:'BUTTON',        S:0x50000009, X:70, Y:342, W: 55, H: 16, Txt:'中文(&C)'};
aDlg[IDRESETB]={C:'BUTTON',        S:0x50000000, X: 5, Y:367, W:120, H: 23, Txt:'全部重置(&D)'};
aDlg[IDUNDOB ]={C:'BUTTON',        S:0x50000000, X: 5, Y:392, W:120, H: 23, Txt:'撤消更改(&U)'};
aDlg[IDAPPLYB]={C:'BUTTON',        S:0x50000000, X: 5, Y:417, W:120, H: 23, Txt:'应用(&A)'};
aDlg[IDOKB   ]={C:'BUTTON',        S:0x50000001, X: 5, Y:442, W:120, H: 23, Txt:'确定'};
aDlg[IDCLOSEB]={C:'BUTTON',        S:0x50000000, X: 5, Y:467, W:120, H: 23, Txt:'关闭'};

var nFX = oSys.Call("User32::GetSystemMetrics", 7 /*SM_CXDLGFRAME*/) * 2;
var nFY = oSys.Call("User32::GetSystemMetrics", 8 /*SM_CYDLGFRAME*/) * 2 + oSys.Call("User32::GetSystemMetrics", 4 /*SM_CYCAPTION*/);

AkelPad.WindowRegisterClass(sClassName);

var hDlg = oSys.Call("User32::CreateWindowExW",
  0,                  //dwExStyle
  sClassName,         //lpClassName
  sScriptName,        //lpWindowName
  0x90C80000,         //dwStyle=WS_VISIBLE|WS_POPUP|WS_CAPTION|WS_SYSMENU
  nDlgX,              //x
  nDlgY,              //y
  Scale.X(795) + nFX, //nWidth
  Scale.Y(495) + nFY, //nHeight
  hMainWnd,           //hWndParent
  0,                  //hMenu
  hInstDLL,           //hInstance
  DialogCallback);    //Script function callback. To use it class must be registered by WindowRegisterClass.

oSys.Call("User32::EnableWindow", hMainWnd, 0);
AkelPad.WindowGetMessage();
AkelPad.WindowUnregisterClass(sClassName);
AkelPad.MemFree(lpText);
AkelPad.MemFree(lpLVITEM);

function DialogCallback(hWnd, uMsg, wParam, lParam)
{
  var nID, nCode;

  if (uMsg == 1 /*WM_CREATE*/)
  {
    CreateWindows(hWnd, aDlg, IDNAMELV);
    SendMessage(aDlg[IDENGB + nLang].HWND, 241 /*BM_SETCHECK*/, 1, 0);
    FillLV();
    EnableButtons();
    hFocus = aDlg[IDNAMELV].HWND;
  }

  else if ((uMsg == 6 /*WM_ACTIVATE*/) && (! wParam))
    hFocus = oSys.Call("User32::GetFocus");

  else if (uMsg == 7 /*WM_SETFOCUS*/)
    oSys.Call("User32::SetFocus", hFocus);

  else if (uMsg == 15 /*WM_PAINT*/)
    PaintFrame();

  else if (uMsg == 256 /*WM_KEYDOWN*/)
  {
    if (wParam == 9 /*VK_TAB*/)
    {
      hFocus = oSys.Call("User32::GetFocus");
      if (Ctrl())
      {
        oSys.Call("User32::SetFocus", aDlg[IDNAMELV].HWND);
        if (Shift())
        {
          if (nSel > 0)
            SetCurSelLV(nSel - 1);
          else
            SetCurSelLV(aParam.length - 1);
        }
        else
        {
          if (nSel < aParam.length - 1)
            SetCurSelLV(nSel + 1);
          else
            SetCurSelLV(0);
        }
      }
      else if ((hFocus == aDlg[IDENGB].HWND) || (hFocus == aDlg[IDRUSB].HWND))
        oSys.Call("User32::SetFocus", oSys.Call("User32::GetNextDlgTabItem", hWnd, hFocus, Shift()));
    }
    else if ((wParam == 13 /*VK_RETURN*/) && IsCloseCB())
      PostMessage(hWnd, 273 /*WM_COMMAND*/, IDOKB, 0);
  }

  else if (uMsg == 260 /*WM_SYSKEYDOWN*/)
  {
    if ((wParam == 0x2E /*VK_DELETE*/) && aParam[nSel][2] && (! IsCloseCB()))
      DeleteFromHistory();
  }

  else if (uMsg == 0x004E /*WM_NOTIFY*/)
  {
    if (wParam > 2001)
    {
      if (aParam[nSel][1].Notify)
        aParam[nSel][1].Notify(wParam, lParam);
    }
    else if (wParam == IDNAMELV)
    {
      switch (AkelPad.MemRead(_PtrAdd(lParam, _X64 ? 16 : 8), 3 /*DT_DWORD*/))
      {
        case -101: //LVN_ITEMCHANGED
          if (AkelPad.MemRead(_PtrAdd(lParam, _X64 ? 32 : 20) /*NMLISTVIEW.uNewState*/, 3 /*DT_DWORD*/) & 0x2 /*LVIS_SELECTED*/)
          {
            DestroyWindows(aParam[nSel][1].Wnd, 2001);
            nSel = GetCurSelLV();
            CreateWindows(hWnd, aParam[nSel][1].Wnd, 2001);
            if (aParam[nSel][2])
              FillCB();
            if (aParam[nSel][1].InitDialog)
              aParam[nSel][1].InitDialog();
            aParam[nSel][1].SetVal();
          }
          break;
        case -2: //NM_CLICK
        case -3: //NM_DBLCLK
        case -5: //NM_RCLICK
        case -6: //NM_RDBLCLK
          if (AkelPad.MemRead(_PtrAdd(lParam, _X64 ? 24 : 12) /*NMITEMACTIVATE.iItem*/, 3 /*DT_DWORD*/) == -1)
            SetCurSelLV(GetCurFocLV());
          break;
      }
    }
  }

  else if (uMsg == 273 /*WM_COMMAND*/)
  {
    nID   = LoWord(wParam);
    nCode = HiWord(wParam);

    bCloseCB = 1;

    if (nID > 2001)
    {
      if (nCode == 0x0100 /*EN_SETFOCUS*/)
        SendMessage(lParam, 3228 /*AEM_SETOPTIONS*/, 2 /*AECOOP_OR*/, 0x00000800 /*AECO_ACTIVELINE*/);
      else if (nCode == 0x0200 /*EN_KILLFOCUS*/)
        SendMessage(lParam, 3228 /*AEM_SETOPTIONS*/, 4 /*AECOOP_XOR*/, 0x00000800 /*AECO_ACTIVELINE*/);

      aParam[nSel][1].Command(nID, nCode, lParam);
      EnableButtons();
    }
    else if ((nID == IDENGB) || (nID == IDRUSB))
    {
      nLang = nID - IDENGB;
      aParam[nSel][1].Command(nID, nCode, lParam);
      SetTextInWindows(aParam[nSel][1].Wnd, 2001);
      oSys.Call("User32::SetFocus", aDlg[IDNAMELV].HWND);
    }
    else if (nID == IDRESETB)
    {
      SetDefPushButton(nID);
      ResetAll();
    }
    else if (nID == IDUNDOB)
    {
      SetDefPushButton(nID);
      UndoAll();
    }
    else if (nID == IDAPPLYB)
    {
      SetDefPushButton(nID);
      ApplyAll();
    }
    else if (nID == IDOKB)
    {
      bSaveHist = 1;
      ApplyAll();
      PostMessage(hWnd, 16 /*WM_CLOSE*/, 0, 0);
    }
    else if ((nID == IDCLOSEB) || (nID == 2 /*IDCANCEL*/))
      PostMessage(hWnd, 16 /*WM_CLOSE*/, 0, 0);
  }

  else if (uMsg == 16 /*WM_CLOSE*/)
  {
    WriteIni();
    oSys.Call("User32::EnableWindow", hMainWnd, 1);
    oSys.Call("User32::DestroyWindow", hWnd);
  }

  else if (uMsg == 2 /*WM_DESTROY*/)
    oSys.Call("User32::PostQuitMessage", 0);

  return 0;
}

function LoWord(nDwNum)
{
  return nDwNum & 0xFFFF;
}

function HiWord(nDwNum)
{
  return (nDwNum >> 16) & 0xFFFF;
}

function MkLong(nLoWord, nHiWord)
{
  return (nLoWord & 0xFFFF) | (nHiWord << 16);
}

function Ctrl()
{
  return oSys.Call("User32::GetKeyState", 0x11 /*VK_CONTROL*/) & 0x8000;
}

function Shift()
{
  return oSys.Call("User32::GetKeyState", 0x10 /*VK_SHIFT*/) & 0x8000;
}

function SendMessage(hWnd, uMsg, wParam, lParam)
{
  return AkelPad.SendMessage(hWnd, uMsg, wParam, lParam);
}

function PostMessage(hWnd, uMsg, wParam, lParam)
{
  return oSys.Call("User32::PostMessageW", hWnd, uMsg, wParam, lParam);
}

function GetWindowText(hWnd)
{
  oSys.Call("User32::GetWindowTextW", hWnd, lpText, nTextLen);
  return AkelPad.MemRead(lpText, 1 /*DT_UNICODE*/);
}

function GetCurFocLV()
{
  return SendMessage(aDlg[IDNAMELV].HWND, 0x100C /*LVM_GETNEXTITEM*/, -1, 0x0001 /*LVNI_FOCUSED*/);
}

function GetCurSelLV()
{
  return SendMessage(aDlg[IDNAMELV].HWND, 0x100C /*LVM_GETNEXTITEM*/, -1, 0x0002 /*LVNI_SELECTED*/);
}

function SetCurSelLV(nItem)
{
  AkelPad.MemCopy(_PtrAdd(lpLVITEM, 12), 0x0003 /*LVIS_SELECTED|LVIS_FOCUSED*/, 3 /*DT_DWORD*/);
  AkelPad.MemCopy(_PtrAdd(lpLVITEM, 16), 0x0003 /*LVIS_SELECTED|LVIS_FOCUSED*/, 3 /*DT_DWORD*/);
  SendMessage(aDlg[IDNAMELV].HWND, 0x102B /*LVM_SETITEMSTATE*/, nItem, lpLVITEM);
  SendMessage(aDlg[IDNAMELV].HWND, 0x1013 /*LVM_ENSUREVISIBLE*/, nItem, 0);
}

function FillLV()
{
  var lpLVCOLUMN = AkelPad.MemAlloc(_X64 ? 56 : 44); //sizeof(LVCOLUMN)
  var i;

  AkelPad.MemCopy(lpLVCOLUMN, 4 /*mask=LVCF_TEXT*/, 3 /*DT_DWORD*/);
  AkelPad.MemCopy(_PtrAdd(lpLVCOLUMN, _X64 ? 16 : 12), lpText, 2 /*DT_QWORD*/);
  AkelPad.MemCopy(lpText, "参数", 1 /*DT_UNICODE*/);

  SendMessage(aDlg[IDNAMELV].HWND, 0x1061 /*LVM_INSERTCOLUMNW*/, 0, lpLVCOLUMN);
  AkelPad.MemFree(lpLVCOLUMN);

  for (i = 0; i < aParam.length; ++i)
  {
    AkelPad.MemCopy(_PtrAdd(lpLVITEM, 4), i, 3 /*DT_DWORD*/);
    AkelPad.MemCopy(lpText, aParam[i][0], 1 /*DT_UNICODE*/);
    SendMessage(aDlg[IDNAMELV].HWND, 0x104D /*LVM_INSERTITEMW*/, 0, lpLVITEM);
  }

  if (nSel < 0)
    nSel = 0;
  else if (nSel >= aParam.length)
    nSel = aParam.length - 1;

  SetCurSelLV(nSel);
  SendMessage(aDlg[IDNAMELV].HWND, 0x101E /*LVM_SETCOLUMNWIDTH*/, 0, -2 /*LVSCW_AUTOSIZE_USEHEADER*/);
  SendMessage(aDlg[IDNAMELV].HWND, 0x1036 /*LVM_SETEXTENDEDLISTVIEWSTYLE*/, 0x0020 /*LVS_EX_FULLROWSELECT*/, 0x0020);
}

function FillCB()
{
  var hWndCB = aParam[nSel][1].Wnd[aParam[nSel][1].IDVAL].HWND;
  var i;

  SendMessage(hWndCB, 321 /*CB_LIMITTEXT*/, nTextLen, 0);
  SendMessage(hWndCB, 341 /*CB_SETEXTENDEDUI*/, 1, 0);

  for (i = 0; i < aParam[nSel][2].length; ++i)
    SendMessage(hWndCB, 0x0143 /*CB_ADDSTRING*/, 0, aParam[nSel][2][i]);
}

function ProcessCB(hWndCB, nCode)
{
  var i;

  if (nCode == 5 /*CBN_EDITCHANGE*/)
  {
    bChanged = 1;
    aParam[nSel][1].Val = GetWindowText(hWndCB);
    SendMessage(aParam[nSel][1].Wnd[aParam[nSel][1].IDDEF].HWND, 241 /*BM_SETCHECK*/, aParam[nSel][1].Val == aParam[nSel][1].Def, 0);
  }
  else if (nCode == 7 /*CBN_DROPDOWN*/)
  {
    for (i = 0; i < aParam[nSel][2].length; ++i)
    {
      if (aParam[nSel][2][i] == aParam[nSel][1].Val)
      {
        PostMessage(hWndCB, 0x014E /*CB_SETCURSEL*/, i, 0);
        break;
      }
    }
  }
  else if (nCode == 8 /*CBN_CLOSEUP*/)
  {
    if ((SendMessage(hWndCB, 0x0148 /*CB_GETLBTEXT*/, SendMessage(hWndCB, 0x0147 /*CB_GETCURSEL*/, 0, 0), lpText) > -1 /*CB_ERR*/) && (aParam[nSel][1].Val != AkelPad.MemRead(lpText, 1 /*DT_UNICODE*/)))
    {
      bChanged = 1;
      aParam[nSel][1].Val = AkelPad.MemRead(lpText, 1 /*DT_UNICODE*/);
      oSys.Call("User32::SetWindowTextW", hWndCB, lpText);
      SendMessage(hWndCB, 0x0142 /*CB_SETEDITSEL*/, 0, MkLong(0, -1));
      SendMessage(aParam[nSel][1].Wnd[aParam[nSel][1].IDDEF].HWND, 241 /*BM_SETCHECK*/, aParam[nSel][1].Val == aParam[nSel][1].Def, 0);
    }
  }
}

function IsCloseCB()
{
  if (aParam[nSel][2])
    return (! SendMessage(aParam[nSel][1].Wnd[aParam[nSel][1].IDVAL].HWND, 343 /*CB_GETDROPPEDSTATE*/, 0, 0));

  return bCloseCB;
}

function DeleteFromHistory()
{
  if (aParam[nSel][2].length)
  {
    var hWndCB = aParam[nSel][1].Wnd[aParam[nSel][1].IDVAL].HWND;
    var nPos   = SendMessage(hWndCB, 0x0147 /*CB_GETCURSEL*/, 0, 0);

    aParam[nSel][2].splice(nPos, 1);
    SendMessage(hWndCB, 0x0144 /*CB_DELETESTRING*/, nPos, 0);

    if (aParam[nSel][2].length)
    {
      if (nPos > aParam[nSel][2].length - 1)
        nPos = aParam[nSel][2].length - 1;

      SendMessage(hWndCB, 0x014E /*CB_SETCURSEL*/, nPos, 0);
    }
    else
    {
      aParam[nSel][1].Val = "";
      oSys.Call("User32::SetWindowTextW", hWndCB, "");
      SendMessage(aParam[nSel][1].Wnd[aParam[nSel][1].IDDEF].HWND, 241 /*BM_SETCHECK*/, aParam[nSel][1].Val == aParam[nSel][1].Def, 0);
    }
  }
}

function CreateWindows(hWndParent, aWnd, nFirst)
{
  var hGuiFont = oSys.Call("Gdi32::GetStockObject", 17 /*DEFAULT_GUI_FONT*/);
  var lpRect   = AkelPad.MemAlloc(16); //sizeof(RECT)
  var i;

  AkelPad.MemCopy(_PtrAdd(lpRect,  0), 2, 3 /*DT_DWORD*/);
  AkelPad.MemCopy(_PtrAdd(lpRect,  4), 2, 3 /*DT_DWORD*/);
  AkelPad.MemCopy(_PtrAdd(lpRect,  8), 2, 3 /*DT_DWORD*/);
  AkelPad.MemCopy(_PtrAdd(lpRect, 12), 2, 3 /*DT_DWORD*/);

  for (i = nFirst; i < aWnd.length; ++i)
  {
    aWnd[i].HWND = oSys.Call("User32::CreateWindowExW",
      0,                  //dwExStyle
      aWnd[i].C,          //lpClassName
      0,                  //lpWindowName
      aWnd[i].S,          //dwStyle
      Scale.X(aWnd[i].X), //x
      Scale.Y(aWnd[i].Y), //y
      Scale.X(aWnd[i].W), //nWidth
      Scale.Y(aWnd[i].H), //nHeight
      hWndParent,         //hWndParent
      i,                  //ID
      hInstDLL,           //hInstance
      0);                 //lpParam

    SendMessage(aWnd[i].HWND, 48 /*WM_SETFONT*/, hGuiFont, 1);

    if (aWnd[i].C == "AkelEditW")
    {
      oSys.Call("User32::SetWindowLongW", aWnd[i].HWND, -20 /*GWL_EXSTYLE*/, 0x20000 /*WS_EX_STATICEDGE*/);
      oSys.Call("User32::SetWindowPos", aWnd[i].HWND, 0, 0, 0, 0, 0, 0x37 /*SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE*/);

      SendMessage(aWnd[i].HWND, 3178 /*AEM_SETRECT*/, 0x02 /*AERC_MARGINS*/, lpRect);
      SendMessage(aWnd[i].HWND, 1091 /*EM_SETBKGNDCOLOR*/, 0, oSys.Call("User32::GetSysColor", 15 /*COLOR_BTNFACE*/)); 
    }
  }

  SetTextInWindows(aWnd, nFirst);
  AkelPad.MemFree(lpRect);
}

function SetTextInWindows(aWnd, nFirst)
{
  var nPos;
  var i;

  for (i = nFirst; i < aWnd.length; ++i)
  {
    if (aWnd[i].Txt)
      oSys.Call("User32::SetWindowTextW", aWnd[i].HWND, ((nLang == 1) && aWnd[i].Rus) ? aWnd[i].Rus : aWnd[i].Txt);

    if ((aWnd[i].C == "AkelEditW") && (! (aWnd[i].S & 0x4 /*ES_MULTILINE*/)))
    {
      nPos = aWnd[i].Txt.indexOf(": ");

      if (nPos > -1)
      {
        SendMessage(aWnd[i].HWND, 177 /*EM_SETSEL*/, nPos + 2, -1);
        SendMessage(aWnd[i].HWND, 8 /*WM_KILLFOCUS*/, 0, 0);
      }
    }
  }
}

function DestroyWindows(aWnd, nFirst)
{
  for (var i = nFirst; i < aWnd.length; ++i)
  {
    oSys.Call("User32::DestroyWindow", aWnd[i].HWND);
    aWnd[i].HWND = 0;
  }
}

function ResetAll()
{
  if (AkelPad.MessageBox(hDlg, "Set all parameters to default values?", sScriptName, 0x21 /*MB_ICONQUESTION|MB_OKCANCEL*/) == 1 /*IDOK*/)
  {
    for (var i = 0; i < aParam.length; ++i)
      aParam[i][1].Val = aParam[i][1].Def;

    aParam[nSel][1].SetVal();
    bChanged = 1;
    EnableButtons();
  }
}

function UndoAll()
{
  if (AkelPad.MessageBox(hDlg, "Undo all changes?", sScriptName, 0x21 /*MB_ICONQUESTION|MB_OKCANCEL*/) == 1 /*IDOK*/)
  {
    for (var i = 0; i < aParam.length; ++i)
    {
      aParam[i][1].Val = aParam[i][1].Ini;
      if ("Enable" in aParam[i][1])
        aParam[i][1].Enable = aParam[i][1].EnableIni;
    }

    aParam[nSel][1].SetVal();
    bChanged = 1;
    EnableButtons();
  }
}

function ApplyAll()
{
  hFocus = oSys.Call("User32::GetFocus");

  oSys.Call("User32::EnableWindow", hDlg, 0);
  oSys.Call("User32::EnableWindow", hMainWnd, 1);

  AkelPad.ScriptNoMutex(0x20 /*ULT_UNLOCKSENDMESSAGE*/);

  for (var i = 0; i < aParam.length; ++i)
    aParam[i][1].Apply();

  AkelPad.ScriptNoMutex(0x10 /*ULT_LOCKSENDMESSAGE*/);

  oSys.Call("User32::RedrawWindow", hMainWnd, 0, 0, 0x0485 /*RDW_ERASE|RDW_FRAME|RDW_INVALIDATE|RDW_ALLCHILDREN*/);
  oSys.Call("User32::EnableWindow", hMainWnd, 0);
  oSys.Call("User32::EnableWindow", hDlg, 1);
  oSys.Call("User32::SetFocus", hFocus);

  bChanged = 0;
  EnableButtons();
}

function EnableButtons()
{
  var bDefault = 1;
  var bInitial = 1;
  var i;

  for (i = 0; i < aParam.length; ++i)
  {
    if (aParam[i][1].Val != aParam[i][1].Def)
    {
      bDefault = 0;
      break;
    }
  }

  for (i = 0; i < aParam.length; ++i)
  {
    if ((aParam[i][1].Val != aParam[i][1].Ini) || (("Enable" in aParam[i][1]) && (aParam[i][1].Enable != aParam[i][1].EnableIni)))
    {
      bInitial = 0;
      break;
    }
  }

  oSys.Call("User32::EnableWindow", aDlg[IDRESETB].HWND, ! bDefault);
  oSys.Call("User32::EnableWindow", aDlg[IDUNDOB ].HWND, ! bInitial);
  oSys.Call("User32::EnableWindow", aDlg[IDAPPLYB].HWND, bChanged);
}

function SetDefPushButton(nID)
{
  if (oSys.Call("User32::GetFocus") == aDlg[nID].HWND)
  {
    oSys.Call("User32::SetFocus", aDlg[IDNAMELV].HWND);
    SendMessage(aDlg[nID  ].HWND, 0xF4 /*BM_SETSTYLE*/, 0 /*BS_PUSHBUTTON*/, 1);
    SendMessage(aDlg[IDOKB].HWND, 0xF4 /*BM_SETSTYLE*/, 1 /*BS_DEFPUSHBUTTON*/, 1);
  }
}

function PaintFrame()
{
  var lpPaint = AkelPad.MemAlloc(_X64 ? 72 : 64); //sizeof(PAINTSTRUCT)
  var lpRect  = AkelPad.MemAlloc(16); //sizeof(RECT)
  var hDC     = oSys.Call("User32::BeginPaint", hDlg, lpPaint);

  AkelPad.MemCopy(_PtrAdd(lpRect,  0), Scale.X(130), 3 /*DT_DWORD*/);
  AkelPad.MemCopy(_PtrAdd(lpRect,  4), Scale.Y(  5), 3 /*DT_DWORD*/);
  AkelPad.MemCopy(_PtrAdd(lpRect,  8), Scale.X(790), 3 /*DT_DWORD*/);
  AkelPad.MemCopy(_PtrAdd(lpRect, 12), Scale.Y(490), 3 /*DT_DWORD*/);

  oSys.Call("User32::DrawEdge", hDC, lpRect, 0x9 /*EDGE_BUMP*/, 0x800F /*BF_MONO|BF_RECT*/);
  oSys.Call("User32::EndPaint", hDlg, lpPaint);

  AkelPad.MemFree(lpPaint);
  AkelPad.MemFree(lpRect);
}

function FindInArray(aArray, sText)
{
  for (var i = 0; i < aArray.length; ++i)
  {
    if (aArray[i][0] == sText)
      return i;
  }
  return -1;
}

function ReadIni()
{
  try
  {
    eval(AkelPad.ReadFile(WScript.ScriptFullName.replace(/\.js$/i, ".ini"), 0x10 /*OD_ADT_NOMESSAGES*/, 1200 /*UTF-16LE*/, 1));
  }
  catch (oError)
  {}
}

function WriteIni()
{
  var lpRect = AkelPad.MemAlloc(16 /*sizeof(RECT)*/);
  var sIniTxt;
  var i, n;

  oSys.Call("User32::GetWindowRect", hDlg, lpRect);

  sIniTxt =
    'nDlgX=' + AkelPad.MemRead(_PtrAdd(lpRect, 0), 3 /*DT_DWORD*/) + ';\r\n' +
    'nDlgY=' + AkelPad.MemRead(_PtrAdd(lpRect, 4), 3 /*DT_DWORD*/) + ';\r\n' +
    'nSel='  + nSel + ';\r\n' +
    'nLang=' + nLang + ';\r\n';

  for (i = 0; i < aParam.length; ++i)
  {
    if (aParam[i][2])
    {
      //add to history
      if (bSaveHist && aParam[i][1].Val)
      {
        for (n = aParam[i][2].length - 1; n >= 0; --n)
        {
          if (aParam[i][2][n] == aParam[i][1].Val)
            aParam[i][2].splice(n, 1);
        }

        aParam[i][2].unshift(aParam[i][1].Val);

        if (aParam[i][2].length > nHistMax)
          aParam[i][2].length = nHistMax;
      }

      sIniTxt += 'a' + aParam[i][0] + '=[';

      for (n = 0; n < aParam[i][2].length; ++n)
        sIniTxt += '"' + aParam[i][2][n].replace(/[\\"]/g, '\\$&') + '"' + ((n < aParam[i][2].length - 1) ? ',' : '');

      sIniTxt += '];\r\n';
    }
  }

  AkelPad.MemFree(lpRect);
  AkelPad.WriteFile(WScript.ScriptFullName.replace(/\.js$/i, ".ini"), sIniTxt, sIniTxt.length, 1200 /*UTF-16LE*/, 1);
}
