//tooltip 提示控件
import win.ui;
import win.ui.ctrl.metaProperty;
namespace win.ui;
class tooltip{
ctor(winform,tParam){
this.parent = winform;
this.hParent = winform[["hwnd"]] : winform;
this.tooltips = {};
this.defaultFlags = 0;
if(tParam[["close"]] || tParam[["track"]] || tParam[["absolute"]]){
this.defaultFlags = 0x20/*_TTF_TRACK*/|0x1000/*_TTF_PARSELINKS*/;
if(tParam[["absolute"]]) this.defaultFlags = this.defaultFlags | 0x80/*_TTF_ABSOLUTE*/;
if(tParam[["close"]])tParam[["balloon"]] = true;
}
else{
this.defaultFlags = 0x10/*_TTF_SUBCLASS*/
}
this.cls = "tooltip";
this.className = "tooltips_class32";
this.disableDpiScaling = true;
if(type(tParam)!="number"){
var style = 0x80000000/*_WS_POPUP*/ ;
if(tParam[["balloon"]]){ style = style | 0x40/*_TTS_BALLOON*/ }
if(tParam[["close"]]){ style = style |0x80/*_TTS_CLOSE*/ }
if( tParam[["style"]] ) style = style | tParam[["style"]];
var exStyle = tParam[["exstyle"]] : 0;
if(tParam[["topmost"]] ){exStyle = exStyle | 8/*_WS_EX_TOPMOST*/}
this.hwnd = ::CreateWindowEx(exStyle, "tooltips_class32", , style,0, 0, 0, 0, this.hParent:0, 0 );
::SendMessageInt(this.hwnd, 0x418/*_TTM_SETMAXTIPWIDTH*/, 0,tParam[["maxTipWidth"]] : 410);
if(winform[["hwnd"]] && winform.add){
winform.add(this);
}
}
else {
this.hwnd = tParam;
}
};
@_metaProperty;
}
namespace tooltip {
balloon = function(form,tParam){
tParam = ..table.assign(tParam,{balloon=true});
if(!form) tParam.topmost = true;
return ..win.ui.tooltip(form,tParam);
}
tracking = function(form,close,balloon,topmost,absolute){
var tParam = ..table.assign(tParam,{
close = close;
balloon = balloon === null || balloon;
track = true;
});
if( !form ) {
tParam.topmost = true;
tParam.absolute = true;
}
var t = ..win.ui.tooltip(form,tParam);
return t;
}
class TOOLINFO {
INT cbSize = 44;
INT flags;
ADDR hOwner;//所有者窗口
ADDR hwnd;// 绑定的控件句柄,原名id
struct rect = ::RECT();
pointer hinst;
ustring text;
int lParam;
hTooltip = 0;
@_meta;
}
namespace TOOLINFO{
_meta = {
_get = {
sendMessage = function(msg,wParam){
::User32.SendMessage(owner.hTooltip,msg, wParam, owner);
return owner;
};
getText = function(){
return owner.text;
};
setText = function(text){
owner.text = topointer(text) == topointer(-1) ? topointer(text) : tostring(text);
::SendMessageByStruct(owner.hTooltip,0x439/*_TTM_UPDATETIPTEXTW*/, 0, owner);
return owner;
};
updateRect = function(rc){
if(rc) owner.rect = rc;
::SendMessageByStruct(owner.hTooltip,0x434/*_TTM_NEWTOOLRECTW*/, 0, owner);
return owner;
};
trackPopup = function(active,x,y){
if(active){
if(type.isString(active)) owner.setText(active);
if( (x===null) || (y===null)){
var pt = ::POINT()
if( ::User32.GetCursorPos(pt) ) x,y = pt.x,pt.y;
else x,y = ..win.getMessagePos()
x = x+::User32.GetSystemMetrics(0xD/*_SM_CXCURSOR*/)
}
::SendMessageInt(owner.hTooltip,0x412/*_TTM_TRACKPOSITION*/, 0, ::MAKELONG(x,y));
::SendMessage(owner.hTooltip,0x41D/*_TTM_UPDATE*/);
}
::User32.SendMessage(owner.hTooltip,0x411/*_TTM_TRACKACTIVATE*/,!!active, owner);
return owner;
};
delete = function(){
::SendMessageByStruct(owner.hTooltip, 0x433/*_TTM_DELTOOLW*/, 0, owner);
};
}
}
}
_metaProperty = ..win.ui.ctrl.metaProperty(
delTool = function(ti){
::SendMessageByStruct(owner.hwnd, 0x433/*_TTM_DELTOOLW*/, 0, ti);
};
addTool = function(ctrl,text,flags){
if( flags === null ) flags = owner.defaultFlags;
flags = flags | 1/*_TTF_IDISHWND*/ ;
var ti = TOOLINFO();
ti.hOwner = owner.hParent;
ti.flags = flags;
ti.text = topointer(text) == _INVALID_HANDLE_VALUE ? _INVALID_HANDLE_VALUE : text;
var hCtrl = ctrl[["hwnd"]] : ctrl : owner.hParent;
if( hCtrl && owner.tooltips[hCtrl] ){
owner.delTool(owner.tooltips[hCtrl]);
}
ti.hwnd = hCtrl;
ti.ctrl = ctrl;
::SendMessageByStruct(owner.hwnd, 0x432/*_TTM_ADDTOOLW*/, 0, ti);
ti.hTooltip = owner.hwnd;
if(hCtrl) owner.tooltips[hCtrl] = ti;
if(flags&0x20/*_TTF_TRACK*/)owner.lastTrackingToolInfo = ti;
owner.lastToolInfo = ti;
return ti;
};
addTrackingTool = function(ctrl,text,flags){
if(type(ctrl)==="string") ctrl,text = text,ctrl;
if(ctrl === null){
return owner.addTool(ctrl,text:"",(flags:0)|( 0x20/*_TTF_TRACK*/|0x80/*_TTF_ABSOLUTE*/|0x1000/*_TTF_PARSELINKS*/));
}
return owner.addTool(ctrl,text:"",(flags:0)|( 0x20/*_TTF_TRACK*/|0x1000/*_TTF_PARSELINKS*/));
};
add = function(ctrls){
if(!owner.parent[["hwnd"]]) error("创建提示控件时未指定父窗体",2);
var tis = {};
for(k,v in ctrls) tis[k] = owner.addTool(owner.parent[k],v);
return tis;
};
getTool = function(ctrl){
var ti;
if(!ctrl) {
if(!owner.lastToolInfo) owner.addTool();
return owner.lastToolInfo;
}
return owner.tooltips[ctrl[["hwnd"]]:ctrl];
};
getCurrentTool = function(){
var ti = TOOLINFO();
if( ::User32.SendMessage(owner.hwnd,0x43B/*_TTM_GETCURRENTTOOLW*/,0,ti) ){
ti.hTooltip = owner.hwnd;
return owner.tooltips[ti.hwnd] : ti;
}
};
adjustRect = function(rc,larger){
if( ::User32.SendMessage(owner.hwnd,0x41F/*_TTM_ADJUSTRECT*/,larger,rc) ){
return rc;
}
};
setText = function(text,ti){
if(!ti) ti = owner.getTool();
elseif(ti[["hwnd"]]){ ti = owner.tooltips[ti.hwnd] : ti;}
if(ti && ti.setText) return ti.setText(text);
else {
error("参数@2错误",2)
}
return ti;
};
setTitle = function(title,icon){
::User32.SendMessage(owner.hwnd,0x421/*_TTM_SETTITLE*/,icon,title:"");
return owner;
};
setInfo = function(title,large){
::User32.SendMessage(owner.hwnd,0x421/*_TTM_SETTITLE*/,large?4:1,title:"");
return owner;
};
setWarning = function(title,large){
::User32.SendMessage(owner.hwnd,0x421/*_TTM_SETTITLE*/,large?5:2,title:"");
return owner;
};
setError = function(title,large){
::User32.SendMessage(owner.hwnd,0x421/*_TTM_SETTITLE*/,large?6:3,title:"");
return owner;
};
setMaxWidth = function(width){
::SendMessageInt(owner.hwnd,0x418/*_TTM_SETMAXTIPWIDTH*/, 0, width);
return owner;
};
setDelayTime = function(time,flag){
::SendMessageInt(owner.hwnd,0x403/*_TTM_SETDELAYTIME*/,flag,time : -1);
return owner;
};
setBkColor = function(clr){
::SendMessageInt(owner.hwnd,0x413/*_TTM_SETTIPBKCOLOR*/,0,clr);
return owner;
};
setTextColor = function(clr){
::SendMessageInt(owner.hwnd,0x414/*_TTM_SETTIPTEXTCOLOR*/,0,clr);
return owner;
};
activate = function(active){
::User32.SendMessage(owner.hTooltip, 0x401/*_TTM_ACTIVATE*/,!!active,0);
};
trackPos = function(x,y){
if(x==null || y==null) x,y = ..win.getMessagePos();
::SendMessageInt(owner.hwnd,0x412/*_TTM_TRACKPOSITION*/, 0, ::MAKELONG(x,y));
return owner;
};
trackPopup = function(active,x,y){
if(!owner.lastTrackingToolInfo) owner.addTrackingTool();
if(owner.lastTrackingToolInfo) owner.lastTrackingToolInfo.trackPopup(active,x,y);
};
update = function(){
::SendMessage(owner.hwnd,0x41D/*_TTM_UPDATE*/);
};
popup = function(show){
if(!show) owner.capture = false;
return ::User32.SendMessage(owner.hwnd,show?0x422/*_TTM_POPUP*/:0x41C/*_TTM_POP*/,0,0);
};
ptInClientRect = function(x,y){
if(y===null) x,y = ..win.getMessagePos(x);
return owner.getClientRect().contains(x,y);
};
_prenotify = {
[0xFFFFFDF6/*_TTN_POP*/] = function(id,code,ptr){
if(::User32.GetCapture()==owner.hwnd){
::User32.ReleaseCapture();
}
if(owner.onPopupHide)owner.onPopupHide();
};
[0xFFFFFDF7/*_TTN_SHOW*/] = function(id,code,ptr){
if(owner.onPopupShow)owner.onPopupShow();
};
[0xFFFFFDF5/*_TTN_LINKCLICK*/] = function(id,code,ptr){
var href,title = ..string.match(owner.text,"\<[aA](.*)>(.+)\[aA]>");
if(#href){
var _,_,h = ..string.match( href,`(\shref\s*=\s*(["'])([^"']+)\2)`);
href = h;
}
if(!#href) href = title;
if(!#href) return;
owner.popup(false);
owner.onHyperlinkClick(href,title);
};
};
getNotifyCustomDraw = function(code,ptr){
if(type(ptr)!="pointer") error("请指定有效NM_CUSTOMDRAW指针",2)
if( code == 0xFFFFFFF4/*_NM_CUSTOMDRAW*/ ){
var lvcd = ..raw.convert(ptr,{
struct hdr = { addr hwndFrom; ADDR idFrom; INT code; }
int dwDrawStage;
pointer hdc;
struct rc = ::RECT();//Handling subitem pre-paint messages on Windows XP receives incorrect top and bottom values
addr dwItemSpec;
int uItemState;
pointer lItemlParam;
INT drawFlags;
} );
lvcd.update = function(){
..raw.mixin(ptr,lvcd);
}
return lvcd;
}
};
capture = {
_set = function( v ){
if(v) {
..win.setCapture(owner[["hwnd"]]);
::User32.SetCursor(__cursor_arrow);
}
else if(::User32.GetCapture()==owner.hwnd)
..win.releaseCapture();
}
_get = function(){
return owner.hwnd == ::User32.GetCapture();
}
};
//@Deprecated
relayEvent = function(msg){
::SendMessageByStruct(owner.hwnd,0x407/*_TTM_RELAYEVENT*/,0,msg);
};
)
__cursor_arrow = ::User32.LoadCursor(,0x7F00/*_IDC_ARROW*/) ;
}
/**details(命名约定)
1、一个提示控件指的是一个 win.ui.tooltip 控件,
原生控件类名 "tooltips_class32",在 aardio 里的类名是 "tooltip",
在代码里我们把提示控件我们可以简称为 tooltip 或者 tooltipCtrl。
这个控件比较特别,没有写在 win.ui.ctrl 命名空间下,也不是由 win.form 创建。
但 win.ui.tooltip 实际上继承了 win.ui.ctrl.metaProperty,仍然由所有者窗口管理。
提示控件有一点像 aardio 里的 orphanWindow 是一个独立窗口,
所以他没有父窗口而是叫所有者窗口(为便于管理,tooltip 控件 仍然拥有 _parentForm 属性指向所有者窗口),
但 tooltip 控件 不会跟随所有者窗口自适应调整显示位置,更不会做 DPI 缩放。
因为这些事 tooltip 控件自己做了。
2、一个提示控件有一个上层所有者窗口(创建提示控件的时候指定)。
3、一个「提示控件」可以管理多个「控件提示」,这里有点绕,不要弄反了。
控件提示 —— 也就是 TOOLINFO 结构体,TOOLINFO 类的完整路径为 win.ui.tooltip.TOOLINFO。
一个控件提示(TOOLINFO)可以关联一个控件窗口,这指的是所有者窗体上的控件窗口。
当然控件提示(TOOLINFO)也可以关联所有者窗体自己。
一个提示控件里一个窗口对象只能关联一个控件提示(TOOLINFO),
实际上你也不可能关联多个,哪有鼠标晃上去多个提示蹦出来乱跳呢。
「控件提示」在代码里会称为 toolinfo 或者缩写为 tool,
例如 addTool() 就是添加 TOOLINFO, 而 getCurrentTool() 就是获取当前控件提示。
end details**/
/**intellisense()
win.ui.tooltip = 提示控件,\n提示控件可以有一个所有者窗体,这应当是一个 win.form 对象,\n一个提示控件可以管理多个控件提示( 也就是 TOOLINFO 对象 )\n而每个 TOOLINFO 对象应关联一个所有者窗体上的控件窗口,\n当然 TOOLINFO 也可以关闭所有者窗体自己,\n同一个提示控件里同一个窗口只能关闭一个 TOOLINFO,\n同一控件关联多次会自动覆盖并删除之前创建的关联TOOLINFO
win.ui.tooltip() = !winUiTooltip.
win.ui.tooltip( = 创建提示控件,\n提示控件可以有一个所有者窗体,这应当是一个 win.form 对象,\n一个提示控件可以管理多个控件提示( 也就是 TOOLINFO 对象 )\n而每个 TOOLINFO 对象应关联一个所有者窗体上的控件窗口,\n当然 TOOLINFO 也可以关闭所有者窗体自己,\n同一个提示控件里同一个窗口只能关闭一个 TOOLINFO,\n同一控件关联多次会自动覆盖并删除之前创建的关联TOOLINFO
win.ui.tooltip(.(所有者窗体,创建参数表) = 创建提示控件,参数 @1 可选指定所有者窗体对象或句柄。\n参数 @2 可选使用一个表对象指定创建选项与样式,支持以下字段(每个都是可选的):\n- track: 添加提示时是否默认添加 _TTF_TRACK 选项(手动控制显示与隐藏)。\n- absolute: 添加提示时是否默认添加 _TTF_ABSOLUTE 选项。\n指定 _TTF_ABSOLUTE 则 trackPopup 方法的显示在指定的坐标而不会自动调整。\n此字段为 true 时 track 字段也会自动设为 true。\n- close: 是否显示关闭按钮,设为 true 时 balloon 与 track 字段自动设为 true\n- balloon: 是否显示为汽泡提示。\n- maxTipWidth: 最大宽度。\n- topmost: 是否置顶显示\n- style: 指定窗口样式的数值,总是自动指定 _WS_POPUP \n- exstyle: 指定窗口扩展样式的数值,总是自动指定 _WS_EX_TOOLWINDOW
win.ui.tooltip(.(所有者窗体,提示控件句柄) = 绑定现有提示控件,\n参数@1可选指定所有者窗体对象或所有者窗体句柄,\n参数@2指定现有提示控件句柄
win.ui.tooltip.balloon() = !winUiTooltip.
win.ui.tooltip.balloon( = 创建汽泡外观提示控件,\n一个提示控件有一个所有者窗体,\n提示控件可以管理多个控件提示(TOOLINFO),\n每个TOOLINFO关联一个控件窗口,\n每个控件窗口同时只能关联一个TOOLINFO
win.ui.tooltip.balloon(.(所有者窗体,创建参数) = 创建汽泡外观提示控件,参数@1为窗体对象,\n参数@2使用一个表指定创建选项与样式,可省略,\n参数@2的详细用法请参考源码与MSDN文档
win.ui.tooltip.tracking() = !winUiTooltip.
win.ui.tooltip.tracking( = 创建提示控件,默认使用默认手动跟踪模式,\n一个提示控件有一个所有者窗体,\n提示控件可以管理多个控件提示(TOOLINFO),\n每个TOOLINFO关联一个控件窗口,\n每个控件窗口同时只能关联一个TOOLINFO
win.ui.tooltip.tracking(.(ownerForm,hasCloseButton,balloon,topmost,absolute) = 创建提示控件,默认使用默认手动跟踪模式,\n@ownerForm 参数指定所有者窗口,省略则设置参数 @topmost,@absolute 为 true ,\n@hasCloseButton 参数指定是否显示关闭按钮,可省略,默认值为 true \n@balloon 参数指定是否启用汽泡外观,可省略默认值为 true \n@topmost 参数指定是否置顶显示\n@absolute 参数指定 trackPopup 方法是否使用绝对坐标(禁用自动调整)
end intellisense**/
/**intellisense(!winUiTooltip)
defaultFlags = 添加提示的默认选项,根据创建参数表自动设置。\ndefaultFlags 指定 _TTF_TRACK 则为手动控制显示与隐藏提示。\ndefaultFlags 指定 _TTF_SUBCLASS 则为自动显示与隐藏提示。\n调用 addTool 方法且显式指定 flags 参数时忽略默认选项。
text = 当前显示文本,\n包含提示标题与内容,\n此属性只读,
setMaxWidth(.(宽度) = 设置提示框最大宽度
setDelayTime(.(超时值,选项) = 光标在控件上悬停并超出一定时间才会显示,\n默认值约为半秒,此函数可修改默认的超时值\n以毫秒为单位,\n选项为可选参数,默认为 0/*_TTDT_AUTOMATIC*/
setTextColor(.(颜色值) = 设置文本颜色
setBkColor(.(颜色值) = 设置背景颜色
setTitle(.(title,icon) = 设置@title参数指定的标题,\n可选用@icon参数指定图标句柄,\n工具有标题才会显示图标,\n只设置标题不设置文本则不会显示
setInfo(.(title,large) = 设置@title参数指定的标题,并显示信息图标,\n可选用@large指定是否使用大图标
setWarning(.(title,large) = 设置@title参数指定的标题,并显示警告图标,\n可选用@large指定是否使用大图标
setError(.(title,large) = 设置@title参数指定的标题,并显示错误图标,\n可选用@large指定是否使用大图标
add(__) = 批量添加控件提示\n参数应使用一个表指定多个控件的提示文本,\n表成员的键为控件名,值为控件提示
addTool( = 创建并返回 TOOLINFO 对象,\n提示控件与绑定控件应在同一线程中
addTool(.(ctrl,text,flags) = 创建并返回默认 TOOLINFO 对象,\n@ctrl参数指定控件对象,省略则设为提示控件所有窗口\n同一窗口在同一提示控件里只能绑定同一个TOOLTIP,\n如果窗口之前添加了提示会先删除之前的再添加,\n@flags为_TTF_前缀常量组合
addTrackingTool( = 创建手动跟踪模式的 TOOLINFO 对象,\n可使用 trackPopup 函数在指定坐标显示,\n如果提示控件指定所有窗口并设置标题、启用关闭按钮则可支持超链接
addTrackingTool(.(ctrl,text,flags) = 创建手动跟踪模式的 TOOLINFO 对象。\n此提示默认添加 _TTF_TRACK 选项,必须使用 trackPopup 函数控制显示或隐藏。\n- 可选用 @ctrl 参数指定一个关联控件,省略则设为提示控件所有窗口。 \n如果同一窗口之前添加了提示会先删除之前的再添加。\n如果未指定 @ctrl 参数则默认添加 _TTF_ABSOLUTE 选项。\n- 可选用 @text 参数指定显示文本,支持超链接。\n嵌入超链接格式:`超链接`,\n- @flags为可选参数,可指定 _TTF_ 前缀常量组合的数值
trackPopup( = 此函数调用最后一次创建的手动跟踪模式 TOOLINFO 对象(启用了 _TTF_TRACK 选项)。\n这指的是在调用此函数以前执行过以下操作(其中之一):\n1、调用 addTrackingTool 函数\n2、win.ui.tooltip.tracking 创建的提示控件调用以默认 flags 创建提示的部分函数\n这包括 addTool, setText 等函数\n\n注意调用此函数显示的提示提示默认不会自动隐藏,\nwinex.tooltip 在调用此函数后设置 capture 为 true 支持点击隐藏
trackPopup(.(true,x,y) = 弹出提示。\n可选用 x,y 参数指定屏幕显示坐标,不指定则取最后一次鼠标消息屏幕坐标。\n指定 _TTF_ABSOLUTE 选项的提示 x,y 为显示坐标,否则以 x,y 为关联坐标自动调整显示位置。\n注意 x,y 始终使用屏幕坐标系,_TTF_ABSOLUTE 并不改变坐标系。\n此函数返回显示的 TOOLINFO 对象
trackPopup(.(text,x,y) = 弹出参数 @text 指定文本内容的提示。\n可选用 x,y 参数指定屏幕显示坐标,不指定则取最后一次鼠标消息屏幕坐标。\n指定 _TTF_ABSOLUTE 选项的提示 x,y 为显示坐标,否则以 x,y 为关联坐标自动调整显示位置。\n注意 x,y 始终使用屏幕坐标系,_TTF_ABSOLUTE 并不改变坐标系。\n此函数返回显示的 TOOLINFO 对象
trackPopup(.(false) = 隐藏弹出的提示
trackPopup() = !winUiTooltipInfo.
delTool(.(ctrl) = 删除提示\n参数@1请使用窗口控件对象,\n如果控件尚未添加提示则忽略不操作
delTool(.(toolInfo) = 删除提示\n参数@1请使用addTool函数的返回值
setText(.(text,ctrlOrToolInfo) = 更新提示文本,\n提示必须有文本,否则不会显示,\naddTrackingTool 函数创建的提示支持超链接,\n提示文本中嵌入超链接格式超链接,\n可选用参数@ctrlOrToolInfo指定控件或TOOLINFO结构体,\n如果不指定则默认使用最后一次添加的TOOLINFO结构体,\n成功返回TOOLINFO结构体
getTool(.(ctrl) = 参数指定控件对象\n返回该控件关联的TOOLINFO结构体\n不指定参数返回最后一次添加的TOOLINFO结构体
getCurrentTool() = 返回提示控件当前正在使用的 TOOLINFO 对象\n!winUiTooltipInfo.
trackPos(.(x,y) = 移动到指定坐标,\n省略参数是移动到最后一次处理鼠标消息的坐标,\n请使用trackPopup函数控制显示和隐藏\n此函数返回自身
activate(.(true) = 激活提示控件
activate(.(false) = 停用提示控件,相当于禁用提示,\n提示控件在非活动状态时,即使鼠标指针位于绑定的控件窗口上也不会出现提示
ptInClientRect( = 判断指定的坐标是否在客户区内
ptInClientRect(.(x,y) = x,y 坐标是否在客户区内
ptInClientRect(.(lParam) = 使用窗口消息回调函数的 lParam 参数获取 x,y 坐标,\n如果 x,y 坐标在客户区内返回 true
update() = 刷新
lastToolInfo = 最后一次添加的提示结构体\n!winUiTooltipInfo.
lastTrackingToolInfo = 最后一次添加的手动跟踪模式提示结构体\n!winUiTooltipInfo.
addTool() = !winUiTooltipInfo.
getTool() = !winUiTooltipInfo.
setText() = !winUiTooltipInfo.
setTitle() = !winUiTooltip.
setInfo() = !winUiTooltip.
setWarning() = !winUiTooltip.
setError() = !winUiTooltip.
addTrackingTool() = !winUiTooltipInfo.
trackPos() = !winUiTooltipInfo.
close() = 关闭提示控件
getParent() = 返回父窗口\n!winform.
capture = 是否捕获全局鼠标消息\n\nwinex.tooltip 对象如果在调用 trackPopup 后设置此属性为 true,\n则支持点击自动隐藏提示
onHyperlinkClick(href,title) = @.onHyperlinkClick = function(href,title){
__/*点击了超链接,\n@href 为链接地址,@title 参数为超链接包含文本,\n提示文本中嵌入超链接格式超链接\n一个提示里只能写一个超链接,不要写多个*/
}
onPopupHide() = @.onPopupHide = function(){
__/*隐藏提示触发此通知。\n\n父窗口不是 win.form 对象则此事件不可用,\n替代方法是在此控件的 wndproc 回调中处理 _WM_SHOWWINDOW 消息*/
}
onPopupShow() = @.onPopupShow = function(){
__/*显示提示触发此通知。\n\n父窗口不是 win.form 对象则此事件不可用,\n替代方法是在此控件的 wndproc 回调中处理 _WM_SHOWWINDOW 消息*/
}
popup(false) = 隐藏提示\n不触发onPopupHide
onDestroy = @.onDestroy = function(){\n __/*窗口销毁前触发*/\n}
onnotify = @.onnotify = function(id,code,ptr){\n __/*通知事件触发*/\n}
wndproc = @.wndproc = function(hwnd,message,wParam,lParam){\n __/*窗口消息回调,返回任意非null值阻止默认回调\nwndproc重复赋值时追加函数而不是覆盖之前的回调\n设为null添除所有消息回调函数\nwndproc也可以是一个表,键要为处理的消息,值为对应的消息回调函数*/ \n}
wait(.(等待函数,超时,延时间隔) = 循环执行等待函数,并等待返回值\n直到等待函数返回非空值,或存在第二个返回值,或当前窗口关闭\n等待函数返回的值就是wait函数的返回值,\n如果指定超时,超过指定毫秒时返回null,\n除等待函数以外,所有参数可选
sendMessage(.(msg,wParam,lParam) = 发送窗口消息\n此函数用法请参考 ::User32.SendMessage
postMessage(.(msg,wParam,lParam) = 投递窗口消息到消息队列中\n此函数用法请参考 ::User32.PostMessage
getRoot() = 获取顶层父窗口
setPos(.(x坐标,y坐标,宽,高,插入位置,参数) = 调整窗口位置或排序,所有参数可选\n同时指定x,y坐标则移动位置\n同时指定宽高则改变大小\n指定插入位置(句柄或_HWND前缀常量)则调整Z序
getPos() = 返回相对父窗口客户区的坐标,宽,高,\n参数为true返回屏幕坐标,宽,高,\nx,y,cx,cy=win.getPos(hwnd)
show(true__) = 显示控件
getRect() = 控件区块位置(::RECT结构体)
getRect(true) = 控件屏幕区块位置(::RECT结构体)
setRect(rc) = 设置控件区块位置(::RECT结构体)
setRect(rc,true) = 设置控件屏幕区块位置(::RECT结构体)
getClientRect() = 控件客户区块位置(::RECT结构体)\n!rect.
getFont() = 控件字体(::LOGFONT结构体)\n!logfont.
setFont(__/*指定字体*/) = 指定LOGFONT字体对象,或逻辑字体句柄
setFont(混入字体属性) = @.setFont(point=10;name="宋体");
modifyStyle(.(remove,add,swpFlags) = 修改窗口样式,所有参数都是可选参数,\n@remove 用数值指定要移除的样式,可使用 _WS_ 前缀的常量\n@add 用数值指定要添加的样式,可使用 _WS_ 前缀的常量\n@swpFlags 可选用数值指定调整窗口选项,可使用 _SWP_ 前缀的常量\n如果指定了 @swpFlag ,则使用该参数调用::SetWindowPos\n细节请参考 win.modifyStyle 函数源码
modifyStyleEx(.(remove,add,swpFlags) = 修改窗口扩展样式,所有参数都是可选参数,\n@remove 用数值指定要移除的样式,可使用 _WS_EX_ 前缀的常量\n@add 用数值指定要添加的样式,可使用 _WS_EX_ 前缀的常量\n@swpFlags 可选用数值指定调整窗口选项,可使用 _SWP_ 前缀的常量\n如果指定了 @swpFlag ,则使用该参数调用::SetWindowPos\n细节请参考 win.modifyStyle 函数源码
redraw() = 刷新
adjustRect( = 对工具提示控件的文本显示矩形与其窗口矩形之间进行自适应转换
adjustRect(.(rc,true) = 参数 @rc 必须是一个指定文本显示的矩形的 ::RECT 结构\n调整该结构体为相应的窗口矩形,并返回该结构体
adjustRect(.(rc,false) = 参数 @rc 必须是一个指定窗口矩形的 ::RECT 结构\n调整该结构体为相应的文本显示矩形,并返回该结构体
getRect() = !rect.
adjustRect() = !rect.
getNotifyCustomDraw(code,ptr) = NM_CUSTOMDRAW通知消息返回NMLVCUSTOMDRAW结构体
getNotifyCustomDraw() = !NMTTCUSTOMDRAW.
end intellisense**/
/**intellisense(!winUiTooltipInfo)
sendMessage(msg,wParam) = 发送消息,用法参考此函数源码\n此函数返回自身
getText() = 返回提示文本
setText(.(text) = 设置文本\n如果值不是-1或指针则调用 tostring 函数转换为字符串,\n@text参数指定要更新的提示文本,\n提示必须有文本,否则不会显示,\n此函数返回自身
updateRect() = 修改 rect 字段指定的提示矩形区域后必须调用此函数更新\n可选在参数中指定新的 ::RECT 对象,\n此函数返回自身
trackPopup( = 弹出提示。\n适用于手动跟踪模式 TOOLINFO 对象(启用了 _TTF_TRACK 选项)
trackPopup(.(true,x,y) = 弹出提示。\n可选用 x,y 参数指定屏幕显示坐标,不指定则取最后一次鼠标消息屏幕坐标。\n\n指定 _TTF_ABSOLUTE 选项的提示 x,y 为显示坐标,否则以 x,y 为关联坐标自动调整显示位置。\n注意 x,y 始终使用屏幕坐标系,_TTF_ABSOLUTE 并不改变坐标系。\n此函数返回自身
trackPopup(.(text,x,y) = 弹出参数 @text 指定文本内容的提示。\n可选用 x,y 参数指定屏幕显示坐标,不指定则取最后一次鼠标消息屏幕坐标。\n\n指定 _TTF_ABSOLUTE 选项的提示 x,y 为显示坐标,否则以 x,y 为关联坐标自动调整显示位置。\n注意 x,y 始终使用屏幕坐标系,_TTF_ABSOLUTE 并不改变坐标系。\n此函数返回自身
trackPopup(.(false) = 隐藏弹出的提示
delete() = 删除提示
trackPopup() = !winUiTooltipInfo.
setText() = !winUiTooltipInfo.
sendMessage() = !winUiTooltipInfo.
updateRect() = !winUiTooltipInfo.
ctrl = 创建提示绑定的控件对象\n!static.
end intellisense**/
/**intellisense(!NMTTCUSTOMDRAW)
update() = 更新数据
dwDrawStage = 绘图状态
hdr = !nmhdr.
hdc = 设置句柄
rc = !rect.
dwItemSpec = 行序号
uItemState = 状态值,例如 _CDIS_FOCUS
lItemlParam = 自定义数据,LPARAM 参数
drawFlags = 提示文本显示格式\n此属性会用于 ::DrawText 的 uFormat 参数
end intellisense**/
//https://docs.microsoft.com/en-us/windows/win32/controls/tooltip-styles
/**intellisense()
_TTS_ALWAYSTIP=@1/*_TTS_ALWAYSTIP*/
_TTS_NOPREFIX=@2/*_TTS_NOPREFIX*/
_TTS_NOANIMATE=@0x10/*_TTS_NOANIMATE*/
_TTS_NOFADE=@0x20/*_TTS_NOFADE*/
_TTS_BALLOON=@0x40/*_TTS_BALLOON*/
_TTS_CLOSE=@0x80/*_TTS_CLOSE*/
_TTF_IDISHWND=@1/*_TTF_IDISHWND*/
_TTF_CENTERTIP=@2/*_TTF_CENTERTIP*/
_TTF_RTLREADING=@4/*_TTF_RTLREADING*/
_TTF_TRACK=@0x20/*_TTF_TRACK*/
_TTF_ABSOLUTE=@0x80/*_TTF_ABSOLUTE*/
_TTF_TRANSPARENT=@0x100/*_TTF_TRANSPARENT*/
_TTF_PARSELINKS=@0x1000/*_TTF_PARSELINKS*/
_TTF_DI_SETITEM=@0x8000/*_TTF_DI_SETITEM*/
_TTN_FIRST=@0xFFFFFDF8/*_TTN_FIRST*/
_TTN_LAST=@0xFFFFFFCA/*_TTN_LAST*/
_TTN_GETDISPINFO=@0xFFFFFDF8/*_TTN_GETDISPINFO*/
_TTN_SHOW=@0xFFFFFDF7/*_TTN_SHOW*/
_TTN_POP=@0xFFFFFDF6/*_TTN_POP*/
_TTN_LINKCLICK=@0xFFFFFDF5/*_TTN_LINKCLICK*/
_TTN_NEEDTEXT=@0xFFFFFDF8/*_TTN_NEEDTEXT*/
end intellisense**/