131738
发表于 2011-11-14 14:48:27
学习。。。
afan
发表于 2011-11-14 14:57:37
效果很好哦~
测试了一下,反馈一点点小瑕疵:
1,工具提示显示后,在移到界面其它处消失,这是正常的。但在移到窗口外部时,却经常停留。
2,在按下按钮后(比如关闭按钮)在其它地方松开,此时再次去按它时该按钮已没有按下的效果。
3,在进行以上测试之后,偶尔会使按钮失效。
kenan
发表于 2011-11-14 15:53:34
学习下。。看看是什么。
seniors
发表于 2011-11-14 15:54:27
1,工具提示显示后,在移到界面其它处消失,这是正常的。但在移到窗口外部时,却经常停留。
2,在按下按钮后(比如关闭按钮)在其它地方松开,此时再次去按它时该按钮已没有按下的效果。
3,在进行以上测试之后,偶尔会使按钮失效afan 发表于 2011-11-14 14:57 http://www.autoitx.com/images/common/back.gif
谢谢测试,对于1、我现在也没找到办法,应该用的是tooltip,不知道怎么让它有时间限制自动消失
2、找到办法把nchittest函数改为
Func WM_NCHITTEST($hWnd, $Msg, $wParam, $lParam)
Local $tPoint = _WinAPI_GetMousePos(True, $hWnd)
Local $wrect = _WinAPI_GetWindowRect($zhu_gui)
Switch $hWnd
Case $zhu_gui
$OnPanBtnFlag = 0
$onTopbuttonFlag = 0
For $iI = 1 To 6
If _WinAPI_PtInRect($PanBtnRect[$iI - 1], $tPoint) Then
$OnPanBtnFlag = $iI
ExitLoop
EndIf
Next
For $iI = 1 To 7
If _WinAPI_PtInRect($topbutton[$iI - 1], $tPoint) Then
$onTopbuttonFlag = $iI
ExitLoop
EndIf
Next
If $OnPanBtnFlag == 0 And $OnPanBtnNum <> $OnPanBtnFlag Then
$OnPanBtnNum = $OnPanBtnFlag
_hoverBTN($SelectPanBtn, $OnPanBtnNum)
ElseIf $onTopbuttonFlag == 0 And $onTopbuttonNum <> $onTopbuttonFlag Then
ToolTip("")
$onTopbuttonNum = $onTopbuttonFlag
_hoverBTN($SelectPanBtn, $OnPanBtnNum)
ElseIf $OnPanBtnFlag == 0 And $onTopbuttonFlag == 0Then
If $DownTopbuttonNum > 0 Then
$DownTopbuttonNum = 0
_hoverBTN($SelectPanBtn, 0)
EndIf
Return $HTCAPTION
ElseIf $SelectPanBtn <> $OnPanBtnFlag And $OnPanBtnNum <> $OnPanBtnFlag Then
$OnPanBtnNum = $OnPanBtnFlag
$OnPanBtnFlag = 0
_hoverBTN($SelectPanBtn, $OnPanBtnNum)
Return $HTOBJECT
ElseIf $onTopbuttonFlag > 0 And $onTopbuttonNum <> $onTopbuttonFlag Then
$onTopbuttonNum = $onTopbuttonFlag
$onTopbuttonFlag = 0
_topbutton($topbutton[$onTopbuttonNum - 1], $topbuttonhoverimg[$onTopbuttonNum - 1])
ToolTip($topbuttontip[$onTopbuttonNum - 1], DllStructGetData($wrect, 1) + DllStructGetData($topbutton[$onTopbuttonNum - 1], 1), DllStructGetData($wrect, 2) + DllStructGetData($topbutton[$onTopbuttonNum - 1], 2) + 30)
Return $HTOBJECT
EndIf
EndSwitch
EndFunc ;==>WM_NCHITTEST
3、我也测试到了,还没找到原因,可能是画图问题,或者是减少内存占用造成的
kenan
发表于 2011-11-14 16:01:08
太漂亮了,支持一下。
newuser
发表于 2011-11-14 16:05:41
回复 1# seniors
代码看的头疼,能就下面的问题在相关代码给出注释吗?
1成功添加了一个image,做法如下:
;47行 由$PanBtnRect改成$PanBtnRect
;78行 由For $iI = 1 To 6改成For $iI = 1 To 7
;309行 由For $iI = 1 To 6改成For $iI = 1 To 7
;412行 Switch $DownPanBtnFlag 为新增图象添加响应
问题是:点击图象没反应,而且由于没找到调整图象的语句,导致与原有image排列出现不美观现象?#Region ACN预处理程序参数(常用参数)
#PRE_Icon= ;图标,支持EXE,DLL,ICO
#PRE_OutFile= ;输出文件名
#PRE_OutFile_Type=exe ;文件类型
#PRE_Compression=4 ;压缩等级
#PRE_UseUpx=y ;使用压缩
#PRE_Res_Comment= ;程序注释
#PRE_Res_Description= ;详细信息
#PRE_Res_Fileversion= ;文件版本
#PRE_Res_FileVersion_AutoIncrement=p ;自动更新版本
#PRE_Res_LegalCopyright= ;版权
#PRE_Change2CUI=N ;修改输出的程序为CUI(控制台程序)
;#PRE_Res_Field=AutoIt Version|%AutoItVer% ;自定义资源段
;#PRE_Run_Tidy= ;脚本整理
;#PRE_Run_Obfuscator= ;代码迷惑
;#PRE_Run_AU3Check= ;语法检查
;#PRE_Run_Before= ;运行前
;#PRE_Run_After= ;运行后
;#PRE_UseX64=n ;使用64位解释器
;#PRE_Compile_Both ;进行双平台编译
#EndRegion ACN预处理程序参数(常用参数)
#cs ____________________________________
Au3 版本:
脚本作者:
电子邮件:
QQ/TM:
脚本版本:
脚本功能:
#ce _______________脚本开始_________________
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GDIPlusEx.au3>
#include <Thread.au3>
Opt('GUIOnEventMode', 1)
_RTEmptyWorkingSet();Thread.au3里的函数,减少内存占用的
Global $zhuwidth = 600, $zhuheight = 400, $winround = 10;主窗口的“宽和高”的设置
Global $pifucolor = , $pifu = 0;皮肤颜色
Global $imgpifu = ["", @ScriptDir & "\top\1.jpg", @ScriptDir & "\top\2.jpg", @ScriptDir & "\top\3.jpg", @ScriptDir & "\top\4.jpg", @ScriptDir & "\top\5.jpg"], $imgNum = 0
;以上几个 .jpg 是设置窗口“顶端背景”的,但我没测试出来?
;原来是通过”设置“菜单实现”换肤“的,竟然没注意到!
_GDIPlus_Startup()
Global $PanBtnRect, $SelectPanBtn = 1, $OnPanBtnNum = 0, $OnPanBtnFlag = 0
Global $topbutton, $topbuttonhoverimg, $topbuttondownimg, $topbuttontip, $onTopbuttonFlag = 0, $onTopbuttonNum = 0, $DownTopbuttonNum = 0
_initRect();应该是”初始化GUI右上角各个菜单的函数,如皮肤、设置、反馈、最大(小)化、关闭
Global $zhu_gui = GUICreate("360界面预览", $zhuwidth, $zhuheight, -1, -1, $WS_POPUP, $WS_EX_LAYERED);创建主窗口
GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST');为一个已知的Windows消息代码“$WM_NCHITTEST"注册一个用户自定义函数"WM_NCHITTEST"
GUIRegisterMsg($WM_LBUTTONDOWN, 'WM_LBUTTONDOWN')
GUIRegisterMsg($WM_LBUTTONUP, 'WM_LBUTTONUP')
$ne_gui = GUICreate("", $zhuwidth - 10, 260, 8, 110, $WS_POPUP, $WS_EX_MDICHILD, $zhu_gui)
;为主窗口$zhu_gui创建一个子窗口$ne_gui
$mylabel = GUICtrlCreateLabel("第一页", 10, 10, $zhuwidth - 20, 30)
GUICtrlSetFont(-1, 24)
GUICtrlSetColor(-1, 0x0860a8)
GUISetState(@SW_SHOW, $ne_gui)
GUISetState(@SW_SHOW, $zhu_gui)
_hoverBTN($SelectPanBtn, $OnPanBtnNum)
While 1
Sleep(100)
WEnd
Func exitfunc();退出函数
_GDIPlus_Shutdown()
Exit
EndFunc ;==>exitfunc
Func _initRect();应该是”初始化GUI右上角各个菜单的函数,如皮肤、设置、反馈、最大(小)化、关闭
For $iI = 1 To 7
$PanBtnRect[$iI - 1] = DllStructCreate($tagRECT)
;创建一个 C/C++ 样式的数据结构供 DllCall 使用.
;DllStructCreate ( "数据结构" [,指针] )
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
Local $kzImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\top\TopPanelBtnClose.png");加载GUI右上角那个“ X” Image图象
$mybtnx = $zhuwidth - 2 - _GDIPlus_ImageGetWidth($kzImage)
$topbutton = DllStructCreate($tagRECT)
DllStructSetData($topbutton, 1, $mybtnx)
DllStructSetData($topbutton, 2, 1)
DllStructSetData($topbutton, 3, $mybtnx + _GDIPlus_ImageGetWidth($kzImage))
DllStructSetData($topbutton, 4, _GDIPlus_ImageGetHeight($kzImage) + 1)
$topbuttonhoverimg = @ScriptDir & "\top\TopPanelCloseOver.png"
;当鼠标”移动“到GUI右上角那个“ X” Image图象 “上(over)时",所显示的 Image 图象
$topbuttondownimg = @ScriptDir & "\top\TopPanelCloseDown.png"
;当鼠标”点击“到GUI右上角那个“ X” Image图象 “上(down)时",所显示的 Image 图象
$topbuttontip = "关闭程序"
;当鼠标”移动“到GUI右上角那个“ X” Image图象时,所显示的”提示文字“
$kzImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\top\TopPanelBtnMax.png")
$mybtnx -= _GDIPlus_ImageGetWidth($kzImage)
$topbutton = DllStructCreate($tagRECT)
DllStructSetData($topbutton, 1, $mybtnx + 2)
DllStructSetData($topbutton, 2, 1)
DllStructSetData($topbutton, 3, $mybtnx + _GDIPlus_ImageGetWidth($kzImage))
DllStructSetData($topbutton, 4, _GDIPlus_ImageGetHeight($kzImage) + 1)
$topbuttonhoverimg = @ScriptDir & "\top\MiddleOver.png"
$topbuttondownimg = @ScriptDir & "\top\MiddleDown.png"
$topbuttontip = "最大化"
$kzImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\top\TopPanelBtnMin.png")
$mybtnx -= _GDIPlus_ImageGetWidth($kzImage)
$topbutton = DllStructCreate($tagRECT)
DllStructSetData($topbutton, 1, $mybtnx + 2)
DllStructSetData($topbutton, 2, 1)
DllStructSetData($topbutton, 3, $mybtnx + _GDIPlus_ImageGetWidth($kzImage))
DllStructSetData($topbutton, 4, _GDIPlus_ImageGetHeight($kzImage) + 1)
$topbuttonhoverimg = @ScriptDir & "\top\MiddleOver.png"
$topbuttondownimg = @ScriptDir & "\top\MiddleDown.png"
$topbuttontip = "最小化"
$kzImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\top\TopPanelBtnSetting.png")
$mybtnx -= _GDIPlus_ImageGetWidth($kzImage)
$topbutton = DllStructCreate($tagRECT)
DllStructSetData($topbutton, 1, $mybtnx + 2)
DllStructSetData($topbutton, 2, 1)
DllStructSetData($topbutton, 3, $mybtnx + _GDIPlus_ImageGetWidth($kzImage))
DllStructSetData($topbutton, 4, _GDIPlus_ImageGetHeight($kzImage) + 1)
$topbuttonhoverimg = @ScriptDir & "\top\MiddleOver.png"
$topbuttondownimg = @ScriptDir & "\top\MiddleDown.png"
$topbuttontip = "设置"
$kzImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\top\TopPanelBtnFeedback.png")
$mybtnx -= _GDIPlus_ImageGetWidth($kzImage)
$topbutton = DllStructCreate($tagRECT)
DllStructSetData($topbutton, 1, $mybtnx)
DllStructSetData($topbutton, 2, 1)
DllStructSetData($topbutton, 3, $mybtnx + _GDIPlus_ImageGetWidth($kzImage))
DllStructSetData($topbutton, 4, _GDIPlus_ImageGetHeight($kzImage) + 1)
$topbuttonhoverimg = @ScriptDir & "\top\over.png"
$topbuttondownimg = @ScriptDir & "\top\mask.png"
$topbuttontip = "反馈"
$kzImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\top\skin.png")
$mybtnx -= _GDIPlus_ImageGetWidth($kzImage)
$topbutton = DllStructCreate($tagRECT)
DllStructSetData($topbutton, 1, $mybtnx)
DllStructSetData($topbutton, 2, 1)
DllStructSetData($topbutton, 3, $mybtnx + _GDIPlus_ImageGetWidth($kzImage))
DllStructSetData($topbutton, 4, _GDIPlus_ImageGetHeight($kzImage) + 1)
$topbuttonhoverimg = @ScriptDir & "\top\over.png"
$topbuttondownimg = @ScriptDir & "\top\mask.png"
$topbuttontip = "皮肤"
$kzImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\top\TopPanelBtnSkin.png")
$mybtnx = $zhuwidth - 20 - _GDIPlus_ImageGetWidth($kzImage)
$topbutton = DllStructCreate($tagRECT)
DllStructSetData($topbutton, 1, $mybtnx)
DllStructSetData($topbutton, 2, 30)
DllStructSetData($topbutton, 3, $mybtnx + _GDIPlus_ImageGetWidth($kzImage))
DllStructSetData($topbutton, 4, _GDIPlus_ImageGetHeight($kzImage) + 30)
$topbuttonhoverimg = @ScriptDir & "\top\over.png"
$topbuttondownimg = @ScriptDir & "\top\mask.png"
$topbuttontip = "配色"
_GDIPlus_ImageDispose($kzImage);释放一个图象对象
EndFunc ;==>_initRect
Func _myback($mywidth, $myheight, $mycolor = 0xFF0860a8, $myskin = "", $myround = 10, $myleftup = True, $myrightup = True, $myleftdown = True, $myrightdown = True)
Local $hHBITMAP = _WinAPI_CreateBitmap($mywidth, $myheight, 1, 32)
Local $hCDC = _WinAPI_CreateCompatibleDC(0)
Local $hOld = _WinAPI_SelectObject($hCDC, $hHBITMAP)
Local $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hCDC)
_GDIPlus_GraphicsClear($hGraphic, 0x00000000)
_GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2);绘制质量 2 - 使用 8 X 8 矩形过滤器
_GDIPlus_GraphicsSetInterpolationMode($hGraphic, 7);插值法 7=High-quality, bicubic interpolation.
$hPath = _myPath(0, 0, $mywidth, $myheight)
$hPen = _GDIPlus_PenCreate(0xFF000000, 1, 0)
_GDIPlus_PenSetLineJoin($hPen, 2);2 - Line join produces a smooth, circular arc between the lines.
DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGraphic, "hwnd", $hPen, "hwnd", $hPath)
If $myskin = "" Then
Local $tRect = _GDIPlus_RectFCreate(0, 0, 40, $myheight);设置区域色块
Local $hBrush = _GDIPlus_LineBrushCreateFromRect($tRect, 0xaaffffff, $mycolor, 1, 3)
Local $tBlends
$tBlends = 4
$tBlends = 0.05
$tBlends = 0.0
$tBlends = 1
$tBlends = 0.05
$tBlends = 0.9
$tBlends = 0.9
$tBlends = 1
$tBlends = 1.0
_GDIPlus_LineBrushSetBlend($hBrush, $tBlends)
DllCall($ghGDIPDll, "uint", "GdipFillPath", "hwnd", $hGraphic, "hwnd", $hBrush, "hwnd", $hPath)
_GDIPlus_BrushDispose($hBrush)
Else
Local $kzImage = _GDIPlus_ImageLoadFromFile($myskin)
Local $imgwidth = $mywidth
If _GDIPlus_ImageGetWidth($kzImage) < $mywidth Then $imgwidth = _GDIPlus_ImageGetWidth($kzImage)
Local $imgheight = $myheight
If _GDIPlus_ImageGetHeight($kzImage) < $myheight Then $imgheight = _GDIPlus_ImageGetHeight($kzImage)
$mypictexture = _GDIPlus_TextureCreate2($kzImage, 0, 0, $imgwidth, $imgheight, 3)
DllCall($ghGDIPDll, "uint", "GdipFillPath", "hwnd", $hGraphic, "hwnd", $mypictexture, "hwnd", $hPath)
_GDIPlus_BrushDispose($mypictexture)
EndIf
_GDIPlus_PathDispose($hPath)
_GDIPlus_PenDispose($hPen)
Local $kzImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\top\TopPanelBtnClose.png")
$mybtnx = $mywidth - 2 - _GDIPlus_ImageGetWidth($kzImage)
_GDIPlus_GraphicsDrawImageRectRect($hGraphic, $kzImage, 0, 0, _GDIPlus_ImageGetWidth($kzImage), _GDIPlus_ImageGetHeight($kzImage), $mybtnx, 1, _GDIPlus_ImageGetWidth($kzImage), _GDIPlus_ImageGetHeight($kzImage))
$kzImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\top\TopPanelBtnMax.png")
$mybtnx -= _GDIPlus_ImageGetWidth($kzImage)
_GDIPlus_GraphicsDrawImageRectRect($hGraphic, $kzImage, 0, 0, _GDIPlus_ImageGetWidth($kzImage), _GDIPlus_ImageGetHeight($kzImage), $mybtnx, 1, _GDIPlus_ImageGetWidth($kzImage), _GDIPlus_ImageGetHeight($kzImage))
$kzImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\top\TopPanelBtnMin.png")
$mybtnx -= _GDIPlus_ImageGetWidth($kzImage)
_GDIPlus_GraphicsDrawImageRectRect($hGraphic, $kzImage, 0, 0, _GDIPlus_ImageGetWidth($kzImage), _GDIPlus_ImageGetHeight($kzImage), $mybtnx, 1, _GDIPlus_ImageGetWidth($kzImage), _GDIPlus_ImageGetHeight($kzImage))
$kzImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\top\TopPanelBtnSetting.png")
$mybtnx -= _GDIPlus_ImageGetWidth($kzImage)
_GDIPlus_GraphicsDrawImageRectRect($hGraphic, $kzImage, 0, 0, _GDIPlus_ImageGetWidth($kzImage), _GDIPlus_ImageGetHeight($kzImage), $mybtnx, 1, _GDIPlus_ImageGetWidth($kzImage), _GDIPlus_ImageGetHeight($kzImage))
$kzImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\top\TopPanelBtnFeedback.png")
$mybtnx -= _GDIPlus_ImageGetWidth($kzImage)
_GDIPlus_GraphicsDrawImageRectRect($hGraphic, $kzImage, 0, 0, _GDIPlus_ImageGetWidth($kzImage), _GDIPlus_ImageGetHeight($kzImage), $mybtnx, 1, _GDIPlus_ImageGetWidth($kzImage), _GDIPlus_ImageGetHeight($kzImage))
$kzImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\top\skin.png")
$mybtnx -= _GDIPlus_ImageGetWidth($kzImage)
_GDIPlus_GraphicsDrawImageRectRect($hGraphic, $kzImage, 0, 0, _GDIPlus_ImageGetWidth($kzImage), _GDIPlus_ImageGetHeight($kzImage), $mybtnx + 1, 2, _GDIPlus_ImageGetWidth($kzImage), _GDIPlus_ImageGetHeight($kzImage))
$kzImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\top\TopPanelBtnSkin.png")
$mybtnx = $mywidth - 20 - _GDIPlus_ImageGetWidth($kzImage)
_GDIPlus_GraphicsDrawImageRectRect($hGraphic, $kzImage, 0, 0, _GDIPlus_ImageGetWidth($kzImage), _GDIPlus_ImageGetHeight($kzImage), $mybtnx, 30, _GDIPlus_ImageGetWidth($kzImage), _GDIPlus_ImageGetHeight($kzImage))
_GDIPlus_ImageDispose($kzImage)
$hFamily = _GDIPlus_FontFamilyCreate("黑体")
$hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
$tLayout = _GDIPlus_RectFCreate(5, 5)
$hPath = _GDIPlus_PathCreate()
_GDIPlus_PathAddString($hPath,"250流氓软件", $tLayout, $hFamily, 1, 9, 0);读取字体外形为路径;0是正常字,9是字号
;设置窗口标题
DllCall($ghGDIPDll, "uint", "GdipFillPath", "hwnd", $hGraphic, "hwnd", $hBrush, "hwnd", $hPath)
_GDIPlus_PathDispose($hPath)
$hPath = _GDIPlus_PathCreate()
$tLayout = _GDIPlus_RectFCreate(5, $myheight - 25)
_GDIPlus_PathAddString($hPath,"沙子制作 By seniors 2011", $tLayout, $hFamily, 0, 12, 0);读取字体外形为路径;0是正常字,16是字号
;设置任务栏”提示内容“
DllCall($ghGDIPDll, "uint", "GdipFillPath", "hwnd", $hGraphic, "hwnd", $hBrush, "hwnd", $hPath)
_GDIPlus_PathDispose($hPath)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hGraphic)
_WinAPI_SelectObject($hCDC, $hOld)
_WinAPI_DeleteDC($hCDC)
Return $hHBITMAP
EndFunc ;==>_myback
Func _hoverBTN($i, $j)
Local $hHBITMAP = _myback($zhuwidth, $zhuheight, $pifucolor[$pifu], $imgpifu[$imgNum], $winround, True, True, True, True)
Local $hCDC = _WinAPI_CreateCompatibleDC(0)
Local $hOld = _WinAPI_SelectObject($hCDC, $hHBITMAP)
Local $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hCDC)
$hPath = _myPath(8 + 70 * ($i - 1), 25, 66, 80, 5)
$hPen = _GDIPlus_PenCreate(0x33000000, 1, 0)
_GDIPlus_PenSetLineJoin($hPen, 2);2 - Line join produces a smooth, circular arc between the lines.
DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGraphic, "hwnd", $hPen, "hwnd", $hPath)
$hPath = _myPath(7 + 70 * ($i - 1), 24, 66, 80, 5)
$hPen = _GDIPlus_PenCreate(0x77FFFFFF, 1, 0)
_GDIPlus_PenSetLineJoin($hPen, 2);2 - Line join produces a smooth, circular arc between the lines.
DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGraphic, "hwnd", $hPen, "hwnd", $hPath)
$tRect = _GDIPlus_RectFCreate(0, 0, 70, 110);设置区域色块
$hBrush = _GDIPlus_LineBrushCreateFromRect($tRect, 0x99FFFFFF, 0x33FFFFFF, 1, 3)
Local $tBlends2
$tBlends2 = 4
$tBlends2 = 0.01
$tBlends2 = 0.0
$tBlends2 = 0.1
$tBlends2 = 0.5
$tBlends2 = 1
$tBlends2 = 0.5
$tBlends2 = 1
$tBlends2 = 1.0
_GDIPlus_LineBrushSetBlend($hBrush, $tBlends2)
DllCall($ghGDIPDll, "uint", "GdipFillPath", "hwnd", $hGraphic, "hwnd", $hBrush, "hwnd", $hPath)
If $j <> 0 Then
$hPath = _myPath(8 + 70 * ($j - 1), 25, 66, 80, 5)
$hPen = _GDIPlus_PenCreate(0x22000000, 1, 0)
_GDIPlus_PenSetLineJoin($hPen, 2);2 - Line join produces a smooth, circular arc between the lines.
DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGraphic, "hwnd", $hPen, "hwnd", $hPath)
$hPath = _myPath(7 + 70 * ($j - 1), 24, 66, 80, 5)
$hPen = _GDIPlus_PenCreate(0x33FFFFFF, 1, 0)
_GDIPlus_PenSetLineJoin($hPen, 2);2 - Line join produces a smooth, circular arc between the lines.
DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGraphic, "hwnd", $hPen, "hwnd", $hPath)
$tRect = _GDIPlus_RectFCreate(0, 0, 70, 110);设置区域色块
$hBrush = _GDIPlus_LineBrushCreateFromRect($tRect, 0x55FFFFFF, 0x11FFFFFF, 1, 3)
Local $tBlends2
$tBlends2 = 4
$tBlends2 = 0.01
$tBlends2 = 0.0
$tBlends2 = 0.1
$tBlends2 = 0.5
$tBlends2 = 1
$tBlends2 = 0.5
$tBlends2 = 1
$tBlends2 = 1.0
_GDIPlus_LineBrushSetBlend($hBrush, $tBlends2)
DllCall($ghGDIPDll, "uint", "GdipFillPath", "hwnd", $hGraphic, "hwnd", $hBrush, "hwnd", $hPath)
EndIf
_GDIPlus_PenDispose($hPen)
_GDIPlus_BrushDispose($hBrush)
For $iI = 1 To 7
$kzImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\app\" & $iI & ".png");加载应用图象用的
_GDIPlus_GraphicsDrawImageRectRect($hGraphic, $kzImage, 0, 0, _GDIPlus_ImageGetWidth($kzImage), _GDIPlus_ImageGetHeight($kzImage), DllStructGetData($PanBtnRect[$iI - 1], 1), DllStructGetData($PanBtnRect[$iI - 1], 2), 70, 70)
Next
_GDIPlus_ImageDispose($kzImage)
_GDIPlus_GraphicsDispose($hGraphic)
_WinAPI_SelectObject($hCDC, $hOld)
_WinAPI_DeleteDC($hCDC)
_WinAPI_UpdateLayeredWindowEx($zhu_gui, $hHBITMAP, 255);可能3.3.7开始这个函数有改变,请在$hHBITMAP前加上二个参数-1,-1
Return $hHBITMAP
EndFunc ;==>_hoverBTN
Func _huanfu()
$pifu += 1
$imgNum = 0
If $pifu == UBound($pifucolor) Then $pifu = 0;UBound($pifucolor) 返回数组 $pifucolor的维度大小
_hoverBTN($SelectPanBtn, $OnPanBtnNum)
EndFunc ;==>_huanfu
Func _huanimg()
$imgNum += 1
If $imgNum == UBound($imgpifu) Then $imgNum = 1
_hoverBTN($SelectPanBtn, $OnPanBtnNum)
EndFunc ;==>_huanimg
Func _topbutton($btRect, $file)
Local $hHBITMAP = _hoverBTN($SelectPanBtn, $OnPanBtnNum)
Local $hCDC = _WinAPI_CreateCompatibleDC(0)
Local $hOld = _WinAPI_SelectObject($hCDC, $hHBITMAP)
Local $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hCDC)
Local $kzImage = _GDIPlus_ImageLoadFromFile($file)
_GDIPlus_GraphicsDrawImageRectRect($hGraphic, $kzImage, 0, 0, _GDIPlus_ImageGetWidth($kzImage), _GDIPlus_ImageGetHeight($kzImage), DllStructGetData($btRect, 1), DllStructGetData($btRect, 2), _GDIPlus_ImageGetWidth($kzImage), _GDIPlus_ImageGetHeight($kzImage))
_GDIPlus_ImageDispose($kzImage)
_GDIPlus_GraphicsDispose($hGraphic)
_WinAPI_SelectObject($hCDC, $hOld)
_WinAPI_DeleteDC($hCDC)
_WinAPI_UpdateLayeredWindowEx($zhu_gui, $hHBITMAP, 255);可能3.3.7开始这个函数有改变,请在$hHBITMAP前加上二个参数-1,-1
Return $hHBITMAP
EndFunc ;==>_topbutton
Func WM_NCHITTEST($hWnd, $Msg, $wParam, $lParam)
Local $tPoint, $x, $y
$tPoint = _WinAPI_GetMousePos(True, $hWnd)
Switch $hWnd
Case $zhu_gui
$OnPanBtnFlag = 0
$onTopbuttonFlag = 0
For $iI = 1 To 6
If _WinAPI_PtInRect($PanBtnRect[$iI - 1], $tPoint) Then
$OnPanBtnFlag = $iI
ExitLoop
EndIf
Next
For $iI = 1 To 7
If _WinAPI_PtInRect($topbutton[$iI - 1], $tPoint) Then
$onTopbuttonFlag = $iI
ExitLoop
EndIf
Next
If $OnPanBtnFlag == 0 And $OnPanBtnNum <> $OnPanBtnFlag Then
$OnPanBtnNum = $OnPanBtnFlag
_hoverBTN($SelectPanBtn, $OnPanBtnNum)
ElseIf $onTopbuttonFlag == 0 And $onTopbuttonNum <> $onTopbuttonFlag Then
ToolTip("")
$onTopbuttonNum = $onTopbuttonFlag
_hoverBTN($SelectPanBtn, $OnPanBtnNum)
ElseIf $OnPanBtnFlag == 0 And $onTopbuttonFlag == 0 Then
Return $HTCAPTION
ElseIf $SelectPanBtn <> $OnPanBtnFlag And $OnPanBtnNum <> $OnPanBtnFlag Then
$OnPanBtnNum = $OnPanBtnFlag
$OnPanBtnFlag = 0
_hoverBTN($SelectPanBtn, $OnPanBtnNum)
Return $HTOBJECT
ElseIf $onTopbuttonFlag > 0 And $onTopbuttonNum <> $onTopbuttonFlag Then
$onTopbuttonNum = $onTopbuttonFlag
$onTopbuttonFlag = 0
_topbutton($topbutton[$onTopbuttonNum - 1], $topbuttonhoverimg[$onTopbuttonNum - 1])
Local $wrect = _WinAPI_GetWindowRect($zhu_gui)
ToolTip($topbuttontip[$onTopbuttonNum - 1], DllStructGetData($wrect, 1) + DllStructGetData($topbutton[$onTopbuttonNum - 1], 1), DllStructGetData($wrect, 2) + DllStructGetData($topbutton[$onTopbuttonNum - 1], 2) + 30)
Return $HTOBJECT
EndIf
EndSwitch
EndFunc ;==>WM_NCHITTEST
Func WM_LBUTTONDOWN($hWnd, $Msg, $wParam, $lParam)
Local $tPoint, $DownTopbuttonFlag, $DownPanBtnFlag
$tPoint = _WinAPI_GetMousePos(True, $hWnd)
Switch $hWnd
Case $zhu_gui
$DownPanBtnFlag = 0
$DownTopbuttonFlag = 0
For $iI = 1 To 6
If _WinAPI_PtInRect($PanBtnRect[$iI - 1], $tPoint) Then
$DownPanBtnFlag = $iI
ExitLoop
EndIf
Next
For $iI = 1 To 7
If _WinAPI_PtInRect($topbutton[$iI - 1], $tPoint) Then
$DownTopbuttonFlag = $iI
ExitLoop
EndIf
Next
Switch $DownPanBtnFlag
Case 1
If $SelectPanBtn <> $DownPanBtnFlag Then
$SelectPanBtn = $DownPanBtnFlag
_hoverBTN($SelectPanBtn, 0)
GUICtrlSetData($mylabel, "第一页")
EndIf
Case 2
If $SelectPanBtn <> $DownPanBtnFlag Then
$SelectPanBtn = $DownPanBtnFlag
_hoverBTN($SelectPanBtn, 0)
GUICtrlSetData($mylabel, "第二页")
EndIf
Case 3
If $SelectPanBtn <> $DownPanBtnFlag Then
$SelectPanBtn = $DownPanBtnFlag
_hoverBTN($SelectPanBtn, 0)
GUICtrlSetData($mylabel, "第三页")
EndIf
Case 4
If $SelectPanBtn <> $DownPanBtnFlag Then
$SelectPanBtn = $DownPanBtnFlag
_hoverBTN($SelectPanBtn, 0)
GUICtrlSetData($mylabel, "第四页")
EndIf
Case 5
If $SelectPanBtn <> $DownPanBtnFlag Then
$SelectPanBtn = $DownPanBtnFlag
_hoverBTN($SelectPanBtn, 0)
GUICtrlSetData($mylabel, "第五页")
EndIf
Case 6
If $SelectPanBtn <> $DownPanBtnFlag Then
$SelectPanBtn = $DownPanBtnFlag
_hoverBTN($SelectPanBtn, 0)
GUICtrlSetData($mylabel, "第六页")
EndIf
Case 7
If $SelectPanBtn <> $DownPanBtnFlag Then
$SelectPanBtn = $DownPanBtnFlag
_hoverBTN($SelectPanBtn, 0)
GUICtrlSetData($mylabel, "第七页")
EndIf
EndSwitch
Switch $DownTopbuttonFlag
Case 1 To 7
If $DownTopbuttonNum <> $DownTopbuttonFlag Then
$DownTopbuttonNum = $DownTopbuttonFlag
_topbutton($topbutton[$DownTopbuttonNum - 1], $topbuttondownimg[$DownTopbuttonNum - 1])
ToolTip("")
EndIf
EndSwitch
EndSwitch
EndFunc ;==>WM_LBUTTONDOWN
Func WM_LBUTTONUP($hWnd, $Msg, $wParam, $lParam)
Local $tPoint, $DownTopbuttonFlag
$tPoint = _WinAPI_GetMousePos(True, $hWnd)
Switch $hWnd
Case $zhu_gui
$DownTopbuttonFlag = 0
For $iI = 1 To 7
If _WinAPI_PtInRect($topbutton[$iI - 1], $tPoint) Then
$DownTopbuttonFlag = $iI
ExitLoop
EndIf
Next
Switch $DownTopbuttonFlag
Case 1
exitfunc()
Case 2
$DownTopbuttonNum = 0
_hoverBTN($SelectPanBtn, 0)
MsgBox(0, "", " 测试 ", 2, $zhu_gui)
Return
Case 3
$DownTopbuttonNum = 0
_hoverBTN($SelectPanBtn, 0)
GUISetState(@SW_MINIMIZE, $zhu_gui)
ToolTip("")
Return
Case 4
$DownTopbuttonNum = 0
_hoverBTN($SelectPanBtn, 0)
MsgBox(0, "", " 测试 ", 2, $zhu_gui)
Return
Case 5
$DownTopbuttonNum = 0
_hoverBTN($SelectPanBtn, 0)
ShellExecute("http://www.autoitx.com/thread-28704-1-1.html")
Return
Case 6
_huanimg()
$DownTopbuttonNum = 0
Return
Case 7
_huanfu()
$DownTopbuttonNum = 0
Return
EndSwitch
EndSwitch
EndFunc ;==>WM_LBUTTONUP
Func _myPath($myx, $myy, $mywidth, $myheight, $myround = 10, $myleftup = True, $myrightup = True, $myleftdown = True, $myrightdown = True)
Local $hPath = _GDIPlus_PathCreate()
If $myleftup Then
_GDIPlus_PathAddArc($hPath, $myx, $myy, $myround, $myround, 180, 90)
Else
_GDIPlus_PathAddLine($hPath, $myx, $myy, $myx, $myy)
EndIf
If $myrightup Then
_GDIPlus_PathAddArc($hPath, $myx + $mywidth - $myround - 1, $myy, $myround, $myround, 270, 90)
Else
_GDIPlus_PathAddLine($hPath, $myx + $mywidth - 1, $myy, $myx + $mywidth - 1, $myy)
EndIf
If $myrightdown Then
_GDIPlus_PathAddArc($hPath, $myx + $mywidth - $myround - 1, $myy + $myheight - $myround - 1, $myround, $myround, 0, 90)
Else
_GDIPlus_PathAddLine($hPath, $myx + $mywidth - 1, $myy + $myheight - 1, $myx + $mywidth - 1, $myy + $myheight - 1)
EndIf
If $myleftdown Then
_GDIPlus_PathAddArc($hPath, $myx, $myy + $myheight - $myround - 1, $myround, $myround, 90, 90)
Else
_GDIPlus_PathAddLine($hPath, $myx, $myy + $myheight - 1, $myx, $myy + $myheight - 1)
EndIf
_GDIPlus_PathCloseFigures($hPath)
Return $hPath
EndFunc ;==>_myPath
mdxaux
发表于 2011-11-14 16:17:44
界面漂亮,值得学习!
seniors
发表于 2011-11-14 16:25:44
回复seniors
代码看的头疼,能就下面的问题在相关代码给出注释吗?
1成功添加了一个image,做法如下: ...
newuser 发表于 2011-11-14 16:05 http://www.autoitx.com/images/common/back.gif
WM_NCHITTEST还有WM_LBUTTONDOWN中的
For $iI = 1 To 6
If _WinAPI_PtInRect($PanBtnRect[$iI - 1], $tPoint) Then
$DownPanBtnFlag = $iI
ExitLoop
EndIf
Next
改成1 to 7
下次有空再做的好改动一些,尽量函数化,再添加说明,这种小代码重复工作我一般不加说明
seniors
发表于 2011-11-14 16:30:34
回复seniors
代码看的头疼,能就下面的问题在相关代码给出注释吗?
1成功添加了一个image,做法如下: ...
newuser 发表于 2011-11-14 16:05 http://www.autoitx.com/images/common/back.gif
注释的挺到位的啊,呵
微笑炸弹
发表于 2011-11-14 17:29:01
偶像啊,我正在学习这一方面的东东
绿色风
发表于 2011-11-14 17:33:24
超好的东西。学习。。。
风行者
发表于 2011-11-14 17:51:06
回复看看是怎样的
komaau3
发表于 2011-11-14 17:53:46
漂亮支持LZ开源
ayumi502
发表于 2011-11-14 17:55:40
非常不错 希望放出源码学习学习~~~
zldfsz
发表于 2011-11-14 18:33:27
什么东东,研究一下
页:
1
[2]
3
4
5
6
7
8
9
10
11