long long long long ago ! seniors大侠的《山寨360界面》相信大家都印象深刻把,观后评价:一个字牛,两个字牛逼,哈哈。在此感谢下大侠,看了她的文章总是收获良多。
断断续续花了N久时间来了解GDI,至今总算初窥门径。于是便有了今天这个现学现卖之作。
下面简单介绍下山寨思路:
基于seniors大侠的《山寨360界面》,主要优化了消息响应,资源占用
一、资源占用
采用缓冲机制:读取资源→缓存之→绘制资源→缓存之→更新资源→循环之
本着这样一个思路,实现了快速绘制窗口,并在很大程度上减轻了CPU的压力。
当然,由于个人比较懒,一次性绘制完了所有资源进行了统一缓存,优缺点都有,后期会尝试多级缓冲。
二、消息响应
事件从监视消息内部,映射到外部循环,供程序处理,不会阻断监视消息,从而实现事件的快速响应及更可靠的处理复杂步骤
三、调用方便
写成了UDF,只需从外部调用几个函数即可快速创建窗口,支持多窗口创建及消息响应。
当然目前所发作品只是雏形,很多思路还没优化,甚至需要重新设计
哈哈,如上废话一堆可能除了作者本人其他人很难看懂吧,上图上代码哈:
创建窗口及控件代码
#include "自绘窗口_UDF.au3"
$Form1 = UICreate(600, 400, -1, -1, "小Q书桌", @ScriptDir & "\Images\102.ico", @ScriptDir & "\Images\bk1.jpg", 10)
$SysClose = UICreateButton("关闭", 565, 2, 32, 18, $Form1, 0)
UIButtonSetImage($SysClose, @ScriptDir & "\Images\Close.png", @ScriptDir & "\Images\CloseOver.png", @ScriptDir & "\Images\CloseDown.png", "")
$SysMax = UICreateButton("最大化", 540, 2, 25, 18, $Form1, 0)
UIButtonSetImage($SysMax, @ScriptDir & "\Images\Max.png", @ScriptDir & "\Images\Over.png", @ScriptDir & "\Images\Down.png", "")
$SysMin = UICreateButton("最小化", 515, 2, 25, 18, $Form1, 0)
UIButtonSetImage($SysMin, @ScriptDir & "\Images\Min.png", @ScriptDir & "\Images\Over.png", @ScriptDir & "\Images\Down.png", "")
$SysSet = UICreateButton("选项", 489, 2, 26, 18, $Form1, 0)
UIButtonSetImage($SysSet, @ScriptDir & "\Images\Setting.png", @ScriptDir & "\Images\Over.png", @ScriptDir & "\Images\Down.png", "")
$SysSkin = UICreateButton("更改外观", 460, 2, 16, 16, $Form1, 0)
UIButtonSetImage($SysSkin, @ScriptDir & "\Images\Skin.png", "", "", "")
$SysColor = UICreateButton("配色", 560, 40, 18, 18, $Form1, 0)
UIButtonSetImage($SysColor, @ScriptDir & "\Images\Color.png", "", "", "")
$Button1 = UICreateButton("按钮1", 20, 45, 32, 32, $Form1)
UIButtonSetImage($Button1, @ScriptDir & "\Images\1.png", "", "", "")
$Button2 = UICreateButton("按钮2", 70, 45, 32, 32, $Form1)
UIButtonSetImage($Button2, @ScriptDir & "\Images\2.png", "", "", "")
$Button3 = UICreateButton("按钮3", 120, 45, 32, 32, $Form1)
UIButtonSetImage($Button3, @ScriptDir & "\Images\3.png", "", "", "")
$Button4 = UICreateButton("按钮4", 170, 45, 32, 32, $Form1)
UIButtonSetImage($Button4, @ScriptDir & "\Images\4.png", "", "", "")
$Button5 = UICreateButton("按钮5", 220, 45, 32, 32, $Form1)
UIButtonSetImage($Button5, @ScriptDir & "\Images\5.png", "", "", "")
$Button6 = UICreateButton("按钮6", 270, 45, 32, 32, $Form1)
UIButtonSetImage($Button6, @ScriptDir & "\Images\6.png", "", "", "")
UICtrlSetFocus($Button1);设置Button1焦点
UILoad($Form1)
;换肤窗口
$Form2 = UICreate(290, 230, -1, -1, "更换皮肤", @ScriptDir & "\Images\102.ico", @ScriptDir & "\Images\skinBK.png", 5)
WinSetOnTop($Form2, "", 1)
$Bk1 = UICreateButton("皮肤1", 5, 35, 90, 60, $Form2, 0)
UIButtonSetImage($Bk1, @ScriptDir & "\Images\bk1.jpg", @ScriptDir & "\Images\skinOver.png", @ScriptDir & "\Images\skinOver.png", "")
$Bk2 = UICreateButton("皮肤2", 100, 35, 90, 60, $Form2, 0)
UIButtonSetImage($Bk2, @ScriptDir & "\Images\bk2.jpg", @ScriptDir & "\Images\skinOver.png", @ScriptDir & "\Images\skinOver.png", "")
$Bk3 = UICreateButton("皮肤3", 195, 35, 90, 60, $Form2, 0)
UIButtonSetImage($Bk3, @ScriptDir & "\Images\bk3.jpg", @ScriptDir & "\Images\skinOver.png", @ScriptDir & "\Images\skinOver.png", "")
$Bk4 = UICreateButton("皮肤4", 5, 100, 90, 60, $Form2, 0)
UIButtonSetImage($Bk4, @ScriptDir & "\Images\bk4.jpg", @ScriptDir & "\Images\skinOver.png", @ScriptDir & "\Images\skinOver.png", "")
$Bk5 = UICreateButton("皮肤5", 100, 100, 90, 60, $Form2, 0)
UIButtonSetImage($Bk5, @ScriptDir & "\Images\bk5.jpg", @ScriptDir & "\Images\skinOver.png", @ScriptDir & "\Images\skinOver.png", "")
$Bk6 = UICreateButton("皮肤6", 195, 100, 90, 60, $Form2, 0)
UIButtonSetImage($Bk6, @ScriptDir & "\Images\bk6.jpg", @ScriptDir & "\Images\skinOver.png", @ScriptDir & "\Images\skinOver.png", "")
$Bk7 = UICreateButton("皮肤7", 5, 165, 90, 60, $Form2, 0)
UIButtonSetImage($Bk7, @ScriptDir & "\Images\bk7.jpg", @ScriptDir & "\Images\skinOver.png", @ScriptDir & "\Images\skinOver.png", "")
$Bk8 = UICreateButton("皮肤8", 100, 165, 90, 60, $Form2, 0)
UIButtonSetImage($Bk8, @ScriptDir & "\Images\bk8.jpg", @ScriptDir & "\Images\skinOver.png", @ScriptDir & "\Images\skinOver.png", "")
$Bk9 = UICreateButton("皮肤9", 195, 165, 90, 60, $Form2, 0)
UIButtonSetImage($Bk9, @ScriptDir & "\Images\bk9.jpg", @ScriptDir & "\Images\skinOver.png", @ScriptDir & "\Images\skinOver.png", "")
$BkColse = UICreateButton("关闭", 255, 2, 32, 18, $Form2, 0)
UIButtonSetImage($BkColse, @ScriptDir & "\Images\Close.png", @ScriptDir & "\Images\CloseOver.png", @ScriptDir & "\Images\CloseDown.png", "")
UILoad($Form2)
;建立子窗口
$Child1 = UIChild($Form1, 591, 280, 8, 100)
$Label1 = GUICtrlCreateLabel("按钮1", 8, 12, 140, 35)
GUICtrlSetFont(-1, 18)
GUICtrlSetColor(-1, 0x0066B2)
$Input1 = GUICtrlCreateInput("很爱很爱你,所以愿意", 162, 20, 249, 21)
$Button7 = GUICtrlCreateButton("修改标题", 288, 64, 119, 45)
GUISetState(@SW_SHOW, $Child1)
GUISetState(@SW_SHOW, $Form1)
GUISetState(@SW_HIDE, $Form2)
UIRegister($Form1)
While 1
$nMsg = UIGetMsg()
Switch $nMsg
Case $SysClose, $GUI_EVENT_CLOSE
Exit
Case $SysMax
Case $SysMin
GUISetState(@SW_MINIMIZE, $Form1)
Case $SysSet
GUICtrlSetData($Label1, UICtrlRead($SysSet))
Case $SysColor
GUICtrlSetData($Label1, UICtrlRead($SysColor))
Case $SysSkin
GUISetState(@SW_SHOW, $Form2)
Case $Button1
GUICtrlSetData($Label1, UICtrlRead($Button1))
Case $Button2
GUICtrlSetData($Label1, UICtrlRead($Button2))
Case $Button3
GUICtrlSetData($Label1, UICtrlRead($Button3))
Case $Button4
GUICtrlSetData($Label1, UICtrlRead($Button4))
Case $Button5
GUICtrlSetData($Label1, UICtrlRead($Button5))
Case $Button6
GUICtrlSetData($Label1, UICtrlRead($Button6))
Case $Button7
UISetTitle($Form1, GUICtrlRead($Input1));设置标题
UILoad($Form1)
Case $BkColse
GUISetState(@SW_HIDE, $Form2)
Case $Bk1
UISetBK($Form1, @ScriptDir & "\Images\bk1.jpg")
UILoad($Form1)
Case $Bk2
UISetBK($Form1, @ScriptDir & "\Images\bk2.jpg")
UILoad($Form1)
Case $Bk3
UISetBK($Form1, @ScriptDir & "\Images\bk3.jpg")
UILoad($Form1)
Case $Bk4
UISetBK($Form1, @ScriptDir & "\Images\bk4.jpg")
UILoad($Form1)
Case $Bk5
UISetBK($Form1, @ScriptDir & "\Images\bk5.jpg")
UILoad($Form1)
Case $Bk6
UISetBK($Form1, @ScriptDir & "\Images\bk6.jpg")
UILoad($Form1)
Case $Bk7
UISetBK($Form1, @ScriptDir & "\Images\bk7.jpg")
UILoad($Form1)
Case $Bk8
UISetBK($Form1, @ScriptDir & "\Images\bk8.jpg")
UILoad($Form1)
Case $Bk9
UISetBK($Form1, @ScriptDir & "\Images\bk9.jpg")
UILoad($Form1)
EndSwitch
WEnd
附件,图片源码等:
|