import win.ui; import mouse; /*DSG{{*/ var winform = win.form(text="aardio form";right=759;bottom=469;composited=1;mode="popup") winform.add( button={cls="button";text="向上拖动";left=538;top=138;right=673;bottom=199;z=2}; button2={cls="button";text="向下拖动";left=539;top=239;right=674;bottom=300;z=3}; plus={cls="plus";left=266;top=117;right=466;bottom=317;background="C:\Users\97975\Desktop\视频增加二维码\1_i2skbfmDsHayHhqPfwt6pA.png";border={color=-65536;width=3};clipBk=false;foreRepeat="stretch";foreground="C:\Users\97975\Desktop\视频增加二维码\1_i2skbfmDsHayHhqPfwt6pA.png";notify=1;z=1} ) /*}}*/ import console; // 定义边框宽度 var borderWidth = 5; var isDragging = false; var startX, startY; var dragType = ""; // 记录拖动的类型:"top", "bottom", "left", "right", "top-left", "top-right", "bottom-left", "bottom-right" // 重写plus控件的窗口过程函数 winform.plus.wndproc = function(hwnd, message, wParam, lParam){ var x, y = win.getMessagePos(lParam); if (message == 0x201) { // WM_LBUTTONDOWN // 获取plus控件的位置和大小 var rect = winform.plus.getClientRect(); winform.text = "Dragging: x=" + x + ", y=" + y; console.dump(rect.left, rect.top, rect.right, rect.bottom); // 上边框 if (x > rect.left + borderWidth && x < rect.right - borderWidth && y >= rect.top && y < rect.top + borderWidth) { console.dump("当前点击了上边框"); isDragging = true; dragType = "top"; startX = x; startY = y; } // 下边框 else if (x > rect.left + borderWidth && x < rect.right - borderWidth && y > rect.bottom - borderWidth && y <= rect.bottom) { console.dump("当前点击了下边框"); isDragging = true; dragType = "bottom"; startX = x; startY = y; } // 左边框 else if (x >= rect.left && x < rect.left + borderWidth && y > rect.top + borderWidth && y < rect.bottom - borderWidth) { console.dump("当前点击了左边框"); isDragging = true; dragType = "left"; startX = x; startY = y; } // 右边框 else if (x > rect.right - borderWidth && x <= rect.right && y > rect.top + borderWidth && y < rect.bottom - borderWidth) { console.dump("当前点击了右边框"); isDragging = true; dragType = "right"; startX = x; startY = y; } // 左上角 else if (x >= rect.left && x < rect.left + borderWidth && y >= rect.top && y < rect.top + borderWidth) { console.dump("当前点击了左上角"); isDragging = true; dragType = "top-left"; startX = x; startY = y; } // 右上角 else if (x > rect.right - borderWidth && x <= rect.right && y >= rect.top && y < rect.top + borderWidth) { console.dump("当前点击了右上角"); isDragging = true; dragType = "top-right"; startX = x; startY = y; } // 左下角 else if (x >= rect.left && x < rect.left + borderWidth && y > rect.bottom - borderWidth && y <= rect.bottom) { console.dump("当前点击了左下角"); isDragging = true; dragType = "bottom-left"; startX = x; startY = y; } // 右下角 else if (x > rect.right - borderWidth && x <= rect.right && y > rect.bottom - borderWidth && y <= rect.bottom) { console.dump("当前点击了右下角"); isDragging = true; dragType = "bottom-right"; startX = x; startY = y; } } else if (message == 0x200) { // WM_MOUSEMOVE if (isDragging) { var deltaX = x - startX; var deltaY = y - startY; if (dragType == "top") { winform.text = "Dragging top: deltaY=" + deltaY; // 处理上边框拖动 if (deltaY != 0) { winform.plus.top += deltaY; winform.plus.height -= deltaY; startY = y; } } else if (dragType == "bottom") { winform.text = "Dragging bottom: deltaY=" + deltaY; // 处理下边框拖动 if (deltaY != 0) { winform.plus.height += deltaY; startY = y; } } else if (dragType == "left") { winform.text = "Dragging left: deltaX=" + deltaX; // 处理左边框拖动 if (deltaX != 0) { winform.plus.left += deltaX; winform.plus.width -= deltaX; startX = x; } } else if (dragType == "right") { winform.text = "Dragging right: deltaX=" + deltaX; // 处理右边框拖动 if (deltaX != 0) { winform.plus.width += deltaX; startX = x; } } else if (dragType == "top-left") { winform.text = "Dragging top-left: deltaX=" + deltaX + ", deltaY=" + deltaY; // 处理左上角拖动 if (deltaX != 0 || deltaY != 0) { winform.plus.left += deltaX; winform.plus.width -= deltaX; winform.plus.top += deltaY; winform.plus.height -= deltaY; startX = x; startY = y; } } else if (dragType == "top-right") { winform.text = "Dragging top-right: deltaX=" + deltaX + ", deltaY=" + deltaY; // 处理右上角拖动 if (deltaX != 0 || deltaY != 0) { winform.plus.width += deltaX; winform.plus.top += deltaY; winform.plus.height -= deltaY; startX = x; startY = y; } } else if (dragType == "bottom-left") { winform.text = "Dragging bottom-left: deltaX=" + deltaX + ", deltaY=" + deltaY; // 处理左下角拖动 if (deltaX != 0 || deltaY != 0) { winform.plus.left += deltaX; winform.plus.width -= deltaX; winform.plus.height += deltaY; startX = x; startY = y; } } else if (dragType == "bottom-right") { winform.text = "Dragging bottom-right: deltaX=" + deltaX + ", deltaY=" + deltaY; // 处理右下角拖动 if (deltaX != 0 || deltaY != 0) { winform.plus.width += deltaX; winform.plus.height += deltaY; startX = x; startY = y; } } } } else if (message == 0x202) { // WM_LBUTTONUP if (isDragging) { isDragging = false; dragType = ""; winform.text = "Dragging ended"; } } // 无返回值则继续调用默认回调函数 } // 向上拖动,图片增高,上横线上移动 winform.button.oncommand = function(id, event){ winform.plus.top -= 1; } // 向下拖动,图片变矮,上横线下移动 winform.button2.oncommand = function(id, event){ winform.plus.top += 1; } winform.transparent(0) winform.plus.orphanWindow(); winform.show(); win.loopMessage();