1、 aardio可以通过wndproc获得窗口消息,但并不能通过简单的返回true或false来达到拦截消息事件执行的目的。
2、在消息处理过程中,我们可以通过修改消息参数的内存数据,让消息按照我们的要求去执行。我觉得可以拿“堵不如疏”这个词语来形容,既然阻挡不了,我们就将他顺势改变一下。
![](https://img-blog.csdnimg.cn/3e99e857772449648d09bd6cc2e40de4.gif)
import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio form";right=349;bottom=469)
winform.add(
static={cls="static";text="最左边限制为200
最窄200最宽500";left=58;top=149;right=218;bottom=311;font=LOGFONT(h=-16);transparent=1;z=1}
)
/*}}*/
// 本例程由光庆编写
winform.show();
// 取屏幕宽度、高度
var screenw,screenh= win.getScreen();
// 限制窗口左边、上边、右边、下边距离
var lleft,ltop,lright,lbottom = 200,200,200,200
// 限制窗口最小宽度、最大宽度、最小高度、最大高度
var lwmin,lwmax,lhmin,lhmax = 300,500,300,500
// 处理窗口消息
winform.wndproc = function(hwnd,message,wParam,lParam){
if message= 0x216 /*_WM_MOVING*/ {
var m = {
struct reserved = ::POINT();
struct maxSize = ::POINT();
struct maxPosition = ::POINT();
struct minTrackSize = ::POINT();
struct maxTrackSize = ::POINT();
};
..raw.convert(..topointer(lParam),m)
if m.reserved.x<lleft {
m.reserved.x=lleft
m.maxSize.x=lleft+winform.width;
}
if m.reserved.y<ltop {
m.reserved.y=ltop
m.maxSize.y=ltop+winform.height;
}
if m.maxSize.x>screenw-lright {
m.reserved.x=screenw-lright-winform.width
m.maxSize.x=screenw-lright
}
if m.maxSize.y>screenh-lbottom {
m.reserved.y=screenh-lbottom-winform.height
m.maxSize.y=screenh-lbottom
}
..raw.convert(m,..topointer(lParam))
};
if message=0x24/*_WM_GETMINMAXINFO*/ {
var m = {
struct reserved = ::POINT();
struct maxSize = ::POINT();
struct maxPosition = ::POINT();
struct minTrackSize = ::POINT();
struct maxTrackSize = ::POINT();
};
..raw.convert(..topointer(lParam),m)
m.minTrackSize.x=lwmin;
m.maxTrackSize.x=lwmax;
m.minTrackSize.y=lhmin;
m.maxTrackSize.y=lhmax;
..raw.convert(m,..topointer(lParam))
};
}
win.loopMessage();
|