获取和设置window主题色到plus
By
admin
at 2020-03-25 • 0人收藏 • 1261人看过
感谢: 撒旦微笑 分享源码
import win.ui; /*DSG{{*/ var winform = win.form(text="aardio form";right=759;bottom=469) winform.add( plus={cls="plus";text="主题色";left=193;top=149;right=506;bottom=223;z=1} ) /*}}*/ var dll = raw.loadDll("Dwmapi.dll") getColor = dll.api("DwmGetColorizationColor","( INT &pcrColorization, bool &pfOpaqueBlend )"); var color = getColor(6,false); winform.plus.foreground = color; winform.wndproc = function(hwnd,message,wParam,lParam){ if(message = 800 and color!= wParam){ color = wParam; winform.plus.foreground = color; } } winform.show(); win.loopMessage();
3 个回复 | 最后更新于 2020-03-28
回复#1 @n48ehxcc :
经过测试可以取到数据
mainform.aardio
import win.ui; /*DSG{{*/ mainForm = win.form(text="aardio工程16";right=507;bottom=275) mainForm.add( button={cls="button";text="打开另一个窗口";left=127;top=99;right=402;bottom=180;z=1} ) /*}}*/ import console; import mysql.client; console.log("正在连接数据库服务器..."); thread.invoke( function() while(! thread.get("db4free.net:end")){ io.stdout.write(">");sleep(100); } ) dbMysql,err = mysql.client( server = "localhost"; //数据库服务器,可省略默认为localhost uid = "root";//用户名,可省略默认为root pwd = "123456"; ); thread.set("db4free.net:end",true) console.clearScreen (); if(!dbMysql){ console.log("连接数据库失败",err); console.pause(); return; } //选择数据库 dbMysql.selectDb("test") //执行SQL语句,注意mysql表名、字段名可包含于反引号内(用键盘左上角ESC下方的按键内) dbMysql.exec("CREATE TABLE IF NOT EXISTS `library` ( `name` varchar(100) NOT NULL, `auditing` tinyint(1) DEFAULT '0',`bytes` BLOB,PRIMARY KEY (`name`),UNIQUE KEY `name` (`name`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"); var dbTable,err = dbMysql.listTables() for tbl in dbTable.each(){ console.log("发现数据表:",tbl); } //执行SQL语句,使用命名参数 var ok,err = dbMysql.exec("INSERT `library` VALUES('测试',@num,@str)",{ num = 123; str = "测试:'这是字符串!'命名参数可以自动处理字符串转义"; } ) console.log(ok,err); //查询数据并返回记录集 var result = dbMysql.query("SELECT * FROM `library`"); for name,auditing,bytes in result.each(){ console.log( name,auditing,bytes ); //逐行输出所有记录 } mainForm.button.oncommand = function(id,event){ var frmChild = mainForm.loadForm("\dlg\aa.aardio"); frmChild.show(); } mainForm.show(); return win.loopMessage();
另外一个窗口 aa.aardio
import win.ui; /*DSG{{*/ var winform = win.form(text="aardio form";right=347;bottom=197) winform.add( button={cls="button";text="读取mainform中的数据库";left=56;top=60;right=295;bottom=131;z=1} ) /*}}*/ import console; import mysql.client; winform.button.oncommand = function(id,event){ //查询数据并返回记录集 var result = dbMysql.query("SELECT * FROM `library`"); for name,auditing,bytes in result.each(){ console.log( name,auditing,bytes ); //逐行输出所有记录 } } winform.show(); win.loopMessage(); return winform;
登录后方可回帖
大神,可以咨询一个问题吗?我在mainform启动时连接了mysql数据库,并且设置了db全局变量,但是切换到其他窗口就获取不到这个db变量,也取不到成员方法,是要每个窗口都连一下数据库吗?