function Control_Class() {
    MsgBox = function (lpText, wType, lpCaption) {
        Api.ECall("User32.dll", "MessageBoxW", 0, (lpText || "").toString(), (lpCaption || "").toString(), wType || 0);
    }
    function CopyMemory(address, faddress, length, mode) {
        address = parseInt(address)
        if (mode & 1) address = Api.VarPtr(address) + 8
        if (typeof faddress == "string") {
            var Str = Api.Malloc()
            Str.FromString = faddress
            Api.ECall("kernel32.dll", "RtlMoveMemory", address, Str.GetPtr(0), length || Str.Size + 1)
            // Str = null
            // CollectGarbage() '立刻GC
            return
        }
        faddress = parseInt(faddress)
        if (mode & 2) faddress = Api.VarPtr(faddress) + 8
        Api.ECall("kernel32.dll", "RtlMoveMemory", address, faddress, length || 4)
        // var Malloc = Api.Malloc()
        // Malloc.Add(0,4) = 123456789
    }
    function VBScript() {
        var vbs = new ActiveXObject("ScriptControl")
        vbs.language = "vbs"
        vbs.timeout = -1
        return vbs
    }
    this.Exist = function (key, Obj, mode) {
        var b = mode & 1 ? Obj.hasOwnProperty(key) : key in Obj
        return b && mode & 4 ? typeof key == 'function' : b
    }
    this.Keys = function (Obj, mode) {
        var keys = new Array()
        for (var key in Obj) {
            switch (true) {
                case Boolean(mode & 1):
                    if (!Obj.hasOwnProperty(key))
                        break;
                case Boolean(mode & 6): //2 返回属性  4返回函数
                    if (typeof Obj[key] == 'function' ? mode & 2 : mode & 4)
                        break;
                default:
                    keys.push(key)
            }
        }
        if (mode & 8) keys = keys.sort()
        return keys.join("|")
    }
    this.XPStyle = function () {
        // Private Type ACTCTX
        //     cbSize As Long                          0
        //     dwFlags As Long                         4
        //     lpSource As String                      8
        //     wProcessorArchitecture As Integer       12
        //     wLangId As Integer                      14
        //     lpAssemblyDirectory As String           16
        //     lpResourceName As String                20
        //     lpApplicationName As String             24
        //     hModule As Long                         28
        // End Type

        var length = Api.ECall("kernel32", "GetWindowsDirectoryW", 0, 0)
        var Path = Api.Malloc((length - 1) * 2 - 1)
        if (Api.ECall("kernel32", "GetWindowsDirectoryW", Path.GetPtr(0), length)) {
            Path.FromString = Path.ToString + "\\WindowsShell.manifest\0"
            var ACTCTX = Api.Malloc(31)
            ACTCTX.SetVal(0, 4) = 32
            ACTCTX.SetVal(8, 4) = Path.GetPtr(0)
            var hActCtx = Api.ECall("kernel32", "CreateActCtxW", ACTCTX.GetPtr(0))
            if (hActCtx != -1) return Api.ECall("kernel32", "ActivateActCtx", hActCtx, Api.VarPtr(length) + 8) != 0
        }
    }
    this.SetComboBox = function (Control, List, Index) {
        var GWL_STYLE = -16
        var GW_CHILD = 5
        var v = List.split("|")
        for (var i = 0; i < v.length; i++) {
            Control.AddItem(v[i])
        }
        var ChildHwnd = Api.ECall("user32.dll", "GetWindow", Control.hwnd, GW_CHILD)
        Api.ECall("user32.dll", "DestroyWindow", ChildHwnd)
        Api.ECall("user32.dll", "SetWindowLongA", Control.hwnd, GWL_STYLE, Api.ECall("user32.dll", "GetWindowLongA", Control.hwnd, GWL_STYLE) + 1)
        Control.ListIndex = Index
    }
    this.LoadPicture = function (URL) {
        var vbs = Api.NewScript("Set obj = nothing")
        var IID = Api.Malloc(15)
        IID.SetVal(0, 4) = 0x7BF80980
        IID.SetVal(4, 2) = 0xBF32
        IID.SetVal(6, 2) = 0x101A
        IID.SetEx(8, 0x8B, 0xBB, 0x0, 0xAA, 0x0, 0x30, 0xC, 0xAB)
        Api.ECall("oleaut32.dll", "OleLoadPicturePath", URL, 0, 0, 0, IID.GetPtr(0), vbs.Eval("Api.VarPtr(obj)+8"))
        var OutObject = vbs.Eval("obj")
        vbs.Reset()
        return OutObject
    }
    this.GetClassObject = function (DllName, CLSID, IID, Hook) {
        var hModule = Api.ECall("kernel32.dll", "GetModuleHandleW", DllName) || Api.ProcAddress(DllName)
        var vbs = Api.NewScript("Set obj = nothing")
        if (hModule) {
            var addr = Api.ProcAddress(hModule, "DllGetClassObject");
            if (addr > 0) {
                var IID_CLSID_ClassFactory = Api.Malloc(35)
                Api.ECall("ole32.dll", "CLSIDFromString", "{00000001-0000-0000-C000-000000000046}", IID_CLSID_ClassFactory.GetPtr(0))   //IID_IClassFactory
                Api.ECall("ole32.dll", "CLSIDFromString", CLSID, IID_CLSID_ClassFactory.GetPtr(16)) //CLSID
                if (Api.ECall(addr, false, IID_CLSID_ClassFactory.GetPtr(16), IID_CLSID_ClassFactory.GetPtr(0), IID_CLSID_ClassFactory.GetPtr(32)) == 0) {  //DllGetClassObject
                    Api.ECall("ole32.dll", "CLSIDFromString", IID || "{00000000-0000-0000-C000-000000000046}", IID_CLSID_ClassFactory.GetPtr(0))    //IID_IUnknown
                    var hClassFactory = IID_CLSID_ClassFactory.Read(32, 4)
                    if (Hook) { //旧版大漠 需要hook 只要hook一次
                        var AsmCode = Api.Malloc(15)
                        hModule = Api.ProcAddress("oleaut32.dll")
                        Hook = Api.ProcAddress(hModule, "LoadRegTypeLib")
                        Api.ECall("kernel32.dll", "RtlMoveMemory", AsmCode.GetPtr(0), Hook, 7)
                        var Callblack = Api.CallBack(function (arg1, arg2, arg3, arg4, arg5) {
                            Api.ECall("ole32.dll", "StringFromCLSID", arg1, IID_CLSID_ClassFactory.GetPtr(32))
                            MsgBox(Api.ReadMem(IID_CLSID_ClassFactory.Read(32, 4), 0, 0, 8))
                            return Api.ECall("oleaut32", "LoadTypeLib", DllName, arg5)
                        }, "", 5)
                        AsmCode.SetEx(8, 0xB8, 0, 0, 0, 0, 0xFF, 0xE0)
                        AsmCode.SetVal(9, 4) = Callblack.GetPtr(0)
                        Api.ECall("kernel32", "WriteProcessMemory", -1, Hook, AsmCode.GetPtr(8), 7, 0)
                    }
                    addr = Api.ReadMem(hClassFactory)
                    Api.ECall(Api.ReadMem(addr + 3 * 4), false, hClassFactory, 0, IID_CLSID_ClassFactory.GetPtr(0), vbs.Eval("Api.VarPtr(obj)+8"))//IClassFactory.CreateInstance在3号位置
                    Api.ECall(Api.ReadMem(addr + 2 * 4), false, hClassFactory)//Release
                    if (Hook) {
                        vbs.Eval("TypeName(obj)")
                        Api.ECall("kernel32", "WriteProcessMemory", -1, Hook, AsmCode.GetPtr(0), 7, 0)
                        Api.ProcAddress(-hModule)
                    }
                }
            }
        }
        var OutObject = vbs.Eval("obj")
        vbs.Reset()
        return OutObject
    }
    this.Drag = function (hwnd) {   //管理员权限开启拖放文件
        var WM_DROPFILES = 0x233
        var MSGFLT_ALLOW = 1
        var MSGFLT_ADD = 1
        var WM_COPYDATA = 0x4A
        var WM_COPYGLOBALDATA = 0x49
        var hModule = Api.ProcAddress("user32");
        var i = Api.ProcAddress(hModule, "ChangeWindowMessageFilter");
        if (i) {
            if (hwnd) {
                Api.ECall("user32", "ChangeWindowMessageFilterEx", hwnd, WM_DROPFILES, MSGFLT_ALLOW, 0)
                Api.ECall("user32", "ChangeWindowMessageFilterEx", hwnd, WM_COPYGLOBALDATA, MSGFLT_ALLOW, 0)
                Api.ECall("shell32", "DragAcceptFiles", hwnd, true)
            } else {
                Api.ECall("user32", "ChangeWindowMessageFilter", WM_COPYGLOBALDATA, MSGFLT_ADD)
                Api.ECall("user32", "ChangeWindowMessageFilter", WM_DROPFILES, MSGFLT_ADD)
                Api.ECall("user32", "ChangeWindowMessageFilter", WM_COPYDATA, MSGFLT_ADD)
            }
        }
        Api.ProcAddress(-hModule);
    }
    this.DragMouse = function (Form, Name, x, y, Event) {   //拖动控件
        var PictureBox = Form.Controls.add("VB.PictureBox", Name)
        PictureBox.Appearance = 0
        PictureBox.BorderStyle = 0
        PictureBox.Move(x, y, 32, 32)
        PictureBox.Visible = true
        PictureBox.Picture = this.LoadPicture("http://www.icosky\x2Ecom/icon/ico/System/WebGloss 3D/Magnifier.ico")
        Form.SetEventLong(PictureBox.hWnd, Api.ArrayFormat([0x201, 0x202]), {
            "Pic_GetMessage": function (cHwnd, Message, wParam, lParam) {
                switch (Message) {
                    case 0x201:
                        Form.MousePointer = 99
                        Form.MouseIcon = Form.Controls(Name).Picture
                        Form.Controls("Image").Left = -9999
                        break
                    case 0x202:
                        Form.Controls("Image").Left = x
                        Form.MousePointer = 0
                        Event(Name)
                }
            }
        }, "Pic")
        return PictureBox.Picture
    }
    this.Menu = function () {
        return {
            "Create": function (hwnd, vMenus) {
                var MF_STRING = 0x0
                var MF_POPUP = 0x10
                var MF_BYPOSITION = 0x400
                var MF_SEPARATOR = 0x800
                var hMenu = Api.ECall("user32.dll", "GetMenu", hwnd)
                if (!hMenu) hMenu = Api.ECall("user32.dll", "CreateMenu")
                hSubMenu = Api.ECall("user32.dll", "CreatePopupMenu")
                var Menus = vMenus.split("\0");
                Api.ECall("user32.dll", "AppendMenuW", hMenu, MF_STRING | MF_BYPOSITION | MF_POPUP, hSubMenu, Menus[0].toString())
                for (var i = 0; i < Menus.length; i++) {
                    Api.ECall("user32.dll", "AppendMenuW", hSubMenu, MF_STRING | MF_BYPOSITION | (Menus[i] == "-" ? MF_SEPARATOR : 0), i + 1, Menus[i].toString())
                }
                Api.ECall("user32.dll", "SetMenu", hwnd, hMenu)
                return hSubMenu
            },
            "Pop": function (hwnd, Menu, x, y) {
                var TPM_RETURNCMD = 0x100
                var Point = Api.Malloc(7)
                Point.SetVal(0, 4) = x / Globals("Screen").TwipsPerPixelX
                Point.SetVal(4, 8) = y / Globals("Screen").TwipsPerPixelY
                Api.ECall("user32.dll", "ClientToScreen", hwnd, Point.GetPtr(0))
                return Api.ECall("user32.dll", "TrackPopupMenu", Menu, TPM_RETURNCMD, Point.Read(0, 4), Point.Read(4, 4), 0, hwnd, 0)
            },
            //     Private Type MENUITEMINFO
            //       cbSize As Long          0
            //       fMask As Long           4
            //       fType As Long           8
            //       fState As Long          12
            //       wID As Long             16
            //       hSubMenu As Long        20
            //       hbmpChecked As Long     24
            //       hbmpUnchecked As Long   28
            //       dwItemData As Long      32
            //       dwTypeData As String    36
            //       cch As Long             40
            //   End Type
            "Set": function (Menu, Index, Mode, Val) {
                var MIIM_TYPE = 0x10
                var MIIM_STATE = 0x1
                var MIIM_CHECKMARKS = 0x8

                var MFT_STRING = 0x0

                var MF_CHECKED = 0x8
                var MFS_GRAYED = 0x3
                pszText = Api.Malloc(255)
                var MENUITEMINFO = Api.Malloc(43)
                MENUITEMINFO.SetVal(0, 4) = 44
                MENUITEMINFO.SetVal(4, 4) = MIIM_TYPE | MIIM_STATE
                MENUITEMINFO.SetVal(36, 4) = pszText.GetPtr(0)
                MENUITEMINFO.SetVal(40, 4) = pszText.Size + 1
                if (Api.ECall("user32", "GetMenuItemInfoW", Menu, Index, true, MENUITEMINFO.GetPtr(0))) {
                    if (Mode & 1) {
                        pszText.FromString = Val + "\0"
                        MENUITEMINFO.SetVal(36, 4) = pszText.GetPtr(0)
                        MENUITEMINFO.SetVal(40, 4) = pszText.Size + 1
                    }
                    fState = MENUITEMINFO.Read(12, 4)
                    if (Mode & 2)
                        fState = fState & ~MF_CHECKED
                    else if (Mode & 4)
                        fState = fState | MF_CHECKED
                    if (Mode & 8)
                        fState = fState & ~MFS_GRAYED
                    else if (Mode & 16)
                        fState = fState | MFS_GRAYED
                    MENUITEMINFO.SetVal(12, 4) = fState
                    return Api.ECall("user32", "SetMenuItemInfoW", Menu, Index, true, MENUITEMINFO.GetPtr(0))
                }
            }
        }
    }

    this.Tray = function (handle) {
        // Private Type NOTIFYICONDATA
        //     cbSize As Long               0
        //     hwnd As Long                 4
        //     uID As Long                  8
        //     uFlags As Long               12
        //     uCallbackMessage As Long     16
        //     hIcon As Long                20
        //     szTip As String * 128        24
        //     dwState As Long              152
        //     dwStateMask As Long          156
        //     szInfo As String * 256       160
        //     uTimeout As Integer          416
        //     uVersion As Integer          418
        //     szInfoTitle As String * 64   420
        //     dwInfoFlags As Long          484
        // End Type
        var NIF_ICON = 0x2
        var NIF_TIP = 0x4
        var NIF_MESSAGE = 0x1
        var NIM_MODIFY = 0x1
        return {
            "handle": handle || 0,
            "Add": function (hwnd, ToolTip, ICO) {
                var LMEM_ZEROINIT = 0x40
                handle = Api.ECall("kernel32.dll", "LocalAlloc", LMEM_ZEROINIT, 488)
                // Api.ECall("kernel32.dll", "RtlZeroMemory", handle, 484)
                CopyMemory(handle, 488, 4, 2)
                CopyMemory(handle + 4, hwnd, 4, 2)
                var WM_MOUSEMOVE = 0x200
                CopyMemory(handle + 16, WM_MOUSEMOVE, 4, 2)
                Up(ToolTip, ICO || Api.ECall("user32.dll", "SendMessageA", hwnd, 0x7F, 1, 0), NIF_ICON | NIF_TIP | NIF_MESSAGE);
                var NIM_ADD = 0x0
                Api.ECall("shell32.dll", "Shell_NotifyIconA", NIM_ADD, handle);
                return handle
            },
            "UpData": function (ToolTip, ICO) {
                Up(ToolTip, ICO, NIF_TIP | NIF_MESSAGE);
                Api.ECall("shell32.dll", "Shell_NotifyIconA", NIM_MODIFY, handle);
            },
            "Tips": function (Text, Title, bFlag) {
                var NIF_INFO = 0x10;
                CopyMemory(handle + 12, NIF_INFO, 4, 2);
                CopyMemory(handle + 420, Api.StrConv(Title || "\0\0", 0x80));
                CopyMemory(handle + 160, Api.StrConv(Text + "\0", 0x80));
                CopyMemory(handle + 484, bFlag || 0, 4, 2);
                Api.ECall("shell32.dll", "Shell_NotifyIconA", NIM_MODIFY, handle);
            },
            "Remove": function () {
                var NIM_DELETE = 0x2
                Api.ECall("shell32.dll", "Shell_NotifyIconA", NIM_DELETE, handle);
                Api.ECall("kernel32.dll", "LocalFree", handle)
            }
        }
        function Up(ToolTip, ICO, Flag) {
            if (ICO) {
                Flag = Flag | NIF_ICON
                CopyMemory(handle + 20, ICO, 4, 2)
            }
            CopyMemory(handle + 12, Flag, 4, 2)
            CopyMemory(handle + 24, Api.StrConv(ToolTip + "\0", 0x80))
        }
    }
    this.ToopTip = function (Hwnd) {
        var WM_USER = 0x400
        return {    //可以不写 局部this
            "Hwnd": Hwnd | 0,
            "Create": function (hwnd) {
                var TTS_BALLOON = 0x40
                var CW_USEDEFAULT = -2147483648 //0x80000000
                this.Hwnd = Api.ECall("user32.dll", "CreateWindowExW", 0, "tooltips_class32", "", TTS_BALLOON, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd || 0, 0, 0, 0)
                return this.Hwnd
            },
            // Private Type TOOLINFO
            //     lSize As Long     0
            //     lFlags As Long    4
            //     lHwnd As Long     8
            //     lId As Long       12
            //     RectL As Long     16
            //     RectT As Long     20
            //     RectR As Long     24
            //     RectB As Long     28
            //     hInstance As Long 32
            //     lpStr As String   36
            //     lParam As Long    40
            // End Type
            "Tips": function (hwnd, Title, Text, x1, y1, x2, y2) {
                var TTF_SUBCLASS = 0x10
                var TTM_ADDTOOLA = WM_USER + 4
                var TTM_DELTOOLA = WM_USER + 5
                var TTM_UPDATETIPTEXTA = WM_USER + 12
                var TOOLINFO = Api.Malloc(43)
                TOOLINFO.SetVal(4, 4) = TTF_SUBCLASS
                TOOLINFO.SetVal(8, 4) = hwnd
                TOOLINFO.SetVal(16, 4) = x1
                TOOLINFO.SetVal(20, 4) = y1
                TOOLINFO.SetVal(24, 4) = x2
                TOOLINFO.SetVal(28, 4) = y2

                pszText = Api.Malloc()
                pszText.FromString = Api.StrConv(Text + "\0", 128)
                TOOLINFO.SetVal(36, 4) = pszText.GetPtr(0)
                Api.ECall("user32.dll", "SendMessageA", this.Hwnd, TTM_DELTOOLA, 0, TOOLINFO.GetPtr(0))
                Api.ECall("user32.dll", "SendMessageA", this.Hwnd, TTM_ADDTOOLA, 0, TOOLINFO.GetPtr(0))
                Api.ECall("user32.dll", "SendMessageA", this.Hwnd, TTM_UPDATETIPTEXTA, 0, TOOLINFO.GetPtr(0))

                var TTM_SETTITLEW = WM_USER + 33
                Api.ECall("user32.dll", "SendMessageA", this.Hwnd, TTM_SETTITLEW, 0, Title)
            },
            "Remove": function () {
                var NIM_DELETE = 0x2
                Api.ECall("shell32.dll", "Shell_NotifyIconA", NIM_DELETE, handle);
                Api.ECall("kernel32.dll", "LocalFree", handle)
            }
        }
    }
    this.MoveEx = function (hWnd, x, y, Width, Height, Owner, Mode) {
        Mode = Mode || 0
        Owner = Owner || Api.ECall("user32.dll", "GetWindow", hWnd, 4)
        if (Mode & 0x10) Api.ECall("user32.dll", "SetWindowLongA", hWnd, -8, Owner)
        if (x == null && y == null) Mode = Mode | 2 //SWP_NOMOVE
        if (Width == null && Height == null) Mode = Mode | 1 //SWP_NOSIZE
        var RECT = Api.Malloc(15)
        Api.ECall("user32", "GetWindowRect", Owner, RECT.GetPtr(0))
        var intX = (RECT.Read(0, 4) + RECT.Read(8, 4)) / 2
        var intY = (RECT.Read(4, 4) + RECT.Read(12, 4)) / 2
        Api.ECall("user32", "GetWindowRect", hWnd, RECT.GetPtr(0))
        Width = Width || RECT.Read(8, 4) - RECT.Read(0, 4)
        Height = Height || RECT.Read(12, 4) - RECT.Read(4, 4)
        x = (x || 0) + intX - Width / 2
        y = (y || 0) + intY - Height / 2
        if (Mode % 0x10) Api.ECall("user32", "SetWindowPos", hWnd, 0, x, y, Width, Height, Mode % 0x10)
    }

    this.WebDialog = function (URL, Title, Mode, Width, Height, x, y, FOwner, IntX, IntY, Event) {   //  2 置顶窗口
        var FShow = Api.NewForm()
        FShow.Appearance = 0;
        FShow.Caption = Title;
        Width = Width || 600
        Height = Height || 360
        FShow.Width += (Width - FShow.ScaleWidth) * Globals("Screen").TwipsPerPixelX;
        FShow.Height += (Height - FShow.ScaleHeight) * Globals("Screen").TwipsPerPixelY;
        FShow.Move(x != null ? x : (Globals("Screen").Width - FShow.Width) / 2, y != null ? y : (Globals("Screen").Height - FShow.Height) / 2)
        if (Mode & 2) Api.ECall("user32.dll", "SetWindowPos", FShow.hWnd, -1, 0, 0, 0, 0, 1 + 2 + 8)
        var WebBrowser = FShow.Controls.add("Shell.Explorer", "WebBrowser");
        x = IntX || 0
        y = IntY || 0
        WebBrowser.Move(x, y, Width - (x < 0 ? 2 * x : x), Height - (y < 0 ? 2 * y : y))
        WebBrowser.Visible = true
        WebBrowser.Object.Silent = true
        WebBrowser.Object.Navigate(URL)
        FShow.SetEventLong(FShow.hwnd, Api.ArrayFormat([0x5]), {
            "Form_GetMessage": function (cHwnd, Message, wParam, lParam) {
                switch (Message) {
                    case 0x5:
                        WebBrowser.Move(x, y, FShow.ScaleWidth - (x < 0 ? 2 * x : x), FShow.ScaleHeight - (y < 0 ? 2 * y : y))
                        break
                }
            }
        }, "Form")
        FShow.SetEvent(WebBrowser, Event || {
            "WebBrowser_TitleChange": function (Text) {
                Api.ECall("user32.dll", "SetWindowTextW", FShow.hWnd, Text)
            },
            "WebBrowser_DocumentComplete": function (pDisp, URL) {
                if (Mode & 4) pDisp.Document.body.oncontextmenu = function () { return false; }
                // pDisp.Document.InvokeScript("bds.util.setContainerWidth")
                // pDisp.Document.body.setAttribute("Angelfz", VBS)
            }
        }, "ActiveXEvent")
        switch (typeof (FOwner)) {
            case 'number':
                if (FOwner > 0) this.MoveEx(FShow.hWnd, IntX, IntY, null, null, FOwner, 0x10)
            case "object":
                this.MoveEx(FShow.hWnd, IntX, IntY, null, null, FOwner.hWnd)
                FShow.Show(Mode & 1, FOwner)
                break;
            default:
                FShow.Show(Mode & 1)
        }
        return FShow
    }
    this.TimeDialog = function (Index) {
        var Tag, me = this
        var callee = arguments.callee
        var VBS = VBScript();
        var FormD = Api.NewForm()
        var Show = function (Index) {
            Index = Index || "12:00:00:1"
            Index = Index.replace(/\|/g, ":")

            FormD.Caption = "填写时间:"
            var i = Api.ECall("user32.dll", "GetWindowLongA", FormD.hwnd, -16)
            Api.ECall("user32.dll", "SetWindowLongA", FormD.hwnd, -16, i & ~(0x10000 | 0x20000 | 0x40000))
            FormD.Move(0, 0, 0, 0)
            FormD.Width += (260 - FormD.ScaleWidth) * Globals("Screen").TwipsPerPixelX
            FormD.Height += (60 - FormD.ScaleHeight) * Globals("Screen").TwipsPerPixelY

            var obj = FormD.Controls.Add("VB.Label", "Label")
            obj.Move(10, 10, 200, 20)
            obj.Caption = "24小时制:时 分 秒"
            obj.Visible = true
            var arr = Index.split(":")

            obj = FormD.Controls.Add("VB.ComboBox", "ComboBox")
            obj.Move(10, 30, 73)
            obj.Visible = true
            if (arr[3] < 0) {
                obj.Enabled = false
                arr[3] = Math.abs(arr[3])
            }

            me.SetComboBox(FormD.Controls("ComboBox"), "每天|一次|每隔", arr[3] - 1)
            for (i = 0; i < arr.length - 1; i++) {
                obj = FormD.Controls.Add("VB.TextBox", "t" + i)
                obj.Move(100 + 25 * i, 30, 20, 20)
                obj.Visible = true
                obj.Text = arr[i]
            }
            arr = new Array("确定", "取消")
            for (i = 0; i < arr.length; i++) {
                obj = FormD.Controls.Add("VB.CommandButton", arr[i])
                obj.Caption = arr[i]
                obj.Move(180 + 35 * i, 30, 35, 21)
                obj.Visible = true
            }
            var wMsgs = VBS.Eval('Array(&H111,&H18)')
            VBS.AddCode('Function JTypeName(Obj)\nJTypeName=TypeName(Obj)\nEnd Function')
            FormD.SetEventLong(FormD.hwnd, wMsgs, Show.caller, "Form")
            FormD.Show(1)
        }
        callee.Form_GetMessage = function (cHwnd, Message, wParam, lParam) {
            switch (Message) {
                case 0x18:
                    FormD.Move((Globals("Screen").Width - FormD.Width) / 2, (Globals("Screen").Height - FormD.Height) / 2)
                case 0x111:
                    var fenum = new Enumerator(FormD.Controls);
                    for (; !fenum.atEnd(); fenum.moveNext()) {
                        var Obj = fenum.item()
                        var TypeName = VBS.Run("JTypeName", Obj)
                        if ("CommandButton|CheckBox|TextBox|ComboBox".indexOf(TypeName) >= 0) {
                            if (Obj.hwnd == lParam) {
                                switch (TypeName) {
                                    case "CommandButton":
                                        if (Obj.Name == "确定") {
                                            Tag = FormD.Controls("t0") + ":" + FormD.Controls("t1") + ":" + FormD.Controls("t2") + "|" + (FormD.Controls("ComboBox").ListIndex + 1)
                                        }
                                        Api.UnloadForm(FormD)
                                        break
                                    case "TextBox":
                                        switch (parseInt(wParam / 0x100)) {
                                            case 0x30000:
                                                var iText = Api.Val(Obj.Text)
                                                if (iText >= (Obj.Name == "t0" ? 24 : 60) || iText < 0) iText = 0
                                                var Text = iText.toString()
                                                if (Text.length == 1) Text = "0" + Text
                                                Obj.Text = Text
                                                Obj.SelStart = Text.length
                                            // Obj.SelLength = Text.length
                                        }
                                        break
                                }
                                return
                            }
                        }
                    }
                    break
            }
        }
        // MsgBox(this.constructor)
        Show(Index)
        VBS.Reset()
        delete callee.Form_GetMessage
        // FormD = null
        // CollectGarbage()
        return Tag;
    }
    this.DownDialog = function (Url, FileName, Callblack, Method, Data, Header, Mode) {
        Mode = Mode | 0;
        var FormD = Api.NewForm()
        FormD.Caption = "下载文件:"
        var i = Api.ECall("user32.dll", "GetWindowLongA", FormD.hwnd, -16)
        Api.ECall("user32.dll", "SetWindowLongA", FormD.hwnd, -16, i & ~(0x10000 | 0x20000 | 0x40000))
        Api.ECall("user32", "SetWindowPos", FormD.hWnd, -1, 0, 0, 0, 0, 0x1 | 0x2)
        FormD.Move(0, 0, 0, 0)
        FormD.Width += (345 - FormD.ScaleWidth) * Globals("Screen").TwipsPerPixelX
        FormD.Height += (85 - FormD.ScaleHeight) * Globals("Screen").TwipsPerPixelY
        var arr = ["URL", Url, "Save", FileName, "down"]
        for (i = 0; i < arr.length; i = i + 2) {
            var obj = FormD.Controls.Add("VB.Label", "Label" + i)
            obj.Move(20, (i + 1) * 12 + 2, 305, 20)
            obj.Visible = true
            if (i + 1 == arr.length) break
            obj.Caption = arr[i] + ":"
            var obj = FormD.Controls.Add("VB.TextBox", arr[i])
            obj.Move(55, (i + 1) * 12, 265, 20)
            obj.Text = arr[i + 1]
            obj.Locked = true
            obj.Visible = true
        }
        var down = 0;
        var downmark = 0;
        var downtime = 0;
        var data = Api.Malloc()
        var http = Api.NewHttp();
        var whttp = http.httpPro({
            "HttpPro_OnFinished": function () {
                if (Mode & 2) Api.UnloadForm(FormD)
                Api.ECall("user32.dll", "SetWindowTextW", FormD.hwnd, "下载文件:100%  ")
                obj.Caption = Array(25).join("■")
                if (Callblack) {
                    Callblack(whttp)
                } else {
                    Api.Script.CodeObject.File.WriteFlie(FileName, whttp.ResponseBody)
                }
                http.Clear()
            },
            "HttpPro_OnError": function () {
                Api.ECall("user32.dll", "SetWindowTextW", FormD.hwnd, "下载失败:" + Api.LastErr.Description)
                whttp.Abort
                http.Clear()
            },
            "HttpPro_OnStart": function (Status, ContentType) {
                try {
                    i = whttp.GetResponseHeader("Content-Length")
                } catch (e) {
                    i = -1
                }
            },
            "HttpPro_OnDataAvailable": function (Bytes) {
                if (i == -1) {
                    Api.ECall("user32.dll", "SetWindowTextW", FormD.hwnd, "下载文件:未知大小")
                    i == -2
                } else if (i > 0) {
                    data.FromBytes = Bytes
                    down = down + data.Size
                    obj.Caption = Array(parseInt(25 * down / i)).join("■")
                }
                var time = new Date().getMilliseconds()
                if (time - downtime >= 100) {
                    Api.ECall("user32.dll", "SetWindowTextW", FormD.hwnd, "下载文件:" + (i < 0 ? "N/A" : Api.Format(down / i, "0.00%  ")) + Api.Format((down - downmark) / (time - downtime), "0.00") + "KB/S")
                    downtime = time
                    downmark = down
                }
            }
        })
        http.GetHttp(Url, Method, Data, Header, 1, whttp)
        FormD.SetUnloadEvent(function () {
            http.Clear()
        })
        FormD.Show(Mode & 1)
    }
}