简单窗口示例
本帖最后由 鹿其 于 2024-9-15 07:45 编辑import fonts.fontAwesome;
import win.ui;
import win.ui.css;
import win.dlg.message;
/*DSG{{*/
var winform = win.form(text="aardio form";right=759;bottom=469;border="none")
winform.add(
bk={cls="bk";left=0;top=0;right=760;bottom=46;aw=1;bgcolor=13816530;forecolor=15790320;linearGradient=1;z=1};
captain={cls="static";text="简单窗口实例";left=41;top=5;right=518;bottom=29;center=1;dl=1;dt=1;font=LOGFONT(h=-14);transparent=1;z=3};
plus1={cls="plus";left=530;top=56;right=582;bottom=82;dr=1;dt=1;iconColor=16480006;iconStyle={font=LOGFONT(h=-24;name='FontAwesome')};iconText='\uF204';notify=1;z=7};
plusButton={cls="plus";text="切换按钮";left=583;top=420;right=743;bottom=452;font=LOGFONT(h=-16);iconStyle={align="left";font=LOGFONT(h=-15;name='FontAwesome');padding={left=30}};iconText='\uF030';notify=1;textPadding={left=30};z=2};
plusColor={cls="plus";text="点我改变背景";left=113;top=245;right=307;bottom=314;bgcolor=15780518;font=LOGFONT(h=-18);notify=1;z=9};
plusIcon={cls="plus";left=2;top=2;right=34;bottom=34;dl=1;dt=1;iconColor=12601344;iconStyle={font=LOGFONT(h=-20;name='FontAwesome')};iconText='\uF2DA';z=4};
plusTopSwitch={cls="plus";left=681;top=56;right=717;bottom=82;dr=1;dt=1;notify=1;z=6};
plusTopmost={cls="plus";text="置顶";left=620;top=0;right=658;bottom=25;dr=1;dt=1;font=LOGFONT(h=-14);notify=1;z=5};
static={cls="static";text="点我改变颜色";left=113;top=174;right=307;bottom=205;align="center";font=LOGFONT(h=-18);notify=1;transparent=1;z=8};
static2={cls="static";text="拖我移动窗口";left=338;top=245;right=532;bottom=314;align="center";border=1;center=1;font=LOGFONT(h=-18);notify=1;transparent=1;z=10}
)
/*}}*/
import win.ui.simpleWindow;
win.ui.simpleWindow(winform,16,,,42);
import win.region.round;
win.region.round(winform,,,15,15);
win.ui.shadow(winform).transparent(0.2);
//用于配置文件
import fsys.config;
varfsys = fsys.config()
//简单窗口标题栏按钮样式
titlebarCSS= class {
//最小最大化按钮样式
minmax = {
background = {
hover = 0xFFE2E2E2;
active = 0xFFD1D1D1;
default = 0x00000000
}
color = {
hover = 0xff666666;
//active = 0xffffffff;
default = 0xFF696969
}
}
//关闭按钮样式
close = {
background = {
hover = 0xFFFF6347;
active = 0xFFE14848;
default = 0x00000000
}
color = {
hover = 0xffffffff;
active = 0xffffffff;
default = 0xFF696969
}
}
//置顶按钮样式
topmost = {
background = {
hover = 0x82FFFFFF;
active = 0xFFC0C0C0;
default = 0x00000000
}
color = {
active = 0xffffffff;
default = 0xFF696969;
};
checked = {
background = {
hover = 0xFFB9B9B9;
default = 0xFFC0C0C0
}
color={
default = 0xFFFFFFFF;
}
}
}
switch = function(plus, size = 45, off = 0xFFD3D3D3, on = 0xFF409EFF) {
plus.iconStyle = {
align = "left";
font = LOGFONT(h = -size; name = 'FontAwesome')
}
plus.iconText = '\uF204'
plus.skin({
color = {
default = off;
};
checked = {
color = {
default = on;
};
iconText = '\uF205'
}
})
}
}
barCss = titlebarCSS()
winform.titlebarMin.skin(barCss.minmax);
winform.titlebarMax.skin(barCss.minmax);
winform.titlebarClose.skin(barCss.close);
winform.plusTopmost.skin(barCss.topmost);
winform.plusButton.skin(barCss.topmost);
//窗口置顶按钮开关样式
barCss.switch(winform.plusTopSwitch,24,0xFF696969,0xFF0677FB);
//窗口置顶
var isTopmost = false;
winform.plusTopmost.oncommand = function(id,event){
isTopmost = !isTopmost
win.setTopmost(winform.hwnd,isTopmost)
}
winform.plusButton.oncommand = function(id,event){
isTopmost = !isTopmost
winform.captain.text = owner.text ++""++ tostring( isTopmost);
}
winform.plusTopSwitch.oncommand = function(id,event){
isTopmost = !isTopmost
win.setTopmost(winform.hwnd,isTopmost)
}
//这种方式图标的颜色不能变,但是已经满足大多数情况
winform.plus1.oncommand = function(id,event){
isTopmost = !isTopmost
win.setTopmost(winform.hwnd,isTopmost)
owner.iconText = isTopmost ?'\uF205':'\uF204';
//逻辑与,第一个操作数为真返回第二个操作数,第一个操作数返回假则返回第一个操作数
}
//传统颜色控件
import win.dlg.color;
winform.static.oncommand = function(id,event){
winform.static.color = win.dlg.color(winform).choose();
winform.static.redraw();
}
//支持透明颜色控件
import win.dlg.ctrlColor;
winform.plusColor.oncommand = function(id,event){
win.dlg.ctrlColor(winform.plusColor)
}
import win.ui.tooltip; //提示控件
import win.ui.tracker; //鼠标跟踪器
//返回可以使用鼠标事件的对象
pls = win.ui.tracker(winform.plusTopmost)
//创建气泡提示对象
var tooltipCtrl = win.ui.tooltip.tracking(winform);
//鼠标移动到控件上
pls.onMouseEnter = function(wParam,lParam){
win.delay(200)
tooltipCtrl.setText("窗口始终在最前显示") //不知道为什么,这个提示偶尔会乱跑
tooltipCtrl.trackPopup(true)
}
//鼠标离开控件
pls.onMouseLeave = function(wParam,lParam){
tooltipCtrl.trackPopup(false)
}
//拖动标签移动窗口
winform.static2.wndproc = {
[ 0x0201/*_WM_LBUTTONDOWN*/ ] = function(hwnd,message,wParam,lParam){
winform.hitCaption();
}
}
winform.show();
win.loopMessage();
多谢分享,不错的窗口
页:
[1]