优化二维码操作体验
This commit is contained in:
parent
76e438d761
commit
39e3dacddb
|
@ -5,5 +5,6 @@
|
|||
<folder name="窗体文件" path="dlg" comment="目录" embed="true" local="false" ignored="false">
|
||||
<file name="qrcode.aardio" path="dlg\qrcode.aardio" comment="dlg\qr_code.aardio"/>
|
||||
<file name="test.aardio" path="dlg\test.aardio" comment="dlg\test.aardio"/>
|
||||
<file name="test2.aardio" path="dlg\test2.aardio" comment="dlg\test2.aardio"/>
|
||||
</folder>
|
||||
</project>
|
||||
|
|
BIN
dist/视频添加二维码.exe
vendored
BIN
dist/视频添加二维码.exe
vendored
Binary file not shown.
|
@ -3,7 +3,7 @@ import win.region.hole;
|
|||
/*DSG{{*/
|
||||
var winform = win.form(text="aardio form";right=304;bottom=297;border="none";exmode="none";mode="popup")
|
||||
winform.add(
|
||||
plus={cls="plus";left=0;top=0;right=305;bottom=298;ah=1;aw=1;clipBk=false;db=1;dl=1;dr=1;dt=1;transparent=1;z=1}
|
||||
plus={cls="plus";left=0;top=0;right=305;bottom=298;ah=1;aw=1;border={color=-65536;width=2};clipBk=false;db=1;dl=1;dr=1;dt=1;transparent=1;z=1}
|
||||
)
|
||||
/*}}*/
|
||||
|
||||
|
@ -19,13 +19,14 @@ subscribe("getQrcode",function(...){
|
|||
winform.plus.background = qrcodePath;
|
||||
} )
|
||||
|
||||
/*
|
||||
winform.wndproc = function(hwnd, message, wParam, lParam) {
|
||||
select(message) {
|
||||
case 0x201/*_WM_LBUTTONDOWN*/{
|
||||
case 0x201{//_WM_LBUTTONDOWN
|
||||
//点击左键移动窗体
|
||||
winform.hitCaption()
|
||||
//winform.hitCaption()
|
||||
}
|
||||
case 0x205/*_WM_RBUTTONUP*/{
|
||||
case 0x205{//_WM_RBUTTONUP
|
||||
//右键菜单
|
||||
var popmenu = win.ui.popmenu(winform);
|
||||
popmenu.add('关闭',
|
||||
|
@ -36,6 +37,7 @@ winform.wndproc = function(hwnd, message, wParam, lParam) {
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
import win.ui.layered;
|
||||
win.ui.layered(winform);
|
||||
|
|
200
dlg/test.aardio
200
dlg/test.aardio
|
@ -1,193 +1,19 @@
|
|||
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 mainForm = win.form(text="父窗口");
|
||||
|
||||
// 定义边框宽度
|
||||
var borderWidth = 5;
|
||||
var isDragging = false;
|
||||
var startX, startY;
|
||||
var dragType = ""; // 记录拖动的类型:"top", "bottom", "left", "right", "top-left", "top-right", "bottom-left", "bottom-right"
|
||||
// 创建子窗口
|
||||
var childForm = mainForm.loadForm("\dlg\test2.aardio");
|
||||
|
||||
// 重写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;
|
||||
}
|
||||
// 设置子窗口的父窗口为 mainForm
|
||||
win.setParent(childForm.hwnd, mainForm.hwnd);
|
||||
|
||||
// 向下拖动,图片变矮,上横线下移动
|
||||
winform.button2.oncommand = function(id, event){
|
||||
winform.plus.top += 1;
|
||||
}
|
||||
winform.transparent(0)
|
||||
winform.plus.orphanWindow();
|
||||
winform.show();
|
||||
win.loopMessage();
|
||||
|
||||
// 显示父窗口和子窗口
|
||||
mainForm.show();
|
||||
childForm.show();
|
||||
childForm.setPos(0,0);
|
||||
// 启动消息循环
|
||||
win.loopMessage();
|
||||
|
|
23
main.aardio
23
main.aardio
|
@ -135,6 +135,29 @@ mainForm.plus2.oncommand = function(id,event){
|
|||
frmChild = mainForm.loadForm("\dlg\qrcode.aardio");
|
||||
publish("getQrcode", path, imgW, imgH);
|
||||
frmChild.show();
|
||||
frmChild.wndproc = function(hwnd,message,wParam,lParam){
|
||||
import mouse
|
||||
select(message) {
|
||||
case 0x201/*_WM_LBUTTONDOWN*/{
|
||||
//点击左键移动窗体
|
||||
frmChild.hitCaption()
|
||||
}
|
||||
case 0x46/*_WM_WINDOWPOSCHANGING*/{
|
||||
// 窗口位置即将改变时
|
||||
//var x,y = win.getMessagePos(lParam);
|
||||
//x, y = mouse.getPos();
|
||||
//mainForm.text = x ++ "," ++ y;
|
||||
}
|
||||
case 0x47/*_WM_WINDOWPOSCHANGED*/{
|
||||
// 窗口位置已经改变时
|
||||
//x, y = mouse.getPos();
|
||||
//mainForm.text = x ++ "---" ++ y;
|
||||
}
|
||||
case 0x232/*_WM_EXITSIZEMOVE*/{
|
||||
// 用户停止拖动窗口或调整窗口大小时
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user