VideoWatermark/dlg/test.aardio

190 lines
7.6 KiB
Plaintext
Raw Normal View History

2024-08-27 23:11:10 +08:00
import win.ui;
import mouse;
2024-08-27 23:11:10 +08:00
/*DSG{{*/
var winform = win.form(text="aardio form";right=759;bottom=469;composited=1;mode="popup")
2024-08-27 23:11:10 +08:00
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";notify=1;z=1}
2024-08-27 23:11:10 +08:00
)
/*}}*/
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) {
if (dragType == "top") {
var deltaY = y - startY;
winform.text = "Dragging top: deltaY=" + deltaY;
// 处理上边框拖动
if(startY == -1){
winform.plus.top -= 1;
}
else {
winform.plus.top += 1;
}
startY = y;
} else if (dragType == "bottom") {
var deltaY = y - startY;
winform.text = "Dragging bottom: deltaY=" + deltaY;
// 处理下边框拖动
winform.plus.height = winform.plus.height + deltaY;
startY = y;
} else if (dragType == "left") {
var deltaX = x - startX;
winform.text = "Dragging left: deltaX=" + deltaX;
// 处理左边框拖动
winform.plus.left = winform.plus.left + deltaX;
winform.plus.width = winform.plus.width - deltaX;
startX = x;
} else if (dragType == "right") {
var deltaX = x - startX;
winform.text = "Dragging right: deltaX=" + deltaX;
// 处理右边框拖动
winform.plus.width = winform.plus.width + deltaX;
startX = x;
} else if (dragType == "top-left") {
var deltaX = x - startX;
var deltaY = y - startY;
winform.text = "Dragging top-left: deltaX=" + deltaX + ", deltaY=" + deltaY;
// 处理左上角拖动
winform.plus.left = winform.plus.left + deltaX;
winform.plus.width = winform.plus.width - deltaX;
winform.plus.top = winform.plus.top + deltaY;
winform.plus.height = winform.plus.height - deltaY;
startX = x;
startY = y;
} else if (dragType == "top-right") {
var deltaX = x - startX;
var deltaY = y - startY;
winform.text = "Dragging top-right: deltaX=" + deltaX + ", deltaY=" + deltaY;
// 处理右上角拖动
winform.plus.width = winform.plus.width + deltaX;
winform.plus.top = winform.plus.top + deltaY;
winform.plus.height = winform.plus.height - deltaY;
startX = x;
startY = y;
} else if (dragType == "bottom-left") {
var deltaX = x - startX;
var deltaY = y - startY;
winform.text = "Dragging bottom-left: deltaX=" + deltaX + ", deltaY=" + deltaY;
// 处理左下角拖动
winform.plus.left = winform.plus.left + deltaX;
winform.plus.width = winform.plus.width - deltaX;
winform.plus.height = winform.plus.height + deltaY;
startX = x;
startY = y;
} else if (dragType == "bottom-right") {
var deltaX = x - startX;
var deltaY = y - startY;
winform.text = "Dragging bottom-right: deltaX=" + deltaX + ", deltaY=" + deltaY;
// 处理右下角拖动
winform.plus.width = winform.plus.width + deltaX;
winform.plus.height = 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.height += 1;
winform.plus.top -= 1;
}
winform.button2.oncommand = function(id,event){
winform.plus.top += 1;
}
2024-08-27 23:11:10 +08:00
winform.show();
win.loopMessage();