#include <winapiex.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GDIPlusEx.au3>
#include <array.au3>
#include <Thread.au3>
Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)
Opt('GUIOnEventMode', 1)
_RTEmptyWorkingSet();减少内存占用
;窗口宽度,高度,圆角
Global $zhuwidth = 600, $zhuheight = 400, $winround = 10
;配色颜色数组,当前皮肤序号
Global $pifucolor[5] = [0xFF0860a8, 0xFFFFAA00, 0xFF00AAFF, 0xFF990000, 0xFF009a20], $pifu = 0
;皮肤图片文件数组,第一个为“”空,是一个标志,为空则按本色显示,当前皮肤序号
Global $imgpifu[6] = ["", @ScriptDir & "\top\1.jpg", @ScriptDir & "\top\2.jpg", @ScriptDir & "\top\3.jpg", @ScriptDir & "\top\4.jpg", @ScriptDir & "\top\5.jpg"], $imgNum = 1
;大图标区域数组,当前选中序号,当前hover序号,当前hover标识,当hover标识和hover序号相同时不重绘
Global $PanBtnRect[6], $SelectPanBtn = 1, $OnPanBtnNum = 0, $OnPanBtnFlag = 0
;系统按钮区域数组,系统按钮tip数组,hoevr按钮标识,hover按钮序号,标识序号相同不重绘,Down按钮序号
Global $topbutton[13], $topbuttontip[13], $onTopbuttonFlag = 0, $onTopbuttonNum = 0, $DownTopbuttonNum = 1
;背景图片,lable,背景是否图片,最小化和显示状态
Global $skin_pic,$zhu_label, $work,$stat
;GUI,PIC,PIC调用的图片数组
Global $zhu_gui, $topbutton_pic[13], $topbuttonimage[13]
_GDIPlus_Startup()
_initRect();按钮区域等初始设置
;窗体建立
_gui_create()
;注册窗口消息函数
GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST')
;托盘退出
Global $exit = TrayCreateItem("退出")
TrayItemSetOnEvent(-1, "exitfunc")
While 1
Sleep(100)
;最小化在显示窗体有问题 暂时先这样
If $stat=1 And WinGetState($zhu_gui)=15 Then
GUIDelete($zhu_gui)
_gui_create()
$stat=0
EndIf
WEnd
Func _gui_create()
$zhu_gui = GUICreate("360界面预览", $zhuwidth, $zhuheight, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
$skin_pic = GUICtrlCreatePic("", 0, 0, $zhuwidth, $zhuheight)
GUICtrlSetState(-1, $Gui_Disable)
$zhu_label=GUICtrlCreateLabel("第"&$DownTopbuttonNum&"页", 20, 120, $zhuwidth - 40, 30)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 24)
GUICtrlSetColor(-1, 0x0860a8)
For $i = 0 To UBound($topbutton) - 1
$topbutton_pic[$i] = GUICtrlCreatePic("", DllStructGetData($topbutton[$i], 1), DllStructGetData($topbutton[$i], 2), DllStructGetData($topbutton[$i], 3), DllStructGetData($topbutton[$i], 4))
GUICtrlSetState(-1, $Gui_Disable)
If $i > 6 Then
_setimage(-1, $topbuttonimage[$i], 60, 60, DllStructGetData($topbutton[$i], 1), DllStructGetData($topbutton[$i], 2))
Else
_setimage(-1, $topbuttonimage[$i])
EndIf
Next
GUISetState()
;背景是否图片
If $work = 1 Then
Global $hGraph = _GDIPlus_GraphicsCreateFromHWND($zhu_gui)
_GDIPlus_GraphicsFillRect($hGraph, 0, 0, $zhuwidth, $zhuheight, _GDIPlus_BrushCreateSolid($pifucolor[$pifu]))
_GDIPlus_GraphicsDispose($hGraph)
Else
_setimage($skin_pic, $imgpifu[$imgNum], $zhuwidth, $zhuheight, 0, 0)
EndIf
EndFunc ;==>_gui_create
Func _setimage($handle, $image, $w_picctrl = -1, $h_picctrl = -1, $ix = -1, $iy = -1);好像是AFAN写的 修改了一点
$himage = _GDIPlus_ImageLoadFromFile($image)
If $w_picctrl <> -1 Then
$w_img = _GDIPlus_ImageGetWidth($himage)
$h_img = _GDIPlus_ImageGetHeight($himage)
Local $kgb = $h_picctrl / $w_picctrl
Local $kgb1 = $h_img / $w_img
Local $x_py = 0, $y_py = 0, $hBMP, $hObject
If $w_img > $w_picctrl Or $h_img > $h_picctrl Then
If $kgb1 > $kgb Then
$h_img = $h_picctrl
$w_img = Round(1 / $kgb1 * $h_img)
$x_py = ($w_picctrl - $w_img) / 2
Else
$w_img = $w_picctrl
$h_img = Round($kgb1 * $w_img)
$y_py = ($h_picctrl - $h_img) / 2
EndIf
Else
$x_py = ($w_picctrl - $w_img) / 2
$y_py = ($h_picctrl - $h_img) / 2
EndIf
EndIf
$hBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($himage)
GUICtrlSendMsg($handle, 0x0172, 0, $hBMP)
_WinAPI_DeleteObject($himage)
_WinAPI_DeleteObject($hBMP)
If $w_picctrl <> -1 Then
_WinAPI_DeleteObject($hObject)
If $ix = 0 And $iy = 0 Then
GUICtrlSetPos($handle, $ix, $iy, $w_img, $h_img)
Else
GUICtrlSetPos($handle, $ix + $x_py - 1, $iy + $y_py - 1, $w_img, $h_img)
GUICtrlSetPos($handle, $ix + $x_py, $iy + $y_py)
EndIf
EndIf
EndFunc ;==>_setimage
Func WM_NCHITTEST($hWnd, $Msg, $wParam, $lParam)
Local $tPoint
$tPoint = GUIGetCursorInfo($hWnd);鼠标信息
;ConsoleWrite(_ArrayToString($tPoint)&@CRLF) 想看信息就使用这句
If $tPoint[2] = 1 Then;左键按下
Switch $tPoint[4]
Case 5;退出
exitfunc()
Case 6, 8;最大化,设置
MsgBox(0, "", " 测试 ", 2, $zhu_gui)
Case 7;最小化
GUISetState(@SW_MINIMIZE, $zhu_gui)
ToolTip("")
$stat=1
Case 9;反馈
ShellExecute("http://www.autoitx.com/thread-28704-1-1.html")
Case 10;换背景图片
_huanimg()
Case 11;换背景色
_huanfu()
Case 12 To 17;6个大图片控件
$DownTopbuttonNum=$tPoint[4]-11
GUICtrlSetData($zhu_label,"第"&$DownTopbuttonNum&"页")
EndSwitch
EndIf
Return 2
EndFunc ;==>WM_NCHITTEST
Func exitfunc()
_GDIPlus_Shutdown()
Exit
EndFunc ;==>exitfunc
Func _initRect();初始化系统按钮图标位置,中间大按钮位置等
For $ii = 1 To 6;初始化6个大按钮位置
$PanBtnRect[$ii - 1] = DllStructCreate($tagRECT)
DllStructSetData($PanBtnRect[$ii - 1], 1, 10 + ($ii - 1) * 70)
DllStructSetData($PanBtnRect[$ii - 1], 2, 30)
DllStructSetData($PanBtnRect[$ii - 1], 3, $ii * 70)
DllStructSetData($PanBtnRect[$ii - 1], 4, 90)
Next
;初始化右上角系统按钮位置,及系统按钮hover,Down图像及提示信息
$topbuttonimage[0] = @ScriptDir & "\top\TopPanelBtnClose.png"
Local $kzImage = _GDIPlus_ImageLoadFromFile($topbuttonimage[0])
$mybtnx = $zhuwidth - 2 - _GDIPlus_ImageGetWidth($kzImage)
$topbutton[0] = DllStructCreate($tagRECT)
DllStructSetData($topbutton[0], 1, $mybtnx)
DllStructSetData($topbutton[0], 2, 1)
DllStructSetData($topbutton[0], 3, $mybtnx + _GDIPlus_ImageGetWidth($kzImage))
DllStructSetData($topbutton[0], 4, _GDIPlus_ImageGetHeight($kzImage) + 1)
$topbuttontip[0] = "关闭"
$topbuttonimage[1] = @ScriptDir & "\top\TopPanelBtnMax.png"
$kzImage = _GDIPlus_ImageLoadFromFile($topbuttonimage[1])
$mybtnx -= _GDIPlus_ImageGetWidth($kzImage)
$topbutton[1] = DllStructCreate($tagRECT)
DllStructSetData($topbutton[1], 1, $mybtnx + 1)
DllStructSetData($topbutton[1], 2, 1)
DllStructSetData($topbutton[1], 3, $mybtnx + _GDIPlus_ImageGetWidth($kzImage))
DllStructSetData($topbutton[1], 4, _GDIPlus_ImageGetHeight($kzImage) + 1)
$topbuttontip[1] = "最大化"
$topbuttonimage[2] = @ScriptDir & "\top\TopPanelBtnMin.png"
$kzImage = _GDIPlus_ImageLoadFromFile($topbuttonimage[2])
$mybtnx -= _GDIPlus_ImageGetWidth($kzImage)
$topbutton[2] = DllStructCreate($tagRECT)
DllStructSetData($topbutton[2], 1, $mybtnx + 1)
DllStructSetData($topbutton[2], 2, 1)
DllStructSetData($topbutton[2], 3, $mybtnx + _GDIPlus_ImageGetWidth($kzImage))
DllStructSetData($topbutton[2], 4, _GDIPlus_ImageGetHeight($kzImage) + 1)
$topbuttontip[2] = "最小化"
$topbuttonimage[3] = @ScriptDir & "\top\TopPanelBtnSetting.png"
$kzImage = _GDIPlus_ImageLoadFromFile($topbuttonimage[3])
$mybtnx -= _GDIPlus_ImageGetWidth($kzImage)
$topbutton[3] = DllStructCreate($tagRECT)
DllStructSetData($topbutton[3], 1, $mybtnx + 1)
DllStructSetData($topbutton[3], 2, 1)
DllStructSetData($topbutton[3], 3, $mybtnx + _GDIPlus_ImageGetWidth($kzImage))
DllStructSetData($topbutton[3], 4, _GDIPlus_ImageGetHeight($kzImage) + 1)
$topbuttontip[3] = "设置"
$topbuttonimage[4] = @ScriptDir & "\top\TopPanelBtnFeedback.png"
$kzImage = _GDIPlus_ImageLoadFromFile($topbuttonimage[4])
$mybtnx -= _GDIPlus_ImageGetWidth($kzImage)
$topbutton[4] = DllStructCreate($tagRECT)
DllStructSetData($topbutton[4], 1, $mybtnx)
DllStructSetData($topbutton[4], 2, 1)
DllStructSetData($topbutton[4], 3, $mybtnx + _GDIPlus_ImageGetWidth($kzImage))
DllStructSetData($topbutton[4], 4, _GDIPlus_ImageGetHeight($kzImage) + 1)
$topbuttontip[4] = "反馈"
$topbuttonimage[5] = @ScriptDir & "\top\skin.png"
$kzImage = _GDIPlus_ImageLoadFromFile($topbuttonimage[5])
$mybtnx -= _GDIPlus_ImageGetWidth($kzImage)
$topbutton[5] = DllStructCreate($tagRECT)
DllStructSetData($topbutton[5], 1, $mybtnx)
DllStructSetData($topbutton[5], 2, 1)
DllStructSetData($topbutton[5], 3, $mybtnx + _GDIPlus_ImageGetWidth($kzImage))
DllStructSetData($topbutton[5], 4, _GDIPlus_ImageGetHeight($kzImage) + 1)
$topbuttontip[5] = "皮肤"
$topbuttonimage[6] = @ScriptDir & "\top\TopPanelBtnSkin.png"
$kzImage = _GDIPlus_ImageLoadFromFile($topbuttonimage[6])
$mybtnx = $zhuwidth - 20 - _GDIPlus_ImageGetWidth($kzImage)
$topbutton[6] = DllStructCreate($tagRECT)
DllStructSetData($topbutton[6], 1, $mybtnx)
DllStructSetData($topbutton[6], 2, 30)
DllStructSetData($topbutton[6], 3, $mybtnx + _GDIPlus_ImageGetWidth($kzImage))
DllStructSetData($topbutton[6], 4, _GDIPlus_ImageGetHeight($kzImage) + 30)
$topbuttontip[6] = "配色"
For $ii = 1 To 6
$topbuttonimage[$ii + 6] = @ScriptDir & "\app" & $ii & ".png"
$kzImage = _GDIPlus_ImageLoadFromFile($topbuttonimage[$ii + 6])
$topbutton[$ii + 6] = DllStructCreate($tagRECT)
DllStructSetData($topbutton[$ii + 6], 1, DllStructGetData($PanBtnRect[$ii - 1], 1))
DllStructSetData($topbutton[$ii + 6], 2, DllStructGetData($PanBtnRect[$ii - 1], 2))
DllStructSetData($topbutton[$ii + 6], 3, 60)
DllStructSetData($topbutton[$ii + 6], 4, 60)
$topbuttontip[$ii + 6] = "第"&$ii&"页"
Next
_WinAPI_DeleteObject($kzImage)
EndFunc ;==>_initRect
Func _huanfu();换配色,不想用弹出窗口选择颜色了,简单点,按一次本色本色按钮颜色选择+1
$pifu += 1;颜色变量序号加1
If $pifu == UBound($pifucolor) Then $pifu = 0;如果颜色序号走出预设颜色数,归0
;显示更换颜色后的窗口
;~ _myback($zhuwidth,$zhuheight,$pifucolor[$pifu])
GUIDelete($zhu_gui)
$work = 1
_gui_create()
$work = 0
EndFunc ;==>_huanfu
Func _huanimg();换背景图片
$imgNum += 1
If $imgNum == UBound($imgpifu) Then $imgNum = 1;如背景图片序号超出预设背景数,归1,因为0 为无背景图片
_setimage($skin_pic, $imgpifu[$imgNum], $zhuwidth, $zhuheight, 0, 0)
EndFunc ;==>_huanimg